Skip to content

Commit 3ec40e4

Browse files
committed
Added link and sync cancel.
1 parent 4f0053c commit 3ec40e4

File tree

8 files changed

+109
-73
lines changed

8 files changed

+109
-73
lines changed

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

Lines changed: 58 additions & 65 deletions
Large diffs are not rendered by default.

iOS-Email-Client/Controllers/ComposeViewController.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ class ComposeViewController: UIViewController {
3030
let DEFAULT_ATTACHMENTS_HEIGHT = 303
3131
let MAX_ROWS_BEFORE_CALC_HEIGHT = 3
3232
let ATTACHMENT_ROW_HEIGHT = 65
33-
let MARGIN_TOP = 20
33+
let MARGIN_TOP = 5
3434
let CONTACT_FIELDS_HEIGHT = 90
3535
let ENTER_LINE_HEIGHT : CGFloat = 28.0
3636
let TOOLBAR_MARGIN_HEIGHT = 25
3737
let COMPOSER_MIN_HEIGHT = 150
3838
let PASSWORD_POPUP_HEIGHT = 295
39+
let ATTACHMENT_BUTTON_HEIGHT = 32.0
3940

4041
@IBOutlet weak var fromField: UILabel!
4142
@IBOutlet weak var fromButton: UIButton!
@@ -189,7 +190,7 @@ class ComposeViewController: UIViewController {
189190

190191
let activityButton = MIBadgeButton(type: .custom)
191192
activityButton.badgeString = ""
192-
activityButton.frame = CGRect(x:14, y:8, width:18, height:32)
193+
activityButton.frame = CGRect(x:14, y:8, width:18, height: ATTACHMENT_BUTTON_HEIGHT)
193194
activityButton.imageEdgeInsets = UIEdgeInsets(top: 2, left: 2, bottom: 5, right: 2)
194195
activityButton.badgeEdgeInsets = UIEdgeInsets(top: 5, left: 12, bottom: 0, right: 13)
195196
activityButton.tintColor = Icon.enabled.color
@@ -1130,7 +1131,8 @@ extension ComposeViewController: RichEditorDelegate {
11301131
let diff = cgheight - composerEditorHeight
11311132
let offset = self.scrollView.contentOffset
11321133

1133-
if CGFloat(height + CONTACT_FIELDS_HEIGHT + TOOLBAR_MARGIN_HEIGHT) > self.toolbarView.frame.origin.y {
1134+
let calcHeight = self.attachmentButtonContainerView.layer.borderWidth + CGFloat(ATTACHMENT_BUTTON_HEIGHT)
1135+
if CGFloat(height + CONTACT_FIELDS_HEIGHT + TOOLBAR_MARGIN_HEIGHT) + calcHeight > self.toolbarView.frame.origin.y {
11341136
var newOffset = CGPoint(x: offset.x, y: offset.y + ENTER_LINE_HEIGHT)
11351137
if diff == -ENTER_LINE_HEIGHT {
11361138
newOffset = CGPoint(x: offset.x, y: offset.y - ENTER_LINE_HEIGHT)
@@ -1146,7 +1148,7 @@ extension ComposeViewController: RichEditorDelegate {
11461148
}
11471149

11481150
composerEditorHeight = cgheight
1149-
self.editorHeightConstraint.constant = cgheight + composerKeyboardOffset
1151+
self.editorHeightConstraint.constant = cgheight + self.attachmentButtonContainerView.layer.borderWidth + CGFloat(ATTACHMENT_BUTTON_HEIGHT) + composerKeyboardOffset
11501152
}
11511153

11521154
func richEditor(_ editor: RichEditorView, contentDidChange content: String) {

iOS-Email-Client/Controllers/ConnectUploadViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ConnectUploadViewController: UIViewController{
6767
}
6868

6969
override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
70+
APIManager.linkCancel(token: self.myAccount.jwt, recipientId: self.myAccount.username, domain: self.myAccount.domain ?? Env.plainDomain, completion: {_ in })
7071
super.dismiss(animated: flag, completion: completion)
7172
scheduleWorker.cancel()
7273
WebSocketManager.sharedInstance.delegate = mailboxDelegate

iOS-Email-Client/Controllers/InboxViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ extension InboxViewController: WebSocketManagerDelegate {
535535
self.handleLinkStart(linkData: data, account: account)
536536
case .LinkDismiss( _, _), .SyncDismiss( _, _):
537537
let topView = self.getTopView().presentedViewController
538-
if(topView is SignInVerificationUIPopover){
538+
if(topView is SignInVerificationUIPopover || topView is GenericDualAnswerUIPopover){
539539
topView?.dismiss(animated: false, completion: nil)
540540
}
541541
case .NewEvent(let username, let domain):

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ class ConnectDeviceViewController: UIViewController{
9393
UIApplication.shared.isIdleTimerDisabled = false
9494
socket?.close()
9595
scheduleWorker.cancel()
96-
cleanData()
97-
presentingViewController?.navigationController?.popToRootViewController(animated: false)
98-
dismiss(animated: true, completion: nil)
96+
guard let myAccount = account else {
97+
presentingViewController?.navigationController?.popToRootViewController(animated: false)
98+
dismiss(animated: true, completion: nil)
99+
return
100+
}
101+
goToMailbox(myAccount.compoundKey)
99102
}
100103

101104
func cleanData(){

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class LoginDeviceViewController: UIViewController{
4949
}
5050

5151
@IBAction func backButtonPress(_ sender: Any) {
52+
if(loginData.jwt != nil){
53+
APIManager.linkCancel(token: loginData.jwt!, recipientId: loginData.username, domain: loginData.domain, completion: {_ in })
54+
}
5255
self.navigationController?.popToRootViewController(animated: true)
5356
}
5457

iOS-Email-Client/Controllers/SettingsGeneralViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ class SettingsGeneralViewController: UIViewController{
276276
popover.rightOption = String.localize("CONTINUE")
277277
popover.onResponse = { [weak self] accept in
278278
guard accept else {
279+
guard let weakSelf = self else {
280+
return
281+
}
282+
APIManager.syncCancel(token: weakSelf.myAccount.jwt, completion: {_ in})
279283
return
280284
}
281285
self?.showManualSyncPopup()

iOS-Email-Client/Managers/APIManager.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,36 @@ class APIManager: SharedAPI {
545545
}
546546
}
547547

548+
class func linkCancel(token: String, recipientId: String, domain: String, completion: @escaping ((ResponseData) -> Void)) {
549+
let url = "\(self.baseUrl)/link/cancel"
550+
let headers = [
551+
"Authorization": "Bearer \(token)",
552+
versionHeader: apiVersion,
553+
language: Env.language
554+
]
555+
let params = [
556+
"recipientId": recipientId,
557+
"domain": domain
558+
] as [String : Any]
559+
Alamofire.request(url, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers).responseString { (response) in
560+
let responseData = handleResponse(response)
561+
completion(responseData)
562+
}
563+
}
564+
565+
class func syncCancel(token: String, completion: @escaping ((ResponseData) -> Void)) {
566+
let url = "\(self.baseUrl)/sync/cancel"
567+
let headers = [
568+
"Authorization": "Bearer \(token)",
569+
versionHeader: apiVersion,
570+
language: Env.language
571+
]
572+
Alamofire.request(url, method: .post, parameters: nil, encoding: JSONEncoding.default, headers: headers).responseString { (response) in
573+
let responseData = handleResponse(response)
574+
completion(responseData)
575+
}
576+
}
577+
548578
class func getNews(code: String, completion: @escaping ((ResponseData) -> Void)) {
549579
let url = "https://news.criptext.com/news/\(NSLocale.preferredLanguages.first!)/\(code)"
550580
Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil).responseJSON { (response) in

0 commit comments

Comments
 (0)