From 5e97adcd3b5e953b4a6ae6273fa6bcef6f0791e7 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Sat, 25 Feb 2023 14:18:27 -0300 Subject: [PATCH] fix(custom-local-timelines): Removing the get account by handle function for each status, and interactions now are fully working. --- .../CustomLocalTimelineFragment.java | 12 ----- .../displayitems/FooterStatusDisplayItem.java | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/CustomLocalTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/CustomLocalTimelineFragment.java index 9c8cc210c..7b8ff6551 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/CustomLocalTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/CustomLocalTimelineFragment.java @@ -61,18 +61,6 @@ public class CustomLocalTimelineFragment extends StatusListFragment { result.stream().forEach(status -> { status.account.acct += "@"+domain; status.reloadWhenClicked = true; - new GetAccountByHandle(status.account.acct) - .setCallback(new Callback() { - @Override - public void onSuccess(Account result) { - status.account.id = result.id; - } - - @Override - public void onError(ErrorResponse error) { - error.showToast(getContext()); - } - }).exec(accountID); }); onDataLoaded(result, !result.isEmpty()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index ce177767a..97016e21c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -191,6 +191,19 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } private void onReplyClick(View v){ + if(item.status.reloadWhenClicked){ + UiUtils.lookupStatus(v.getContext(), + item.status, item.accountID, null, + status -> { + v.startAnimation(opacityIn); + Bundle args=new Bundle(); + args.putString("account", item.accountID); + args.putParcelable("replyTo", Parcels.wrap(status)); + Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + } + ); + return; + } v.startAnimation(opacityIn); Bundle args=new Bundle(); args.putString("account", item.accountID); @@ -214,6 +227,16 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } private void onBoostClick(View v){ + if(item.status.reloadWhenClicked){ + UiUtils.lookupStatus(v.getContext(), + item.status, item.accountID, null, + status -> { + boost.setSelected(!status.reblogged); + AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(status, !status.reblogged, null, r->boostConsumer(v, r)); + } + ); + return; + } boost.setSelected(!item.status.reblogged); AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, null, r->boostConsumer(v, r)); } @@ -310,6 +333,23 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } private void onFavoriteClick(View v){ + if(item.status.reloadWhenClicked){ + UiUtils.lookupStatus(v.getContext(), + item.status, item.accountID, null, + status -> { + favorite.setSelected(!status.favourited); + AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(status, !status.favourited, r->{ + if (status.favourited) { + v.startAnimation(GlobalUserPreferences.reduceMotion ? opacityIn : animSet); + } else { + v.startAnimation(opacityIn); + } + bindButton(favorite, r.favouritesCount); + }); + } + ); + return; + } favorite.setSelected(!item.status.favourited); AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{ if (item.status.favourited) { @@ -336,6 +376,18 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } private void onBookmarkClick(View v){ + if(item.status.reloadWhenClicked){ + UiUtils.lookupStatus(v.getContext(), + item.status, item.accountID, null, + status -> { + bookmark.setSelected(!status.bookmarked); + AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(status, !status.bookmarked, r->{ + v.startAnimation(opacityIn); + }); + } + ); + return; + } bookmark.setSelected(!item.status.bookmarked); AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{ v.startAnimation(opacityIn);