Fix issue #324 & #325 - Error messages with action on Friendica

This commit is contained in:
Thomas 2022-09-20 16:11:55 +02:00
parent f4bfe12abe
commit bd43af4ab8

View file

@ -224,9 +224,31 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Status statusReturned,
boolean remote) {
if (statusReturned == null) {
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return;
switch (typeOfAction) {
case BOOKMARK_ACTION:
statusToDeal.bookmarked = true;
break;
case REBLOG_ACTION:
statusToDeal.reblogged = true;
statusToDeal.reblogs_count++;
break;
case FAVOURITE_ACTION:
statusToDeal.favourited = true;
statusToDeal.favourites_count++;
break;
case UNBOOKMARK_ACTION:
statusToDeal.bookmarked = false;
break;
case UNREBLOG_ACTION:
statusToDeal.reblogged = false;
statusToDeal.reblogs_count--;
break;
case UNFAVOURITE_ACTION:
statusToDeal.favourited = false;
statusToDeal.favourites_count--;
break;
}
} else {
boolean isOK = true;
switch (typeOfAction) {
case BOOKMARK_ACTION:
@ -248,7 +270,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
isOK = !statusReturned.favourited;
break;
}
if (!isOK) {
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return;
@ -260,6 +281,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
statusToDeal.reblogs_count = statusReturned.reblogs_count;
statusToDeal.favourites_count = statusReturned.favourites_count;
}
//Update status in cache if not a remote instance
if (!remote) {
new Thread(() -> {