From 23e4541eb7b5177a96b6b0091a07580bf7a63e51 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 14 Dec 2022 21:00:36 -0500 Subject: [PATCH] Don't reload list timeline if edit screen is closed without making changes --- .../Lists/EditListAccountsViewController.swift | 6 ++++-- Tusker/Screens/Lists/ListTimelineViewController.swift | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Tusker/Screens/Lists/EditListAccountsViewController.swift b/Tusker/Screens/Lists/EditListAccountsViewController.swift index 7a2d8ba5..11660b99 100644 --- a/Tusker/Screens/Lists/EditListAccountsViewController.swift +++ b/Tusker/Screens/Lists/EditListAccountsViewController.swift @@ -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) diff --git a/Tusker/Screens/Lists/ListTimelineViewController.swift b/Tusker/Screens/Lists/ListTimelineViewController.swift index 5c1c83cf..eab7d025 100644 --- a/Tusker/Screens/Lists/ListTimelineViewController.swift +++ b/Tusker/Screens/Lists/ListTimelineViewController.swift @@ -71,12 +71,15 @@ 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 - Task { - applyInitialSnapshot() - await controller.loadInitial() + if presented?.changedAccounts == true { + Task { + applyInitialSnapshot() + await controller.loadInitial() + } } }