From ca07240a706a1b8b103510f560a62a3be2760a42 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 26 Jul 2024 14:03:51 -0300 Subject: [PATCH] feat(unoficial-quote-posts): add caching to unofficial quote toots --- .../android/fragments/BaseStatusListFragment.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 4368690f30..191c2ebd8e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -23,6 +23,7 @@ import org.joinmastodon.android.E; import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.CacheController; import org.joinmastodon.android.api.MastodonAPIRequest; import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships; import org.joinmastodon.android.api.requests.polls.SubmitPollVote; @@ -33,6 +34,7 @@ import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.AkkomaTranslation; import org.joinmastodon.android.model.DisplayItemsParent; +import org.joinmastodon.android.model.Notification; import org.joinmastodon.android.model.Poll; import org.joinmastodon.android.model.Relationship; import org.joinmastodon.android.model.Status; @@ -727,6 +729,15 @@ public void updateStatusWithQuote(DisplayItemsParent parent) { int prevSize=oldItems.size(); oldItems.clear(); displayItems.addAll(startIndex, newItems); + + // Update the cache + final CacheController cache=AccountSessionManager.get(accountID).getCacheController(); + if (parent instanceof Status) { + cache.updateStatus((Status) parent); + } else if (parent instanceof Notification) { + cache.updateNotification((Notification) parent); + } + adapter.notifyItemRangeRemoved(startIndex, prevSize); adapter.notifyItemRangeInserted(startIndex, newItems.size()); }