mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +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;
|
package org.thoughtcrime.securesms.notifications;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import androidx.annotation.MainThread;
|
import androidx.annotation.MainThread;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -47,9 +48,9 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isCaughtUp) {
|
if (isCaughtUp) {
|
||||||
wrapped.updateNotification(context);
|
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context));
|
||||||
} else {
|
} else {
|
||||||
debouncer.publish(() -> wrapped.updateNotification(context));
|
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +64,9 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isCaughtUp) {
|
if (isCaughtUp) {
|
||||||
wrapped.updateNotification(context, threadId);
|
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId));
|
||||||
} else {
|
} 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) {
|
if (isCaughtUp) {
|
||||||
wrapped.updateNotification(context, threadId, signal);
|
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId, signal));
|
||||||
} else {
|
} 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) {
|
if (isCaughtUp) {
|
||||||
wrapped.updateNotification(context, signal, reminderCount);
|
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, signal, reminderCount));
|
||||||
} else {
|
} else {
|
||||||
debouncer.publish(() -> wrapped.updateNotification(context, signal, reminderCount));
|
debouncer.publish(() -> performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, signal, reminderCount)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearReminder(@NonNull Context context) { wrapped.clearReminder(context); }
|
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