feat: mark stories as seen locally

This commit is contained in:
rhunk
2023-12-03 14:56:24 +01:00
parent 0984644adc
commit a7275c2a0b
4 changed files with 31 additions and 10 deletions

View File

@ -351,4 +351,13 @@ class DatabaseAccess(
}
}
}
fun markFriendStoriesAsSeen(userId: String) {
openLocalDatabase("main", writeMode = true)?.apply {
performOperation {
execSQL("UPDATE StorySnap SET viewed = 1 WHERE userId = ?", arrayOf(userId))
}
close()
}
}
}

View File

@ -278,9 +278,10 @@ class FriendFeedInfoMenu : AbstractMenu() {
val (conversationId, targetUser) = getCurrentConversationInfo()
val translation = context.translation.getCategory("friend_menu_option")
if (friendFeedMenuOptions.contains("conversation_info")) {
viewConsumer(Button(view.context).apply {
text = modContext.translation["friend_menu_option.preview"]
text = translation["preview"]
applyTheme(view.width, hasRadius = true)
setOnClickListener {
showPreview(
@ -302,9 +303,9 @@ class FriendFeedInfoMenu : AbstractMenu() {
)
}
if (friendFeedMenuOptions.contains("mark_as_seen")) {
if (friendFeedMenuOptions.contains("mark_snaps_as_seen")) {
viewConsumer(Button(view.context).apply {
text = modContext.translation["friend_menu_option.mark_as_seen"]
text = translation["mark_snaps_as_seen"]
applyTheme(view.width, hasRadius = true)
setOnClickListener {
this@FriendFeedInfoMenu.context.mainActivity?.triggerRootCloseTouchEvent()
@ -312,5 +313,18 @@ class FriendFeedInfoMenu : AbstractMenu() {
}
})
}
if (targetUser != null && friendFeedMenuOptions.contains("mark_stories_as_seen")) {
viewConsumer(Button(view.context).apply {
text = translation["mark_stories_as_seen"]
applyTheme(view.width, hasRadius = true)
setOnClickListener {
this@FriendFeedInfoMenu.context.apply {
mainActivity?.triggerRootCloseTouchEvent()
database.markFriendStoriesAsSeen(targetUser)
}
}
})
}
}
}