mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 09:08:33 +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() {
|
public @NonNull Recipient getCurrent() {
|
||||||
RecipientId id = RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));
|
RecipientId id = RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));
|
||||||
return Recipient.live(id).get();
|
return Recipient.resolved(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Recipient getNext() {
|
public @Nullable Recipient getNext() {
|
||||||
|
@ -407,14 +407,17 @@ public class NotificationChannels {
|
|||||||
|
|
||||||
for (NotificationChannel existingChannel : notificationManager.getNotificationChannels()) {
|
for (NotificationChannel existingChannel : notificationManager.getNotificationChannels()) {
|
||||||
if (existingChannel.getId().startsWith(CONTACT_PREFIX) && !customChannelIds.contains(existingChannel.getId())) {
|
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());
|
notificationManager.deleteNotificationChannel(existingChannel.getId());
|
||||||
} else if (existingChannel.getId().startsWith(MESSAGES_PREFIX) && !existingChannel.getId().equals(getMessagesChannel(context))) {
|
} 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());
|
notificationManager.deleteNotificationChannel(existingChannel.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Recipient customRecipient : customRecipients) {
|
for (Recipient customRecipient : customRecipients) {
|
||||||
if (!existingChannelIds.contains(customRecipient.getNotificationChannel())) {
|
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);
|
db.setNotificationChannel(customRecipient.getId(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,15 +119,28 @@ public final class LiveRecipient {
|
|||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public @NonNull Recipient resolve() {
|
public @NonNull Recipient resolve() {
|
||||||
Recipient recipient = get();
|
Recipient current = get();
|
||||||
|
|
||||||
if (recipient.isResolving()) {
|
if (!current.isResolving()) {
|
||||||
recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
return current;
|
||||||
liveData.postValue(recipient);
|
|
||||||
Stream.of(recipient.getParticipants()).forEach(Recipient::resolve);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@WorkerThread
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
Recipient recipient = fetchRecipientFromDisk(defaultRecipient.getId());
|
||||||
liveData.postValue(recipient);
|
List<Recipient> participants = Stream.of(recipient.getParticipants())
|
||||||
Stream.of(recipient.getParticipants()).map(Recipient::live).forEach(LiveRecipient::refresh);
|
.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) {
|
private @NonNull Recipient fetchRecipientFromDisk(RecipientId id) {
|
||||||
RecipientSettings settings = recipientDatabase.getRecipientSettings(id);
|
RecipientSettings settings = recipientDatabase.getRecipientSettings(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user