Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jan 4, 2025
2 parents bb3f4a2 + 884be3a commit 1da2d35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.b44t.messenger.DcMsg;
import com.b44t.messenger.rpc.Reactions;
import com.b44t.messenger.rpc.Rpc;
import com.b44t.messenger.rpc.RpcException;

import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.DcHelper;
Expand Down Expand Up @@ -124,12 +125,14 @@ private String getSelfReaction() {
String result = null;
try {
final Reactions reactions = rpc.getMsgReactions(dcContext.getAccountId(), msgToReactTo.getId());
final Map<Integer, String[]> reactionsByContact = reactions.getReactionsByContact();
final String [] selfReactions = reactionsByContact.get(DcContact.DC_CONTACT_ID_SELF);
if (selfReactions != null && selfReactions.length > 0) {
result = selfReactions[0];
if (reactions != null) {
final Map<Integer, String[]> reactionsByContact = reactions.getReactionsByContact();
final String [] selfReactions = reactionsByContact.get(DcContact.DC_CONTACT_ID_SELF);
if (selfReactions != null && selfReactions.length > 0) {
result = selfReactions[0];
}
}
} catch(Exception e) {
} catch(RpcException e) {
e.printStackTrace();
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.rpc.Reactions;
import com.b44t.messenger.rpc.RpcException;

import org.thoughtcrime.securesms.ProfileActivity;
Expand Down Expand Up @@ -85,17 +86,20 @@ private void refreshData() {

int accId = DcHelper.getContext(requireActivity()).getAccountId();
try {
Map<Integer, String[]> reactionsByContact = DcHelper.getRpc(requireActivity()).getMsgReactions(accId, msgId).getReactionsByContact();
final Reactions reactions = DcHelper.getRpc(requireActivity()).getMsgReactions(accId, msgId);
ArrayList<Pair<Integer, String>> contactsReactions = new ArrayList<>();
String[] selfReactions = reactionsByContact.remove(DcContact.DC_CONTACT_ID_SELF);
for (Integer contact: reactionsByContact.keySet()) {
for (String reaction: reactionsByContact.get(contact)) {
contactsReactions.add(new Pair<>(contact, reaction));
if (reactions != null) {
Map<Integer, String[]> reactionsByContact = reactions.getReactionsByContact();
String[] selfReactions = reactionsByContact.remove(DcContact.DC_CONTACT_ID_SELF);
for (Integer contact: reactionsByContact.keySet()) {
for (String reaction: reactionsByContact.get(contact)) {
contactsReactions.add(new Pair<>(contact, reaction));
}
}
}
if (selfReactions != null) {
for (String reaction: selfReactions) {
contactsReactions.add(new Pair<>(DcContact.DC_CONTACT_ID_SELF, reaction));
if (selfReactions != null) {
for (String reaction: selfReactions) {
contactsReactions.add(new Pair<>(DcContact.DC_CONTACT_ID_SELF, reaction));
}
}
}
adapter.changeData(contactsReactions);
Expand Down

0 comments on commit 1da2d35

Please sign in to comment.