From f1711719f47c7ba57221a70fc6fe0ad1a0372784 Mon Sep 17 00:00:00 2001 From: Rashed <38612386+rashedswen@users.noreply.github.com> Date: Fri, 3 Mar 2023 09:53:56 +0300 Subject: [PATCH 1/2] add follow directly from a note feature --- .../com/vitorpamplona/amethyst/ui/note/NoteCompose.kt | 11 +++++++++++ .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index c56c242f0..a596c06c3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -629,6 +629,17 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit, expanded = popupExpanded, onDismissRequest = onDismiss ) { + if (note.author != accountViewModel.accountLiveData.value?.account?.userProfile()) { + + DropdownMenuItem(onClick = { + accountViewModel.follow( + note.author ?: return@DropdownMenuItem + ); onDismiss() + }) { + Text(stringResource(R.string.follow)) + } + Divider() + } DropdownMenuItem(onClick = { clipboardManager.setText(AnnotatedString(accountViewModel.decrypt(note) ?: "")); onDismiss() }) { Text(stringResource(R.string.copy_text)) } 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 66e702358..2c7391156 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 @@ -113,7 +113,9 @@ class AccountViewModel(private val account: Account): ViewModel() { account.prefer(source, target, preference) } - + fun follow(user: User) { + account.follow(user) + } } \ No newline at end of file From 8e858996fe07ca5eac66c1d63108fa0ebae47dd3 Mon Sep 17 00:00:00 2001 From: Rashed <38612386+rashedswen@users.noreply.github.com> Date: Fri, 3 Mar 2023 10:13:15 +0300 Subject: [PATCH 2/2] hide follow button when the user already followed --- .../java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index a596c06c3..c6fd6212d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -629,7 +629,8 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit, expanded = popupExpanded, onDismissRequest = onDismiss ) { - if (note.author != accountViewModel.accountLiveData.value?.account?.userProfile()) { + if (note.author != accountViewModel.accountLiveData.value?.account?.userProfile() && !accountViewModel.accountLiveData.value?.account?.userProfile() + !!.isFollowing(note.author!!)) { DropdownMenuItem(onClick = { accountViewModel.follow(