Don't reload list timeline if edit screen is closed without making changes
This commit is contained in:
parent
d4b9f71fd3
commit
23e4541eb7
|
@ -12,12 +12,12 @@ import Combine
|
||||||
|
|
||||||
class EditListAccountsViewController: EnhancedTableViewController {
|
class EditListAccountsViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
|
private var list: List
|
||||||
let mastodonController: MastodonController
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
private var list: List
|
var changedAccounts = false
|
||||||
|
|
||||||
var dataSource: DataSource!
|
var dataSource: DataSource!
|
||||||
|
|
||||||
var nextRange: RequestRange?
|
var nextRange: RequestRange?
|
||||||
|
|
||||||
var searchResultsController: SearchResultsViewController!
|
var searchResultsController: SearchResultsViewController!
|
||||||
|
@ -122,6 +122,7 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addAccount(id: String) async {
|
private func addAccount(id: String) async {
|
||||||
|
changedAccounts = true
|
||||||
do {
|
do {
|
||||||
let req = List.add(list, accounts: [id])
|
let req = List.add(list, accounts: [id])
|
||||||
_ = try await mastodonController.run(req)
|
_ = try await mastodonController.run(req)
|
||||||
|
@ -137,6 +138,7 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func removeAccount(id: String) async {
|
private func removeAccount(id: String) async {
|
||||||
|
changedAccounts = true
|
||||||
do {
|
do {
|
||||||
let request = List.remove(list, accounts: [id])
|
let request = List.remove(list, accounts: [id])
|
||||||
_ = try await mastodonController.run(request)
|
_ = try await mastodonController.run(request)
|
||||||
|
|
|
@ -71,13 +71,16 @@ class ListTimelineViewController: TimelineViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func editListDoneButtonPressed() {
|
@objc func editListDoneButtonPressed() {
|
||||||
|
let presented = (presentedViewController as? UINavigationController)?.viewControllers.first as? EditListAccountsViewController
|
||||||
|
|
||||||
dismiss(animated: true)
|
dismiss(animated: true)
|
||||||
|
|
||||||
// TODO: only reload if there were changes
|
if presented?.changedAccounts == true {
|
||||||
Task {
|
Task {
|
||||||
applyInitialSnapshot()
|
applyInitialSnapshot()
|
||||||
await controller.loadInitial()
|
await controller.loadInitial()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue