fix(custom-local-timelines): Removing the get account by handle function for each status, and interactions now are fully working.

This commit is contained in:
LucasGGamerM
2023-02-25 14:18:27 -03:00
parent 75f311b8a7
commit 5e97adcd3b
2 changed files with 52 additions and 12 deletions

View File

@@ -61,18 +61,6 @@ public class CustomLocalTimelineFragment extends StatusListFragment {
result.stream().forEach(status -> { result.stream().forEach(status -> {
status.account.acct += "@"+domain; status.account.acct += "@"+domain;
status.reloadWhenClicked = true; status.reloadWhenClicked = true;
new GetAccountByHandle(status.account.acct)
.setCallback(new Callback<Account>() {
@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()); onDataLoaded(result, !result.isEmpty());

View File

@@ -191,6 +191,19 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
} }
private void onReplyClick(View v){ 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); v.startAnimation(opacityIn);
Bundle args=new Bundle(); Bundle args=new Bundle();
args.putString("account", item.accountID); args.putString("account", item.accountID);
@@ -214,6 +227,16 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
} }
private void onBoostClick(View v){ 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); boost.setSelected(!item.status.reblogged);
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setReblogged(item.status, !item.status.reblogged, null, r->boostConsumer(v, r)); 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){ 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); favorite.setSelected(!item.status.favourited);
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{ AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{
if (item.status.favourited) { if (item.status.favourited) {
@@ -336,6 +376,18 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
} }
private void onBookmarkClick(View v){ 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); bookmark.setSelected(!item.status.bookmarked);
AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{ AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setBookmarked(item.status, !item.status.bookmarked, r->{
v.startAnimation(opacityIn); v.startAnimation(opacityIn);