mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Cancel typing jobs when you send a group message.
This commit is contained in:
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -150,6 +151,14 @@ class JobController {
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
synchronized void cancelAllInQueue(@NonNull String queue) {
|
||||
Stream.of(runningJobs.values())
|
||||
.filter(j -> Objects.equals(j.getParameters().getQueue(), queue))
|
||||
.map(Job::getId)
|
||||
.forEach(this::cancelJob);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
synchronized void onRetry(@NonNull Job job) {
|
||||
int nextRunAttempt = job.getRunAttempt() + 1;
|
||||
|
||||
@@ -198,6 +198,13 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
executor.execute(() -> jobController.cancelJob(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels all jobs in the specified queue. See {@link #cancel(String)} for details.
|
||||
*/
|
||||
public void cancelAllInQueue(@NonNull String queue) {
|
||||
executor.execute(() -> jobController.cancelAllInQueue(queue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the specified job synchronously. Beware: All normal dependencies are respected, meaning
|
||||
* you must take great care where you call this. It could take a very long time to complete!
|
||||
|
||||
Reference in New Issue
Block a user