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