mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 21:08:26 +00:00
Fix problem with creating group and empty avatar
This commit is contained in:
parent
c2dbb34b25
commit
d9ab1a93f8
@ -221,15 +221,20 @@ public class GroupDatabase extends Database {
|
||||
}
|
||||
|
||||
public void updateAvatar(String groupId, byte[] avatar) {
|
||||
long avatarId = Math.abs(new SecureRandom().nextLong());
|
||||
ContentValues contentValues = new ContentValues();
|
||||
long avatarId;
|
||||
|
||||
if (avatar != null) avatarId = Math.abs(new SecureRandom().nextLong());
|
||||
else avatarId = 0;
|
||||
|
||||
|
||||
ContentValues contentValues = new ContentValues(2);
|
||||
contentValues.put(AVATAR, avatar);
|
||||
contentValues.put(AVATAR_ID, avatarId);
|
||||
|
||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues, GROUP_ID + " = ?",
|
||||
new String[] {groupId});
|
||||
|
||||
Recipient.applyCached(Address.fromSerialized(groupId), recipient -> recipient.setGroupAvatarId(avatarId));
|
||||
Recipient.applyCached(Address.fromSerialized(groupId), recipient -> recipient.setGroupAvatarId(avatarId == 0 ? null : avatarId));
|
||||
}
|
||||
|
||||
public void updateMembers(String groupId, List<Address> members) {
|
||||
|
@ -21,6 +21,7 @@ import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
@ -130,6 +131,7 @@ class RecipientProvider {
|
||||
String title = groupRecord.get().getTitle();
|
||||
List<Address> memberAddresses = groupRecord.get().getMembers();
|
||||
List<Recipient> members = new LinkedList<>();
|
||||
Long avatarId = null;
|
||||
|
||||
for (Address memberAddress : memberAddresses) {
|
||||
members.add(getRecipient(context, memberAddress, Optional.absent(), Optional.absent(), asynchronous));
|
||||
@ -139,7 +141,11 @@ class RecipientProvider {
|
||||
title = context.getString(R.string.RecipientProvider_unnamed_group);
|
||||
}
|
||||
|
||||
return new RecipientDetails(title, groupRecord.get().getAvatarId(), false, settings.orNull(), members);
|
||||
if (groupRecord.get().getAvatarId() != 0) {
|
||||
avatarId = groupRecord.get().getAvatarId();
|
||||
}
|
||||
|
||||
return new RecipientDetails(title, avatarId, false, settings.orNull(), members);
|
||||
}
|
||||
|
||||
return new RecipientDetails(context.getString(R.string.RecipientProvider_unnamed_group), null, false, settings.orNull(), null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user