Skip to content

Commit

Permalink
unsend fix, princess wishes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirobreak committed Oct 19, 2018
1 parent b153426 commit cfe66fc
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 22 deletions.
15 changes: 12 additions & 3 deletions iOS-Email-Client/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NsV-eR-Br8">
<rect key="frame" x="243" y="288.5" width="105" height="38"/>
<rect key="frame" x="243" y="323.5" width="105" height="38"/>
<color key="backgroundColor" red="0.0" green="0.56862745098039214" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="698-sM-68Z"/>
Expand All @@ -1582,13 +1582,20 @@
</connections>
</button>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="i2e-ku-M8K">
<rect key="frame" x="285.5" y="297.5" width="20" height="20"/>
<rect key="frame" x="285.5" y="332.5" width="20" height="20"/>
</activityIndicatorView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Note: Changing your recovery email will turn off Two-Factor Authentication" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lM2-53-pVD">
<rect key="frame" x="27" y="276.5" width="321" height="38.5"/>
<fontDescription key="fontDescription" name="NunitoSans-Regular" family="Nunito Sans" pointSize="14"/>
<color key="textColor" red="0.44705882349999998" green="0.44705882349999998" blue="0.44705882349999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Upi-pd-9ph" firstAttribute="centerY" secondItem="S9Q-rO-GEN" secondAttribute="centerY" id="08s-mZ-uvB"/>
<constraint firstItem="W6o-Yn-D7Z" firstAttribute="centerX" secondItem="n3y-BG-AGw" secondAttribute="centerX" id="89z-bC-lqJ"/>
<constraint firstItem="lM2-53-pVD" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="18" id="AVH-O1-6N5"/>
<constraint firstItem="i2e-ku-M8K" firstAttribute="centerX" secondItem="NsV-eR-Br8" secondAttribute="centerX" id="C2f-ZQ-KiA"/>
<constraint firstItem="nCs-ch-41A" firstAttribute="trailing" secondItem="Zcd-QO-oCP" secondAttribute="trailing" id="Dob-nd-Ubf"/>
<constraint firstItem="nCs-ch-41A" firstAttribute="top" secondItem="Zcd-QO-oCP" secondAttribute="bottom" constant="15" id="E0I-5T-wke"/>
Expand All @@ -1602,11 +1609,13 @@
<constraint firstItem="n3y-BG-AGw" firstAttribute="top" secondItem="iNz-jU-IJX" secondAttribute="bottom" constant="15" id="UxJ-HK-xQo"/>
<constraint firstItem="Upi-pd-9ph" firstAttribute="leading" secondItem="iNz-jU-IJX" secondAttribute="trailing" id="W9j-nV-IB8"/>
<constraint firstItem="i2e-ku-M8K" firstAttribute="centerY" secondItem="NsV-eR-Br8" secondAttribute="centerY" id="h8k-fa-dyW"/>
<constraint firstItem="lM2-53-pVD" firstAttribute="trailing" secondItem="Upi-pd-9ph" secondAttribute="trailing" id="hVx-Vm-ajx"/>
<constraint firstItem="Zcd-QO-oCP" firstAttribute="trailing" secondItem="Upi-pd-9ph" secondAttribute="trailing" id="lXp-jg-rre"/>
<constraint firstItem="Upi-pd-9ph" firstAttribute="trailing" secondItem="S9Q-rO-GEN" secondAttribute="trailing" id="nca-MU-PVK"/>
<constraint firstItem="NsV-eR-Br8" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="30" id="ny8-6L-Lpd"/>
<constraint firstItem="NsV-eR-Br8" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="65" id="ny8-6L-Lpd"/>
<constraint firstItem="NsV-eR-Br8" firstAttribute="trailing" secondItem="Zcd-QO-oCP" secondAttribute="trailing" id="p5n-hV-tK1"/>
<constraint firstItem="W6o-Yn-D7Z" firstAttribute="centerY" secondItem="n3y-BG-AGw" secondAttribute="centerY" id="shV-9R-cgP"/>
<constraint firstItem="lM2-53-pVD" firstAttribute="leading" secondItem="Zcd-QO-oCP" secondAttribute="leading" id="t0P-WV-xcF"/>
<constraint firstItem="S9Q-rO-GEN" firstAttribute="leading" secondItem="Bc4-Fn-Mhk" secondAttribute="leading" constant="27" id="y1s-o5-hla"/>
<constraint firstItem="iNz-jU-IJX" firstAttribute="leading" secondItem="S9Q-rO-GEN" secondAttribute="leading" id="yd9-F4-Bbo"/>
</constraints>
Expand Down
10 changes: 3 additions & 7 deletions iOS-Email-Client/Controllers/CustomTabsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CustomTabsController: TabsController {
}

