mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
Fix crash & friend request handling bug
This commit is contained in:
parent
3124a59269
commit
4e5607f7be
@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -47,9 +48,9 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context);
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context));
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context));
|
||||
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,9 +64,9 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, threadId);
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId));
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, threadId));
|
||||
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,9 +80,9 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, threadId, signal);
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId, signal));
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, threadId, signal));
|
||||
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId, signal)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,12 +96,20 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
}
|
||||
|
||||
if (isCaughtUp) {
|
||||
wrapped.updateNotification(context, signal, reminderCount);
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, signal, reminderCount));
|
||||
} else {
|
||||
debouncer.publish(() -> wrapped.updateNotification(context, signal, reminderCount));
|
||||
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, signal, reminderCount)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearReminder(@NonNull Context context) { wrapped.clearReminder(context); }
|
||||
|
||||
private void performOnBackgroundThreadIfNeeded(Runnable r) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
new Thread(r).start();
|
||||
} else {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user