Merge pull request #318 from believethehype/main

Show "follow back" on a user's profile when this user already is a follower
This commit is contained in:
Vitor Pamplona
2023-03-26 17:24:44 -04:00
committed by GitHub
5 changed files with 11 additions and 6 deletions

View File

@@ -75,7 +75,7 @@ fun UserCompose(baseUser: User, accountViewModel: AccountViewModel, navControlle
} else if (userFollows.isFollowingCached(baseUser)) { } else if (userFollows.isFollowingCached(baseUser)) {
UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseUser) } } UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseUser) } }
} else { } else {
FollowButton { coroutineScope.launch(Dispatchers.IO) { account.follow(baseUser) } } FollowButton({ coroutineScope.launch(Dispatchers.IO) { account.follow(baseUser) } })
} }
} }
} }

View File

@@ -120,7 +120,7 @@ fun ZapNoteCompose(baseNote: Pair<Note, Note>, accountViewModel: AccountViewMode
} else if (userFollows.isFollowingCached(baseAuthor)) { } else if (userFollows.isFollowingCached(baseAuthor)) {
UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseAuthor) } } UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseAuthor) } }
} else { } else {
FollowButton { coroutineScope.launch(Dispatchers.IO) { account.follow(baseAuthor) } } FollowButton({ coroutineScope.launch(Dispatchers.IO) { account.follow(baseAuthor) } })
} }
} }
} }

View File

@@ -111,7 +111,7 @@ fun HashtagHeader(tag: String, account: Account) {
if (userFollows.isFollowingHashtagCached(tag)) { if (userFollows.isFollowingHashtagCached(tag)) {
UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(tag) } } UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(tag) } }
} else { } else {
FollowButton { coroutineScope.launch(Dispatchers.IO) { account.follow(tag) } } FollowButton({ coroutineScope.launch(Dispatchers.IO) { account.follow(tag) } })
} }
} }
} }

View File

@@ -389,7 +389,11 @@ private fun ProfileHeader(
} else if (accountUser.isFollowingCached(baseUser)) { } else if (accountUser.isFollowingCached(baseUser)) {
UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseUser) } } UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(baseUser) } }
} else { } else {
FollowButton { coroutineScope.launch(Dispatchers.IO) { account.follow(baseUser) } } if (baseUser.isFollowingCached(accountUser)) {
FollowButton({ coroutineScope.launch(Dispatchers.IO) { account.follow(baseUser) } }, R.string.follow_back)
} else {
FollowButton({ coroutineScope.launch(Dispatchers.IO) { account.follow(baseUser) } }, R.string.follow)
}
} }
} }
} }
@@ -949,7 +953,7 @@ fun UnfollowButton(onClick: () -> Unit) {
} }
@Composable @Composable
fun FollowButton(onClick: () -> Unit) { fun FollowButton(onClick: () -> Unit, text: Int = R.string.follow) {
Button( Button(
modifier = Modifier.padding(start = 3.dp), modifier = Modifier.padding(start = 3.dp),
onClick = onClick, onClick = onClick,
@@ -960,7 +964,7 @@ fun FollowButton(onClick: () -> Unit) {
), ),
contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp) contentPadding = PaddingValues(vertical = 6.dp, horizontal = 16.dp)
) { ) {
Text(text = stringResource(R.string.follow), color = Color.White, textAlign = TextAlign.Center) Text(text = stringResource(text), color = Color.White, textAlign = TextAlign.Center)
} }
} }

View File

@@ -122,6 +122,7 @@
<string name="send_a_direct_message">Send a Direct Message</string> <string name="send_a_direct_message">Send a Direct Message</string>
<string name="edits_the_user_s_metadata">Edits the User\'s Metadata</string> <string name="edits_the_user_s_metadata">Edits the User\'s Metadata</string>
<string name="follow">Follow</string> <string name="follow">Follow</string>
<string name="follow_back">Follow back</string>
<string name="unblock">Unblock</string> <string name="unblock">Unblock</string>
<string name="copy_user_id">Copy User ID</string> <string name="copy_user_id">Copy User ID</string>
<string name="unblock_user">Unblock User</string> <string name="unblock_user">Unblock User</string>