func loadData(){
let myDevice = Device.createActiveDevice(deviceId: myAccount.deviceId)
APIManager.getSettings(token: myAccount.jwt) { (responseData) in
if case .Unauthorized = responseData {
self.logout()
Expand All @@ -42,13 +43,8 @@ class CustomTabsController: TabsController {
let general = settings["general"] as? [String: Any] else {
return
}
for device in devices {
let newDevice = Device.fromDictionary(data: device)
guard !self.devicesData.devices.contains(where: {$0.id == newDevice.id && $0.active}) else {
continue
}
self.devicesData.devices.append(newDevice)
}
let myDevices = devices.map({Device.fromDictionary(data: $0)}).filter({$0.id != myDevice.id}).sorted(by: {$0.safeDate > $1.safeDate})
self.devicesData.devices.append(contentsOf: myDevices)
let email = general["recoveryEmail"] as! String
let status = general["recoveryEmailConfirmed"] as! Int
let isTwoFactor = general["twoFactorAuth"] as! Int
Expand Down
6 changes: 6 additions & 0 deletions iOS-Email-Client/Controllers/EmailDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,19 @@ extension EmailDetailViewController: DetailMoreOptionsViewDelegate {
self.presentPasswordPopover(myAccount: self.myAccount)
return
}
if case .Conflicts = responseData {
self.showAlert("Unsend Failed", message: "Failed to unsend the email. Time (1h) for unsending has already expired.", style: .alert)
self.emailsTableView.reloadData()
return
}
guard case .Success = responseData else {
self.showAlert("Unsend Failed", message: "Unable to unsend email. Please try again later", style: .alert)
self.emailsTableView.reloadData()
return
}
DBManager.unsendEmail(email)
email.isLoaded = false
cell.isLoaded = false
cell.setContent(email, myEmail: self.emailData.accountEmail)
self.emailsTableView.reloadData()
}
Expand Down
1 change: 1 addition & 0 deletions iOS-Email-Client/Controllers/InboxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ extension InboxViewController: WebSocketManagerDelegate {
}
settings.generalData.recoveryEmail = address
settings.generalData.recoveryEmailStatus = .pending
settings.generalData.isTwoFactor = false
settings.reloadChildViews()
case .RecoveryVerified:
guard let nav = self.presentedViewController as? UINavigationController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class LoginDeviceViewController: UIViewController{
@IBOutlet weak var failureDeviceView: UIView!
@IBOutlet weak var hourglassImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var signWithPasswordButton: UIButton!

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -37,7 +38,7 @@ class LoginDeviceViewController: UIViewController{
self.sendLinkAuthRequest()
return
}
titleLabel.text = "2-Factor Authentication"
signWithPasswordButton.isHidden = true
self.scheduleWorker.start()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ResetDeviceViewController: UIViewController{
var loginData: LoginData!
var failed = false
var buttonTitle: String {
return loginData.isTwoFactor ? "Next" : "Sign-in"
return loginData.isTwoFactor ? "Confirm" : "Sign-in"
}

override func viewDidLoad() {
Expand All @@ -43,7 +43,6 @@ class ResetDeviceViewController: UIViewController{

if(loginData.isTwoFactor){
resetButton.setTitle(buttonTitle, for: .normal)
titleLabel.text = "2-Factor Authentication"
}
}

Expand Down Expand Up @@ -122,10 +121,14 @@ class ResetDeviceViewController: UIViewController{
self.showFeedback(true, error.description)
return
}
guard case .Success = responseData else {
if case .BadRequest = responseData {
self.showFeedback(true, "Wrong password. Please try again.")
return
}
guard case .Success = responseData else {
self.showFeedback(true, "Server Error. Please try again.")
return
}
self.loginData.password = password.sha256()!
self.jumpToLoginDeviceView(loginData: self.loginData)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class RecoveryEmailViewController: UIViewController {
}
self.generalData.recoveryEmail = email
self.generalData.recoveryEmailStatus = .pending
self.generalData.isTwoFactor = false
self.emailTextField.detail = ""
self.prepareView()
self.presentResendAlert()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SettingsGeneralViewController: UITableViewController{
let ROW_HEIGHT: CGFloat = 40.0
let sections = ["ACCOUNT", "ABOUT", "VERSION"] as [String]
let menus = [
"ACCOUNT": ["Profile", "Signature", "Change Password", "2-Factor Authentication", "Recovery Email"],
"ACCOUNT": ["Profile", "Signature", "Change Password", "Two-Factor Authentication", "Recovery Email"],
"ABOUT": ["Privacy Policy", "Terms of Service", "Open Source Libraries", "Logout"],
"VERSION": ["Version"]] as [String: [String]]
var generalData: GeneralSettingsData!
Expand Down Expand Up @@ -70,7 +70,7 @@ class SettingsGeneralViewController: UITableViewController{
cell.loader.isHidden = true
cell.goImageView.isHidden = false
return cell
case "2-Factor Authentication":
case "Two-Factor Authentication":
let cell = tableView.dequeueReusableCell(withIdentifier: "settingsGeneralSwitch") as! GeneralSwitchTableViewCell
cell.optionLabel.text = text
cell.availableSwitch.isOn = generalData.isTwoFactor
Expand Down Expand Up @@ -259,6 +259,10 @@ class SettingsGeneralViewController: UITableViewController{
let initialValue = self.generalData.isTwoFactor
self.generalData.isTwoFactor = enable
APIManager.setTwoFactor(isOn: enable, token: myAccount.jwt) { (responseData) in
if case .Conflicts = responseData {
self.presentRecoveryPopover()
return
}
guard case .Success = responseData else {
self.showAlert("Something went wrong", message: "Unable to \(enable ? "enable" : "disable") two pass. Please try again", style: .alert)
self.generalData.isTwoFactor = initialValue
Expand Down
4 changes: 2 additions & 2 deletions iOS-Email-Client/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.11</string>
<string>1.0.12</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2</string>
<string>1</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
3 changes: 2 additions & 1 deletion iOS-Email-Client/Login.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
<action selector="onDidEndOnExit:" destination="OMZ-WS-rzb" eventType="editingDidEndOnExit" id="47k-IR-8FF"/>
</connections>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Recover Email (Optional)" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="lKE-K8-r13" customClass="StatusTextField" customModule="iOS_Email_Client" customModuleProvider="target">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Recovery Email (Optional)" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="lKE-K8-r13" customClass="StatusTextField" customModule="iOS_Email_Client" customModuleProvider="target">
<rect key="frame" x="56" y="446.5" width="265" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="XFo-u4-bU8"/>
Expand Down Expand Up @@ -992,6 +992,7 @@ from Criptext</string>
<connections>
<outlet property="failureDeviceView" destination="0gh-tT-mLY" id="EwJ-16-AYR"/>
<outlet property="hourglassImage" destination="CQ6-X5-Uq5" id="A4Z-X8-aXv"/>
<outlet property="signWithPasswordButton" destination="Jek-k9-O5Z" id="Qpq-zR-Te8"/>
<outlet property="titleLabel" destination="AGe-4s-CNR" id="hBq-SA-IQn"/>
<outlet property="waitingDeviceView" destination="oqf-Tb-I2x" id="R2I-IK-Hgb"/>
</connections>
Expand Down
6 changes: 6 additions & 0 deletions iOS-Email-Client/Model/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class Device {
var active = false
var type = Kind.ios.rawValue
var lastActivity: Date?
var safeDate: Date {
guard let myDate = lastActivity else {
return Date(timeIntervalSinceNow: -(60 * 60 * 24 * 62))
}
return myDate
}

enum Kind : Int{
case pc = 1
Expand Down
6 changes: 3 additions & 3 deletions iOS-Email-Client/Views/SettingsDeviceTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class SettingsDeviceTableViewCell: UITableViewCell {
guard !device.active else {
return
}
let attrString = NSMutableAttributedString(string: "Last Activity", attributes: [NSAttributedStringKey.font: Font.bold.size(12.0)!])
let attrString = NSMutableAttributedString(string: "Last Active ", attributes: [NSAttributedStringKey.font: Font.bold.size(12.0)!])
guard let date = device.lastActivity else {
attrString.append(NSAttributedString(string: " - Over 2 month ago", attributes: [NSAttributedStringKey.font: Font.regular.size(12.0)!]))
attrString.append(NSAttributedString(string: "Over 2 month ago", attributes: [NSAttributedStringKey.font: Font.regular.size(12.0)!]))
deviceLocationLabel.attributedText = attrString
return
}
attrString.append(NSAttributedString(string: " - \(String(DateUtils.beautyDate(date)!).replacingOccurrences(of: "at ", with: ""))", attributes: [NSAttributedStringKey.font: Font.regular.size(12.0)!]))
attrString.append(NSAttributedString(string: "\(String(DateUtils.beautyDate(date)!).replacingOccurrences(of: "at ", with: ""))", attributes: [NSAttributedStringKey.font: Font.regular.size(12.0)!]))
deviceLocationLabel.attributedText = attrString
}

Expand Down

0 comments on commit cfe66fc

Please sign in to comment.