Skip to content

Commit

Permalink
feat(unoficial-quote-posts): add caching to unofficial quote toots
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGGamerM committed Jul 26, 2024
1 parent 1b6978b commit ca07240
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit ca07240

Please sign in to comment.