add support for amber in the follow dropdown menu

This commit is contained in:
greenart7c3 2023-08-28 14:31:20 -03:00
parent a450dcbac1
commit c223c1372b
4 changed files with 17 additions and 10 deletions

View File

@ -325,8 +325,10 @@ private fun RenderMainPopup(
stringResource(R.string.quick_action_follow)
) {
scope.launch(Dispatchers.IO) {
accountViewModel.follow(note.author!!)
onDismiss()
event = accountViewModel.follow(note.author!!, !accountViewModel.loggedInWithAmber())
if (!accountViewModel.loggedInWithAmber()) {
onDismiss()
}
}
}
}

View File

@ -416,11 +416,15 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState<Boolean>, accountVi
}
if (!state.isFollowingAuthor) {
DropdownMenuItem(onClick = {
accountViewModel.follow(
note.author ?: return@DropdownMenuItem
); onDismiss()
}) {
DropdownMenuItem(
onClick = {
val author = note.author ?: return@DropdownMenuItem
event = accountViewModel.follow(author, !accountViewModel.loggedInWithAmber())
if (!accountViewModel.loggedInWithAmber()) {
onDismiss()
}
}
) {
Text(stringResource(R.string.follow))
}
Divider()

View File

@ -269,7 +269,7 @@ fun ShowFollowingOrUnfollowingButton(
}
} else {
scope.launch(Dispatchers.IO) {
accountViewModel.follow(baseAuthor)
accountViewModel.follow(baseAuthor, true)
}
}
}

View File

@ -30,6 +30,7 @@ import com.vitorpamplona.amethyst.ui.note.ZapraiserStatus
import com.vitorpamplona.amethyst.ui.note.showAmount
import com.vitorpamplona.quartz.encoders.HexKey
import com.vitorpamplona.quartz.events.BookmarkListEvent
import com.vitorpamplona.quartz.events.ContactListEvent
import com.vitorpamplona.quartz.events.DeletionEvent
import com.vitorpamplona.quartz.events.Event
import com.vitorpamplona.quartz.events.GiftWrapEvent
@ -375,8 +376,8 @@ class AccountViewModel(val account: Account) : ViewModel() {
account.prefer(source, target, preference)
}
fun follow(user: User) {
account.follow(user)
fun follow(user: User, signEvent: Boolean): ContactListEvent? {
return account.follow(user, signEvent)
}
fun unfollow(user: User) {