diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.kt index da17e38d35..be96391bdb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.kt @@ -486,13 +486,15 @@ class RetrieveProfileJob private constructor(parameters: Parameters, private val * Submits the necessary job to refresh the profile of the requested recipient. Works for any * RecipientId, including individuals, groups, or yourself. * - * - * Identical to [.enqueue])} + * May not enqueue any jobs in certain circumstances. In particular, if the recipient is a group + * with no other members, then no job will be enqueued. */ @JvmStatic @WorkerThread fun enqueue(recipientId: RecipientId) { - ApplicationDependencies.getJobManager().add(forRecipient(recipientId)) + forRecipients(setOf(recipientId)).firstOrNull()?.let { job -> + ApplicationDependencies.getJobManager().add(job) + } } /** @@ -508,19 +510,10 @@ class RetrieveProfileJob private constructor(parameters: Parameters, private val } } - /** - * Works for any RecipientId, whether it's an individual, group, or yourself. - */ - @JvmStatic - @WorkerThread - fun forRecipient(recipientId: RecipientId): Job { - return forRecipients(setOf(recipientId)).first() - } - /** * Works for any RecipientId, whether it's an individual, group, or yourself. * - * @return A list of length 2 or less. Two iff you are in the recipients. + * @return A list of length 2 or less. Two iff you are in the recipients. Could be empty for groups with no other members. */ @JvmStatic @WorkerThread diff --git a/app/src/main/java/org/thoughtcrime/securesms/messages/DataMessageProcessor.kt b/app/src/main/java/org/thoughtcrime/securesms/messages/DataMessageProcessor.kt index 60ee507ff7..f1178b13f2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/messages/DataMessageProcessor.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/messages/DataMessageProcessor.kt @@ -223,7 +223,7 @@ object DataMessageProcessor { if (SignalDatabase.recipients.setProfileKey(senderRecipient.id, messageProfileKey)) { log(timestamp, "Profile key on message from " + senderRecipient.id + " didn't match our local store. It has been updated.") SignalDatabase.runPostSuccessfulTransaction { - ApplicationDependencies.getJobManager().add(RetrieveProfileJob.forRecipient(senderRecipient.id)) + RetrieveProfileJob.enqueue(senderRecipient.id) } } } else { diff --git a/app/src/main/java/org/thoughtcrime/securesms/profiles/manage/EditProfileViewModel.java b/app/src/main/java/org/thoughtcrime/securesms/profiles/manage/EditProfileViewModel.java index 0a78309a40..ba787a47ae 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/profiles/manage/EditProfileViewModel.java +++ b/app/src/main/java/org/thoughtcrime/securesms/profiles/manage/EditProfileViewModel.java @@ -69,7 +69,7 @@ class EditProfileViewModel extends ViewModel { SignalExecutors.BOUNDED.execute(() -> { onRecipientChanged(Recipient.self().fresh()); - ApplicationDependencies.getJobManager().add(RetrieveProfileJob.forRecipient(Recipient.self().getId())); + RetrieveProfileJob.enqueue(Recipient.self().getId()); }); Recipient.self().live().observeForever(observer);