From f43e7880f711e0d01fc88010d046d35aaae37e16 Mon Sep 17 00:00:00 2001 From: austinate Date: Mon, 23 Dec 2019 17:20:52 +0200 Subject: [PATCH 01/58] iOS, Add Folder: Make sure Account Name field is in sync with selected account in picker --- iOS/Add/AddFolderViewController.swift | 47 ++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/iOS/Add/AddFolderViewController.swift b/iOS/Add/AddFolderViewController.swift index 3d2dc0047..26d794a10 100644 --- a/iOS/Add/AddFolderViewController.swift +++ b/iOS/Add/AddFolderViewController.swift @@ -20,7 +20,22 @@ class AddFolderViewController: UITableViewController, AddContainerViewController return accounts.count > 1 } - private var accounts: [Account]! + private var accounts: [Account]! { + didSet { + if let predefinedAccount = accounts.first(where: { $0.accountID == AppDefaults.addFolderAccountID }) { + selectedAccount = predefinedAccount + } else { + selectedAccount = accounts[0] + } + } + } + + private var selectedAccount: Account! { + didSet { + guard selectedAccount != oldValue else { return } + accountLabel.text = selectedAccount.flatMap { ($0 as DisplayNameProvider).nameForDisplay } + } + } weak var delegate: AddContainerViewControllerChildDelegate? @@ -32,13 +47,11 @@ class AddFolderViewController: UITableViewController, AddContainerViewController nameTextField.delegate = self - accountLabel.text = (accounts[0] as DisplayNameProvider).nameForDisplay - if shouldDisplayPicker { accountPickerView.dataSource = self accountPickerView.delegate = self - if let index = accounts.firstIndex(where: { $0.accountID == AppDefaults.addFolderAccountID }) { + if let index = accounts.firstIndex(of: selectedAccount) { accountPickerView.selectRow(index, inComponent: 0, animated: false) } @@ -52,21 +65,26 @@ class AddFolderViewController: UITableViewController, AddContainerViewController NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: nameTextField) } + + private func didSelect(_ account: Account) { + AppDefaults.addFolderAccountID = account.accountID + selectedAccount = account + } func cancel() { delegate?.processingDidEnd() } func add() { - let account = accounts[accountPickerView.selectedRow(inComponent: 0)] - if let folderName = nameTextField.text { - account.addFolder(folderName) { result in - switch result { - case .success: - self.delegate?.processingDidEnd() - case .failure(let error): - self.presentError(error) - } + guard let folderName = nameTextField.text else { + return + } + selectedAccount.addFolder(folderName) { result in + switch result { + case .success: + self.delegate?.processingDidEnd() + case .failure(let error): + self.presentError(error) } } } @@ -100,8 +118,7 @@ extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate } func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - accountLabel.text = (accounts[row] as DisplayNameProvider).nameForDisplay - AppDefaults.addFolderAccountID = accounts[row].accountID + didSelect(accounts[row]) } } From 61370dd04d9ad38cc9bd9cb50140adeaa7e84719 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 24 Dec 2019 17:34:47 -0700 Subject: [PATCH 02/58] Fix so that we don't try to scroll before the datasource has been fully applied to the table. Issue #1463 --- iOS/MasterTimeline/MasterTimelineViewController.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 3d8ce6479..709e1f117 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -74,11 +74,12 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner } resetUI(resetScroll: true) - applyChanges(animated: false) - // Restore the scroll position if we have one stored - if let restoreIndexPath = coordinator.timelineMiddleIndexPath { - tableView.scrollToRow(at: restoreIndexPath, at: .middle, animated: false) + // Load the table and then scroll to the saved position if available + applyChanges(animated: false) { + if let restoreIndexPath = self.coordinator.timelineMiddleIndexPath { + self.tableView.scrollToRow(at: restoreIndexPath, at: .middle, animated: false) + } } } From 84d1ccadfdb16a26cebf206ae559052fdb258fcb Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 24 Dec 2019 17:55:56 -0700 Subject: [PATCH 03/58] Clear the saved middle position when emptying the timeline. Issue #1464 --- iOS/SceneCoordinator.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 9cb6d5ef1..76955cd20 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -1551,6 +1551,7 @@ private extension SceneCoordinator { func emptyTheTimeline() { if !articles.isEmpty { + timelineMiddleIndexPath = nil replaceArticles(with: Set
(), animated: false) } } From 758fb1a1c0fd2ac3cba3ea8c453e7e6d93eafbcf Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Tue, 24 Dec 2019 20:12:10 -0600 Subject: [PATCH 04/58] Make initial scale 100% and don't let WebKit increase text size Issue #1459. --- iOS/Resources/page.html | 2 +- iOS/Resources/styleSheet.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/iOS/Resources/page.html b/iOS/Resources/page.html index 9d60b7f68..fae517747 100644 --- a/iOS/Resources/page.html +++ b/iOS/Resources/page.html @@ -1,6 +1,6 @@ - +