mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-29 21:52:31 +02:00
Moving processing flags to Launched Effect.
This commit is contained in:
@@ -1087,6 +1087,13 @@ fun UserPicture(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class DropDownParams(
|
||||||
|
val isFollowingAuthor: Boolean,
|
||||||
|
val isPrivateBookmarkNote: Boolean,
|
||||||
|
val isPublicBookmarkNote: Boolean,
|
||||||
|
val isLoggedUser: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit, accountViewModel: AccountViewModel) {
|
fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit, accountViewModel: AccountViewModel) {
|
||||||
val clipboardManager = LocalClipboardManager.current
|
val clipboardManager = LocalClipboardManager.current
|
||||||
@@ -1094,11 +1101,26 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit,
|
|||||||
val actContext = LocalContext.current
|
val actContext = LocalContext.current
|
||||||
var reportDialogShowing by remember { mutableStateOf(false) }
|
var reportDialogShowing by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
var state by remember {
|
||||||
|
mutableStateOf<DropDownParams>(
|
||||||
|
DropDownParams(false, false, false, false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(key1 = note) {
|
||||||
|
state = DropDownParams(
|
||||||
|
accountViewModel.isFollowing(note.author),
|
||||||
|
accountViewModel.isInPrivateBookmarks(note),
|
||||||
|
accountViewModel.isInPublicBookmarks(note),
|
||||||
|
accountViewModel.isLoggedUser(note.author)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
DropdownMenu(
|
DropdownMenu(
|
||||||
expanded = popupExpanded,
|
expanded = popupExpanded,
|
||||||
onDismissRequest = onDismiss
|
onDismissRequest = onDismiss
|
||||||
) {
|
) {
|
||||||
if (!accountViewModel.isFollowing(note.author)) {
|
if (!state.isFollowingAuthor) {
|
||||||
DropdownMenuItem(onClick = {
|
DropdownMenuItem(onClick = {
|
||||||
accountViewModel.follow(
|
accountViewModel.follow(
|
||||||
note.author ?: return@DropdownMenuItem
|
note.author ?: return@DropdownMenuItem
|
||||||
@@ -1135,7 +1157,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit,
|
|||||||
Text(stringResource(R.string.quick_action_share))
|
Text(stringResource(R.string.quick_action_share))
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
if (accountViewModel.isInPrivateBookmarks(note)) {
|
if (state.isPrivateBookmarkNote) {
|
||||||
DropdownMenuItem(onClick = { accountViewModel.removePrivateBookmark(note); onDismiss() }) {
|
DropdownMenuItem(onClick = { accountViewModel.removePrivateBookmark(note); onDismiss() }) {
|
||||||
Text(stringResource(R.string.remove_from_private_bookmarks))
|
Text(stringResource(R.string.remove_from_private_bookmarks))
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1166,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit,
|
|||||||
Text(stringResource(R.string.add_to_private_bookmarks))
|
Text(stringResource(R.string.add_to_private_bookmarks))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (accountViewModel.isInPublicBookmarks(note)) {
|
if (state.isPublicBookmarkNote) {
|
||||||
DropdownMenuItem(onClick = { accountViewModel.removePublicBookmark(note); onDismiss() }) {
|
DropdownMenuItem(onClick = { accountViewModel.removePublicBookmark(note); onDismiss() }) {
|
||||||
Text(stringResource(R.string.remove_from_public_bookmarks))
|
Text(stringResource(R.string.remove_from_public_bookmarks))
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1180,7 @@ fun NoteDropDownMenu(note: Note, popupExpanded: Boolean, onDismiss: () -> Unit,
|
|||||||
Text(stringResource(R.string.broadcast))
|
Text(stringResource(R.string.broadcast))
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
if (accountViewModel.isLoggedUser(note.author)) {
|
if (state.isLoggedUser) {
|
||||||
DropdownMenuItem(onClick = { accountViewModel.delete(note); onDismiss() }) {
|
DropdownMenuItem(onClick = { accountViewModel.delete(note); onDismiss() }) {
|
||||||
Text(stringResource(R.string.request_deletion))
|
Text(stringResource(R.string.request_deletion))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user