Skip to content

Commit cfe66fc

Browse files
committed
unsend fix, princess wishes
1 parent b153426 commit cfe66fc

12 files changed

+50
-22
lines changed

iOS-Email-Client/Base.lproj/Main.storyboard

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@
15621562
</connections>
15631563
</textField>
15641564
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NsV-eR-Br8">
1565-
<rect key="frame" x="243" y="288.5" width="105" height="38"/>
1565+
<rect key="frame" x="243" y="323.5" width="105" height="38"/>
15661566
<color key="backgroundColor" red="0.0" green="0.56862745098039214" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
15671567
<constraints>
15681568
<constraint firstAttribute="height" constant="38" id="698-sM-68Z"/>
@@ -1582,13 +1582,20 @@
15821582
</connections>
15831583
</button>
15841584
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="i2e-ku-M8K">
1585-
<rect key="frame" x="285.5" y="297.5" width="20" height="20"/>
1585+
<rect key="frame" x="285.5" y="332.5" width="20" height="20"/>
15861586
</activityIndicatorView>
1587+
<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">
1588+
<rect key="frame" x="27" y="276.5" width="321" height="38.5"/>
1589+
<fontDescription key="fontDescription" name="NunitoSans-Regular" family="Nunito Sans" pointSize="14"/>
1590+
<color key="textColor" red="0.44705882349999998" green="0.44705882349999998" blue="0.44705882349999998" alpha="1" colorSpace="calibratedRGB"/>
1591+
<nil key="highlightedColor"/>
1592+
</label>
15871593
</subviews>
15881594
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
15891595
<constraints>
15901596
<constraint firstItem="Upi-pd-9ph" firstAttribute="centerY" secondItem="S9Q-rO-GEN" secondAttribute="centerY" id="08s-mZ-uvB"/>
15911597
<constraint firstItem="W6o-Yn-D7Z" firstAttribute="centerX" secondItem="n3y-BG-AGw" secondAttribute="centerX" id="89z-bC-lqJ"/>
1598+
<constraint firstItem="lM2-53-pVD" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="18" id="AVH-O1-6N5"/>
15921599
<constraint firstItem="i2e-ku-M8K" firstAttribute="centerX" secondItem="NsV-eR-Br8" secondAttribute="centerX" id="C2f-ZQ-KiA"/>
15931600
<constraint firstItem="nCs-ch-41A" firstAttribute="trailing" secondItem="Zcd-QO-oCP" secondAttribute="trailing" id="Dob-nd-Ubf"/>
15941601
<constraint firstItem="nCs-ch-41A" firstAttribute="top" secondItem="Zcd-QO-oCP" secondAttribute="bottom" constant="15" id="E0I-5T-wke"/>
@@ -1602,11 +1609,13 @@
16021609
<constraint firstItem="n3y-BG-AGw" firstAttribute="top" secondItem="iNz-jU-IJX" secondAttribute="bottom" constant="15" id="UxJ-HK-xQo"/>
16031610
<constraint firstItem="Upi-pd-9ph" firstAttribute="leading" secondItem="iNz-jU-IJX" secondAttribute="trailing" id="W9j-nV-IB8"/>
16041611
<constraint firstItem="i2e-ku-M8K" firstAttribute="centerY" secondItem="NsV-eR-Br8" secondAttribute="centerY" id="h8k-fa-dyW"/>
1612+
<constraint firstItem="lM2-53-pVD" firstAttribute="trailing" secondItem="Upi-pd-9ph" secondAttribute="trailing" id="hVx-Vm-ajx"/>
16051613
<constraint firstItem="Zcd-QO-oCP" firstAttribute="trailing" secondItem="Upi-pd-9ph" secondAttribute="trailing" id="lXp-jg-rre"/>
16061614
<constraint firstItem="Upi-pd-9ph" firstAttribute="trailing" secondItem="S9Q-rO-GEN" secondAttribute="trailing" id="nca-MU-PVK"/>
1607-
<constraint firstItem="NsV-eR-Br8" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="30" id="ny8-6L-Lpd"/>
1615+
<constraint firstItem="NsV-eR-Br8" firstAttribute="top" secondItem="nCs-ch-41A" secondAttribute="bottom" constant="65" id="ny8-6L-Lpd"/>
16081616
<constraint firstItem="NsV-eR-Br8" firstAttribute="trailing" secondItem="Zcd-QO-oCP" secondAttribute="trailing" id="p5n-hV-tK1"/>
16091617
<constraint firstItem="W6o-Yn-D7Z" firstAttribute="centerY" secondItem="n3y-BG-AGw" secondAttribute="centerY" id="shV-9R-cgP"/>
1618+
<constraint firstItem="lM2-53-pVD" firstAttribute="leading" secondItem="Zcd-QO-oCP" secondAttribute="leading" id="t0P-WV-xcF"/>
16101619
<constraint firstItem="S9Q-rO-GEN" firstAttribute="leading" secondItem="Bc4-Fn-Mhk" secondAttribute="leading" constant="27" id="y1s-o5-hla"/>
16111620
<constraint firstItem="iNz-jU-IJX" firstAttribute="leading" secondItem="S9Q-rO-GEN" secondAttribute="leading" id="yd9-F4-Bbo"/>
16121621
</constraints>

