Fix some issues with avatar syncing.
- We weren't falling back to system avatars when no profile was present - We weren't triggering a sync when the setting changed
This commit is contained in:
parent
d8256013a3
commit
70db617229
2 changed files with 16 additions and 7 deletions
|
@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.components.settings.app.chats
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.ConversationUtil
|
||||
|
@ -35,6 +37,7 @@ class ChatsSettingsViewModel(private val repository: ChatsSettingsRepository) :
|
|||
store.update { it.copy(useAddressBook = enabled) }
|
||||
SignalStore.settings().isPreferSystemContactPhotos = enabled
|
||||
refreshDebouncer.publish { ConversationUtil.refreshRecipientShortcuts() }
|
||||
ApplicationDependencies.getJobManager().add(MultiDeviceContactUpdateJob(true))
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
|
||||
|
|
|
@ -275,17 +275,23 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
|
|||
}
|
||||
|
||||
private Optional<SignalServiceAttachmentStream> getAvatar(@NonNull RecipientId recipientId, @Nullable Uri uri) {
|
||||
Optional<SignalServiceAttachmentStream> avatarStream = Optional.absent();
|
||||
Optional<SignalServiceAttachmentStream> stream;
|
||||
|
||||
if (SignalStore.settings().isPreferSystemContactPhotos()) {
|
||||
avatarStream = getSystemAvatar(uri);
|
||||
stream = getSystemAvatar(uri);
|
||||
|
||||
if (!stream.isPresent()) {
|
||||
stream = getProfileAvatar(recipientId);
|
||||
}
|
||||
} else {
|
||||
stream = getProfileAvatar(recipientId);
|
||||
|
||||
if (!stream.isPresent()) {
|
||||
stream = getSystemAvatar(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (avatarStream.isPresent()) {
|
||||
return avatarStream;
|
||||
} else {
|
||||
return getProfileAvatar(recipientId);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
private Optional<SignalServiceAttachmentStream> getProfileAvatar(@NonNull RecipientId recipientId) {
|
||||
|
|
Loading…
Add table
Reference in a new issue