diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt index a7bb6a9fa..90d899f83 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt @@ -73,9 +73,7 @@ fun NoteAuthorPicture( modifier: Modifier = Modifier, onClick: ((User) -> Unit)? = null ) { - val author by baseNote.live().metadata.map { - it.note.author - }.distinctUntilChanged().observeAsState(baseNote.author) + val author by baseNote.live().authorChanges.observeAsState(baseNote.author) Crossfade(targetState = author) { if (it == null) { @@ -112,23 +110,19 @@ fun UserPicture( accountViewModel: AccountViewModel, nav: (String) -> Unit ) { - val route by remember { + val route by remember(user) { derivedStateOf { "User/${user.pubkeyHex}" } } - val scope = rememberCoroutineScope() - ClickableUserPicture( baseUser = user, size = size, accountViewModel = accountViewModel, modifier = pictureModifier, onClick = { - scope.launch { - nav(route) - } + nav(route) } ) } @@ -274,9 +268,7 @@ fun InnerBaseUserPicture( accountViewModel: AccountViewModel, modifier: Modifier ) { - val userProfile by baseUser.live().metadata.map { - it.user.profilePicture() - }.distinctUntilChanged().observeAsState(baseUser.profilePicture()) + val userProfile by baseUser.live().profilePictureChanges.observeAsState(baseUser.profilePicture()) PictureAndFollowingMark( userHex = baseUser.pubkeyHex, @@ -508,9 +500,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi fun WatchBookmarksFollowsAndAccount(note: Note, accountViewModel: AccountViewModel, onNew: (DropDownParams) -> Unit) { val followState by accountViewModel.userProfile().live().follows.observeAsState() val bookmarkState by accountViewModel.userProfile().live().bookmarks.observeAsState() - val showSensitiveContent by accountViewModel.accountLiveData.map { - it.account.showSensitiveContent - }.distinctUntilChanged().observeAsState(accountViewModel.account.showSensitiveContent) + val showSensitiveContent by accountViewModel.showSensitiveContentChanges.observeAsState(accountViewModel.account.showSensitiveContent) LaunchedEffect(key1 = followState, key2 = bookmarkState, key3 = showSensitiveContent) { launch(Dispatchers.IO) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 2169f3725..76bb6ab2d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -57,22 +57,26 @@ class AccountViewModel(val account: Account) : ViewModel() { val userFollows: LiveData = account.userProfile().live().follows.map { it } val userRelays: LiveData = account.userProfile().live().relays.map { it } - val discoveryListLiveData = accountLiveData.map { + val discoveryListLiveData = account.live.map { it.account.defaultDiscoveryFollowList }.distinctUntilChanged() - val homeListLiveData = accountLiveData.map { + val homeListLiveData = account.live.map { it.account.defaultHomeFollowList }.distinctUntilChanged() - val notificationListLiveData = accountLiveData.map { + val notificationListLiveData = account.live.map { it.account.defaultNotificationFollowList }.distinctUntilChanged() - val storiesListLiveData = accountLiveData.map { + val storiesListLiveData = account.live.map { it.account.defaultStoriesFollowList }.distinctUntilChanged() + val showSensitiveContentChanges = account.live.map { + it.account.showSensitiveContent + }.distinctUntilChanged() + fun updateAutomaticallyStartPlayback( automaticallyStartPlayback: ConnectivityType ) {