iOS-Email-Client/Controllers/CustomTabsController.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CustomTabsController: TabsController {
2828
}
2929

3030
func loadData(){
31+
let myDevice = Device.createActiveDevice(deviceId: myAccount.deviceId)
3132
APIManager.getSettings(token: myAccount.jwt) { (responseData) in
3233
if case .Unauthorized = responseData {
3334
self.logout()
@@ -42,13 +43,8 @@ class CustomTabsController: TabsController {
4243
let general = settings["general"] as? [String: Any] else {
4344
return
4445
}
45-
for device in devices {
46-
let newDevice = Device.fromDictionary(data: device)
47-
guard !self.devicesData.devices.contains(where: {$0.id == newDevice.id && $0.active}) else {
48-
continue
49-
}
50-
self.devicesData.devices.append(newDevice)
51-
}
46+
let myDevices = devices.map({Device.fromDictionary(data: $0)}).filter({$0.id != myDevice.id}).sorted(by: {$0.safeDate > $1.safeDate})
47+
self.devicesData.devices.append(contentsOf: myDevices)
5248
let email = general["recoveryEmail"] as! String
5349
let status = general["recoveryEmailConfirmed"] as! Int
5450
let isTwoFactor = general["twoFactorAuth"] as! Int

iOS-Email-Client/Controllers/EmailDetailViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,19 @@ extension EmailDetailViewController: DetailMoreOptionsViewDelegate {
638638
self.presentPasswordPopover(myAccount: self.myAccount)
639639
return
640640
}
641+
if case .Conflicts = responseData {
642+
self.showAlert("Unsend Failed", message: "Failed to unsend the email. Time (1h) for unsending has already expired.", style: .alert)
643+
self.emailsTableView.reloadData()
644+
return
645+
}
641646
guard case .Success = responseData else {
642647
self.showAlert("Unsend Failed", message: "Unable to unsend email. Please try again later", style: .alert)
643648
self.emailsTableView.reloadData()
644649
return
645650
}
646651
DBManager.unsendEmail(email)
647652
email.isLoaded = false
653+
cell.isLoaded = false
648654
cell.setContent(email, myEmail: self.emailData.accountEmail)
649655
self.emailsTableView.reloadData()
650656
}

iOS-Email-Client/Controllers/InboxViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ extension InboxViewController: WebSocketManagerDelegate {
283283
}
284284
settings.generalData.recoveryEmail = address
285285
settings.generalData.recoveryEmailStatus = .pending
286+
settings.generalData.isTwoFactor = false
286287
settings.reloadChildViews()
287288
case .RecoveryVerified:
288289
guard let nav = self.presentedViewController as? UINavigationController,

iOS-Email-Client/Controllers/Login/LoginDeviceViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class LoginDeviceViewController: UIViewController{
1717
@IBOutlet weak var failureDeviceView: UIView!
1818
@IBOutlet weak var hourglassImage: UIImageView!
1919
@IBOutlet weak var titleLabel: UILabel!
20+
@IBOutlet weak var signWithPasswordButton: UIButton!
2021

2122
override func viewDidLoad() {
2223
super.viewDidLoad()
@@ -37,7 +38,7 @@ class LoginDeviceViewController: UIViewController{
3738
self.sendLinkAuthRequest()
3839
return
3940
}
40-
titleLabel.text = "2-Factor Authentication"
41+
signWithPasswordButton.isHidden = true
4142
self.scheduleWorker.start()
4243
}
4344

iOS-Email-Client/Controllers/Login/ResetDeviceViewController.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ResetDeviceViewController: UIViewController{
2424
var loginData: LoginData!
2525
var failed = false
2626
var buttonTitle: String {
27-
return loginData.isTwoFactor ? "Next" : "Sign-in"
27+
return loginData.isTwoFactor ? "Confirm" : "Sign-in"
2828
}
2929

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

4444
if(loginData.isTwoFactor){
4545
resetButton.setTitle(buttonTitle, for: .normal)
46-
titleLabel.text = "2-Factor Authentication"
4746
}
4847
}
4948

@@ -122,10 +121,14 @@ class ResetDeviceViewController: UIViewController{
122121
self.showFeedback(true, error.description)
123122
return
124123
}
125-
guard case .Success = responseData else {
124+
if case .BadRequest = responseData {
126125
self.showFeedback(true, "Wrong password. Please try again.")
127126
return
128127
}
128+
guard case .Success = responseData else {
129+
self.showFeedback(true, "Server Error. Please try again.")
130+
return
131+
}
129132
self.loginData.password = password.sha256()!
130133
self.jumpToLoginDeviceView(loginData: self.loginData)
131134
}

iOS-Email-Client/Controllers/RecoveryEmailViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class RecoveryEmailViewController: UIViewController {
164164
}
165165
self.generalData.recoveryEmail = email
166166
self.generalData.recoveryEmailStatus = .pending
167+
self.generalData.isTwoFactor = false
167168
self.emailTextField.detail = ""
168169
self.prepareView()
169170
self.presentResendAlert()

iOS-Email-Client/Controllers/SettingsGeneralViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SettingsGeneralViewController: UITableViewController{
1515
let ROW_HEIGHT: CGFloat = 40.0
1616
let sections = ["ACCOUNT", "ABOUT", "VERSION"] as [String]
1717
let menus = [
18-
"ACCOUNT": ["Profile", "Signature", "Change Password", "2-Factor Authentication", "Recovery Email"],
18+
"ACCOUNT": ["Profile", "Signature", "Change Password", "Two-Factor Authentication", "Recovery Email"],
1919
"ABOUT": ["Privacy Policy", "Terms of Service", "Open Source Libraries", "Logout"],
2020
"VERSION": ["Version"]] as [String: [String]]
2121
var generalData: GeneralSettingsData!
@@ -70,7 +70,7 @@ class SettingsGeneralViewController: UITableViewController{
7070
cell.loader.isHidden = true
7171
cell.goImageView.isHidden = false
7272
return cell
73-
case "2-Factor Authentication":
73+
case "Two-Factor Authentication":
7474
let cell = tableView.dequeueReusableCell(withIdentifier: "settingsGeneralSwitch") as! GeneralSwitchTableViewCell
7575
cell.optionLabel.text = text
7676
cell.availableSwitch.isOn = generalData.isTwoFactor
@@ -259,6 +259,10 @@ class SettingsGeneralViewController: UITableViewController{
259259
let initialValue = self.generalData.isTwoFactor
260260
self.generalData.isTwoFactor = enable
261261
APIManager.setTwoFactor(isOn: enable, token: myAccount.jwt) { (responseData) in
262+
if case .Conflicts = responseData {
263+
self.presentRecoveryPopover()
264+
return
265+
}
262266
guard case .Success = responseData else {
263267
self.showAlert("Something went wrong", message: "Unable to \(enable ? "enable" : "disable") two pass. Please try again", style: .alert)
264268
self.generalData.isTwoFactor = initialValue

iOS-Email-Client/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0.11</string>
20+
<string>1.0.12</string>
2121
<key>CFBundleURLTypes</key>
2222
<array>
2323
<dict>
@@ -30,7 +30,7 @@
3030
</dict>
3131
</array>
3232
<key>CFBundleVersion</key>
33-
<string>2</string>
33+
<string>1</string>
3434
<key>Fabric</key>
3535
<dict>
3636
<key>APIKey</key>

iOS-Email-Client/Login.storyboard

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
<action selector="onDidEndOnExit:" destination="OMZ-WS-rzb" eventType="editingDidEndOnExit" id="47k-IR-8FF"/>
384384
</connections>
385385
</textField>
386-
<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">
386+
<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">
387387
<rect key="frame" x="56" y="446.5" width="265" height="30"/>
388388
<constraints>
389389
<constraint firstAttribute="height" constant="30" id="XFo-u4-bU8"/>
@@ -992,6 +992,7 @@ from Criptext</string>
992992
<connections>
993993
<outlet property="failureDeviceView" destination="0gh-tT-mLY" id="EwJ-16-AYR"/>
994994
<outlet property="hourglassImage" destination="CQ6-X5-Uq5" id="A4Z-X8-aXv"/>
995+
<outlet property="signWithPasswordButton" destination="Jek-k9-O5Z" id="Qpq-zR-Te8"/>
995996
<outlet property="titleLabel" destination="AGe-4s-CNR" id="hBq-SA-IQn"/>
996997
<outlet property="waitingDeviceView" destination="oqf-Tb-I2x" id="R2I-IK-Hgb"/>
997998
</connections>

0 commit comments

Comments
 (0)