Don't reload list timeline if edit screen is closed without making changes

This commit is contained in:
Shadowfacts 2022-12-14 21:00:36 -05:00
parent d4b9f71fd3
commit 23e4541eb7
2 changed files with 11 additions and 6 deletions

View File

@ -12,12 +12,12 @@ import Combine
class EditListAccountsViewController: EnhancedTableViewController {
private var list: List
let mastodonController: MastodonController
private var list: List
var changedAccounts = false
var dataSource: DataSource!
var nextRange: RequestRange?
var searchResultsController: SearchResultsViewController!
@ -122,6 +122,7 @@ class EditListAccountsViewController: EnhancedTableViewController {
}
private func addAccount(id: String) async {
changedAccounts = true
do {
let req = List.add(list, accounts: [id])
_ = try await mastodonController.run(req)
@ -137,6 +138,7 @@ class EditListAccountsViewController: EnhancedTableViewController {
}
private func removeAccount(id: String) async {
changedAccounts = true
do {
let request = List.remove(list, accounts: [id])
_ = try await mastodonController.run(request)

View File

@ -71,13 +71,16 @@ class ListTimelineViewController: TimelineViewController {
}
@objc func editListDoneButtonPressed() {
let presented = (presentedViewController as? UINavigationController)?.viewControllers.first as? EditListAccountsViewController
dismiss(animated: true)
// TODO: only reload if there were changes
if presented?.changedAccounts == true {
Task {
applyInitialSnapshot()
await controller.loadInitial()
}
}
}
}