feat(core): auto close friend feed menu

Automatically closes the Friend Feed Menu after pressing a setting button of SnapEnhance

Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
rhunk 2024-06-21 21:23:30 +02:00
parent 5d2277db7c
commit 4beb63e7aa
3 changed files with 14 additions and 4 deletions

View File

@ -555,6 +555,10 @@
"name": "Friend Feed Menu Buttons", "name": "Friend Feed Menu Buttons",
"description": "Select which buttons to show in the Friend Feed Menu" "description": "Select which buttons to show in the Friend Feed Menu"
}, },
"auto_close_friend_feed_menu": {
"name": "Auto Close Friend Feed Menu",
"description": "Automatically closes the Friend Feed Menu after pressing a setting button"
},
"vertical_story_viewer": { "vertical_story_viewer": {
"name": "Vertical Story Viewer", "name": "Vertical Story Viewer",
"description": "Enables the vertical story viewer for all stories" "description": "Enables the vertical story viewer for all stories"

View File

@ -57,6 +57,7 @@ class UserInterfaceTweaks : ConfigContainer() {
).apply { ).apply {
set(mutableListOf("conversation_info", MessagingRuleType.STEALTH.key)) set(mutableListOf("conversation_info", MessagingRuleType.STEALTH.key))
} }
val autoCloseFriendFeedMenu = boolean("auto_close_friend_feed_menu")
val customizeUi = container("customize_ui", CustomizeUIConfig()) { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val customizeUi = container("customize_ui", CustomizeUIConfig()) { addNotices(FeatureNotice.UNSTABLE); requireRestart() }
val friendFeedMessagePreview = container("friend_feed_message_preview", FriendFeedMessagePreview()) { requireRestart() } val friendFeedMessagePreview = container("friend_feed_message_preview", FriendFeedMessagePreview()) { requireRestart() }
val snapPreview = boolean("snap_preview") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val snapPreview = boolean("snap_preview") { addNotices(FeatureNotice.UNSTABLE); requireRestart() }

View File

@ -384,6 +384,11 @@ class FriendFeedInfoMenu : AbstractMenu() {
val translation = context.translation.getCategory("friend_menu_option") val translation = context.translation.getCategory("friend_menu_option")
fun closeMenu() {
if (!context.config.userInterface.autoCloseFriendFeedMenu.get()) return
context.mainActivity?.triggerRootCloseTouchEvent()
}
@Composable @Composable
fun ComposeFriendFeedMenu() { fun ComposeFriendFeedMenu() {
Column( Column(
@ -418,7 +423,7 @@ class FriendFeedInfoMenu : AbstractMenu() {
context.translation.format("rules.toasts.${if (state) "enabled" else "disabled"}", "ruleName" to context.translation[ruleFeature.ruleType.translateOptionKey(ruleState.key)]), context.translation.format("rules.toasts.${if (state) "enabled" else "disabled"}", "ruleName" to context.translation[ruleFeature.ruleType.translateOptionKey(ruleState.key)]),
durationMs = 1500 durationMs = 1500
) )
context.mainActivity?.triggerRootCloseTouchEvent() closeMenu()
} }
MenuElement( MenuElement(
@ -446,7 +451,7 @@ class FriendFeedInfoMenu : AbstractMenu() {
translation["mark_snaps_as_seen"], translation["mark_snaps_as_seen"],
onClick = { onClick = {
context.apply { context.apply {
mainActivity?.triggerRootCloseTouchEvent() closeMenu()
feature(AutoMarkAsRead::class).markSnapsAsSeen(conversationId) feature(AutoMarkAsRead::class).markSnapsAsSeen(conversationId)
} }
} }
@ -462,7 +467,7 @@ class FriendFeedInfoMenu : AbstractMenu() {
translation["mark_stories_as_seen_locally"], translation["mark_stories_as_seen_locally"],
onClick = { onClick = {
context.apply { context.apply {
mainActivity?.triggerRootCloseTouchEvent() closeMenu()
inAppOverlay.showStatusToast( inAppOverlay.showStatusToast(
Icons.Default.Info, Icons.Default.Info,
if (database.setStoriesViewedState(targetUser!!, true)) markAsSeenTranslation["seen_toast"] if (database.setStoriesViewedState(targetUser!!, true)) markAsSeenTranslation["seen_toast"]
@ -474,7 +479,7 @@ class FriendFeedInfoMenu : AbstractMenu() {
onLongClick = { onLongClick = {
view.post { view.post {
context.apply { context.apply {
mainActivity?.triggerRootCloseTouchEvent() closeMenu()
inAppOverlay.showStatusToast( inAppOverlay.showStatusToast(
Icons.Default.Info, Icons.Default.Info,
if (database.setStoriesViewedState(targetUser!!, false)) markAsSeenTranslation["unseen_toast"] if (database.setStoriesViewedState(targetUser!!, false)) markAsSeenTranslation["unseen_toast"]