Fixes the unfollow button on profile (removes the follow signal including all lists for now)
Also fixes spacing of the Follow button
This commit is contained in:
+2
-11
@@ -411,15 +411,6 @@ fun observeUserIsFollowing(
|
||||
): State<Boolean> {
|
||||
// Subscribe in the relay for changes in the metadata of this user.
|
||||
UserFinderFilterAssemblerSubscription(user1, accountViewModel)
|
||||
val isUserInFollowSets =
|
||||
remember(accountViewModel.account.peopleListsState) {
|
||||
// Only check follow sets if user1 is the logged-in user
|
||||
if (user1 == accountViewModel.account.userProfile()) {
|
||||
accountViewModel.account.peopleListsState.isUserInFollowSets(user2)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// Subscribe in the LocalCache for changes that arrive in the device
|
||||
val flow =
|
||||
@@ -429,13 +420,13 @@ fun observeUserIsFollowing(
|
||||
.follows.stateFlow
|
||||
.sample(1000)
|
||||
.mapLatest { userState ->
|
||||
userState.user.isFollowing(user2) || isUserInFollowSets
|
||||
userState.user.isFollowing(user2)
|
||||
}.distinctUntilChanged()
|
||||
.flowOn(Dispatchers.IO)
|
||||
}
|
||||
|
||||
return flow.collectAsStateWithLifecycle(
|
||||
user1.isFollowing(user2) || isUserInFollowSets,
|
||||
user1.isFollowing(user2),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ fun ShowFollowingOrUnfollowingButton(
|
||||
baseAuthor: User,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
var isFollowing = observeUserIsFollowing(accountViewModel.account.userProfile(), baseAuthor, accountViewModel)
|
||||
val isFollowing = observeUserIsFollowing(accountViewModel.account.userProfile(), baseAuthor, accountViewModel)
|
||||
|
||||
if (isFollowing.value) {
|
||||
UnfollowButton {
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ fun FollowButton(
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
FilledTonalButton(
|
||||
modifier = Modifier.padding(start = 3.dp),
|
||||
modifier = Modifier.padding(horizontal = 3.dp),
|
||||
onClick = onClick,
|
||||
shape = if (isInProfileActions) LeftHalfCircleButtonBorder else ButtonBorder,
|
||||
contentPadding = ButtonPadding,
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ fun DisplayFollowUnfollowButton(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FollowButton(R.string.follow, true) {
|
||||
FollowButton(R.string.follow, isInProfileActions = true) {
|
||||
if (!accountViewModel.isWriteable()) {
|
||||
accountViewModel.toastManager.toast(
|
||||
R.string.read_only_user,
|
||||
|
||||
Reference in New Issue
Block a user