mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Improve detection of websocket drained status.
Will now work when you lose and regain network. Also removes the unnecessary InitialMessageRetriever.
This commit is contained in:
@@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.jobmanager.Constraint;
|
||||
|
||||
/**
|
||||
* A constraint that is met once we have pulled down all messages from the websocket during initial
|
||||
* load. See {@link org.thoughtcrime.securesms.messages.InitialMessageRetriever}.
|
||||
* load. See {@link org.thoughtcrime.securesms.messages.IncomingMessageObserver}.
|
||||
*/
|
||||
public final class WebsocketDrainedConstraint implements Constraint {
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class WebsocketDrainedConstraint implements Constraint {
|
||||
|
||||
@Override
|
||||
public boolean isMet() {
|
||||
return ApplicationDependencies.getInitialMessageRetriever().isCaughtUp();
|
||||
return ApplicationDependencies.getIncomingMessageObserver().isWebsocketDrained();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.ConstraintObserver;
|
||||
|
||||
/**
|
||||
* An observer for {@link WebsocketDrainedConstraint}. Will fire when the
|
||||
* {@link org.thoughtcrime.securesms.messages.InitialMessageRetriever} is caught up.
|
||||
* An observer for {@link WebsocketDrainedConstraint}. Will fire when the websocket is drained
|
||||
* (i.e. it has received an empty response).
|
||||
*/
|
||||
public class WebsocketDrainedConstraintObserver implements ConstraintObserver {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class WebsocketDrainedConstraintObserver implements ConstraintObserver {
|
||||
private volatile Notifier notifier;
|
||||
|
||||
public WebsocketDrainedConstraintObserver() {
|
||||
ApplicationDependencies.getInitialMessageRetriever().addListener(() -> {
|
||||
ApplicationDependencies.getIncomingMessageObserver().addWebsocketDrainedListener(() -> {
|
||||
if (notifier != null) {
|
||||
notifier.onConstraintMet(REASON);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user