Skip to content

Commit

Permalink
Put refresh and upload profile jobs in the same queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Jun 7, 2020
1 parent 2d8b2e7 commit 8fe8a1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Expand Up @@ -26,13 +26,15 @@ public final class ProfileUploadJob extends BaseJob {

public static final String KEY = "ProfileUploadJob";

public static final String QUEUE = "ProfileAlteration";

private final Context context;
private final SignalServiceAccountManager accountManager;

public ProfileUploadJob() {
this(new Job.Parameters.Builder()
.addConstraint(NetworkConstraint.KEY)
.setQueue(KEY)
.setQueue(QUEUE)
.setLifespan(Parameters.IMMORTAL)
.setMaxAttempts(Parameters.UNLIMITED)
.setMaxInstances(1)
Expand Down
Expand Up @@ -43,7 +43,7 @@ public class RefreshOwnProfileJob extends BaseJob {
public RefreshOwnProfileJob() {
this(new Parameters.Builder()
.addConstraint(NetworkConstraint.KEY)
.setQueue("RefreshOwnProfileJob")
.setQueue(ProfileUploadJob.QUEUE)
.setMaxInstances(1)
.setMaxAttempts(10)
.build());
Expand Down
Expand Up @@ -131,10 +131,18 @@ public final class FeatureFlags {
*/
private static final Map<String, OnFlagChange> FLAG_CHANGE_LISTENERS = new HashMap<String, OnFlagChange>() {{
put(MESSAGE_REQUESTS, (change) -> SignalStore.setMessageRequestEnableTime(change == Change.ENABLED ? System.currentTimeMillis() : 0));
put(VERSIONED_PROFILES, (change) -> ApplicationDependencies.getJobManager().add(new ProfileUploadJob()));
put(GROUPS_V2, (change) -> ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob())
.then(new RefreshOwnProfileJob())
.enqueue());
put(VERSIONED_PROFILES, (change) -> {
if (change == Change.ENABLED) {
ApplicationDependencies.getJobManager().add(new ProfileUploadJob());
}
});
put(GROUPS_V2, (change) -> {
if (change == Change.ENABLED) {
ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob())
.then(new RefreshOwnProfileJob())
.enqueue();
}
});
}};

private static final Map<String, Object> REMOTE_VALUES = new TreeMap<>();
Expand Down

0 comments on commit 8fe8a1e

Please sign in to comment.