mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 05:58:34 +00:00
Fix custom notification creation.
This commit is contained in:
parent
e273593343
commit
ced48d0788
@ -848,7 +848,7 @@ public class RecipientDatabase extends Database {
|
||||
|
||||
public @NonNull Recipient getCurrent() {
|
||||
RecipientId id = RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));
|
||||
return Recipient.live(id).get();
|
||||
return Recipient.resolved(id);
|
||||
}
|
||||
|
||||
public @Nullable Recipient getNext() {
|
||||
|
@ -407,14 +407,17 @@ public class NotificationChannels {
|
||||
|
||||
for (NotificationChannel existingChannel : notificationManager.getNotificationChannels()) {
|
||||
if (existingChannel.getId().startsWith(CONTACT_PREFIX) && !customChannelIds.contains(existingChannel.getId())) {
|
||||
Log.i(TAG, "Consistency: Deleting channel '"+ existingChannel.getId() + "' because the DB has no record of it.");
|
||||
notificationManager.deleteNotificationChannel(existingChannel.getId());
|
||||
} else if (existingChannel.getId().startsWith(MESSAGES_PREFIX) && !existingChannel.getId().equals(getMessagesChannel(context))) {
|
||||
Log.i(TAG, "Consistency: Deleting channel '"+ existingChannel.getId() + "' because it's out of date.");
|
||||
notificationManager.deleteNotificationChannel(existingChannel.getId());
|
||||
}
|
||||
}
|
||||
|
||||
for (Recipient customRecipient : customRecipients) {
|
||||
if (!existingChannelIds.contains(customRecipient.getNotificationChannel())) {
|
||||
Log.i(TAG, "Consistency: Removing custom channel '"+ customRecipient.getNotificationChannel() + "' because the system doesn't have it.");
|
||||
db.setNotificationChannel(customRecipient.getId(), null);
|
||||
}
|
||||
}
|
||||
|
@ -119,15 +119,28 @@ public final class LiveRecipient {
|
||||
*/
|
||||
@WorkerThread
|
||||
public @NonNull Recipient resolve() {
|
||||
Recipient recipient = get();
|
||||
Recipient current = get();
|
||||
|
||||
if (recipient.isResolving()) {
|
||||
recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||
liveData.postValue(recipient);
|
||||
Stream.of(recipient.getParticipants()).forEach(Recipient::resolve);
|
||||
if (!current.isResolving()) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return recipient;
|
||||
Recipient updated = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||
List<Recipient> participants = Stream.of(updated.getParticipants())
|
||||
.filter(Recipient::isResolving)
|
||||
.map(Recipient::getId)
|
||||
.map(this::fetchRecipientFromDisk)
|
||||
.toList();
|
||||
|
||||
Util.runOnMainSync(() -> {
|
||||
for (Recipient participant : participants) {
|
||||
participant.live().liveData.setValue(participant);
|
||||
}
|
||||
|
||||
liveData.setValue(updated);
|
||||
});
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,11 +148,20 @@ public final class LiveRecipient {
|
||||
*/
|
||||
@WorkerThread
|
||||
public void refresh() {
|
||||
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||
liveData.postValue(recipient);
|
||||
Stream.of(recipient.getParticipants()).map(Recipient::live).forEach(LiveRecipient::refresh);
|
||||
}
|
||||
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||
List<Recipient> participants = Stream.of(recipient.getParticipants())
|
||||
.map(Recipient::getId)
|
||||
.map(this::fetchRecipientFromDisk)
|
||||
.toList();
|
||||
|
||||
Util.runOnMainSync(() -> {
|
||||
for (Recipient participant : participants) {
|
||||
participant.live().liveData.setValue(participant);
|
||||
}
|
||||
|
||||
liveData.setValue(recipient);
|
||||
});
|
||||
}
|
||||
|
||||
private @NonNull Recipient fetchRecipientFromDisk(RecipientId id) {
|
||||
RecipientSettings settings = recipientDatabase.getRecipientSettings(id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user