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> {
|
): State<Boolean> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
UserFinderFilterAssemblerSubscription(user1, accountViewModel)
|
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
|
// Subscribe in the LocalCache for changes that arrive in the device
|
||||||
val flow =
|
val flow =
|
||||||
@@ -429,13 +420,13 @@ fun observeUserIsFollowing(
|
|||||||
.follows.stateFlow
|
.follows.stateFlow
|
||||||
.sample(1000)
|
.sample(1000)
|
||||||
.mapLatest { userState ->
|
.mapLatest { userState ->
|
||||||
userState.user.isFollowing(user2) || isUserInFollowSets
|
userState.user.isFollowing(user2)
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
}
|
}
|
||||||
|
|
||||||
return flow.collectAsStateWithLifecycle(
|
return flow.collectAsStateWithLifecycle(
|
||||||
user1.isFollowing(user2) || isUserInFollowSets,
|
user1.isFollowing(user2),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ fun ShowFollowingOrUnfollowingButton(
|
|||||||
baseAuthor: User,
|
baseAuthor: User,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
var isFollowing = observeUserIsFollowing(accountViewModel.account.userProfile(), baseAuthor, accountViewModel)
|
val isFollowing = observeUserIsFollowing(accountViewModel.account.userProfile(), baseAuthor, accountViewModel)
|
||||||
|
|
||||||
if (isFollowing.value) {
|
if (isFollowing.value) {
|
||||||
UnfollowButton {
|
UnfollowButton {
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ fun FollowButton(
|
|||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
modifier = Modifier.padding(start = 3.dp),
|
modifier = Modifier.padding(horizontal = 3.dp),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
shape = if (isInProfileActions) LeftHalfCircleButtonBorder else ButtonBorder,
|
shape = if (isInProfileActions) LeftHalfCircleButtonBorder else ButtonBorder,
|
||||||
contentPadding = ButtonPadding,
|
contentPadding = ButtonPadding,
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ fun DisplayFollowUnfollowButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FollowButton(R.string.follow, true) {
|
FollowButton(R.string.follow, isInProfileActions = true) {
|
||||||
if (!accountViewModel.isWriteable()) {
|
if (!accountViewModel.isWriteable()) {
|
||||||
accountViewModel.toastManager.toast(
|
accountViewModel.toastManager.toast(
|
||||||
R.string.read_only_user,
|
R.string.read_only_user,
|
||||||
|
|||||||
Reference in New Issue
Block a user