Set tapbacks to read as scrolling by in messages

This commit is contained in:
Garth Vander Houwen 2024-01-21 17:42:23 -08:00
parent aa2f3c4511
commit 10359784f7
2 changed files with 29 additions and 0 deletions

View file

@ -190,6 +190,20 @@ struct ChannelMessageList: View {
.fixedSize()
.padding(.bottom, 1)
}
.onAppear {
if !tapback.read {
tapback.read = true
do {
try context.save()
print("📖 Read message \(message.messageId) ")
appState.unreadChannelMessages = myInfo.unreadMessages
UIApplication.shared.applicationIconBadgeNumber = appState.unreadChannelMessages + appState.unreadDirectMessages
context.refresh(myInfo, mergeChanges: true)
} catch {
print("Failed to read tapback \(tapback.messageId)")
}
}
}
}
}
.padding(10)
@ -199,6 +213,7 @@ struct ChannelMessageList: View {
)
}
}
HStack {
if currentUser && message.receivedACK {
// Ack Received

View file

@ -167,6 +167,20 @@ struct UserMessageList: View {
.fixedSize()
.padding(.bottom, 1)
}
.onAppear {
if !tapback.read {
tapback.read = true
do {
try context.save()
print("📖 Read tapback \(tapback.messageId) ")
appState.unreadDirectMessages = user.unreadMessages
UIApplication.shared.applicationIconBadgeNumber = appState.unreadChannelMessages + appState.unreadDirectMessages
} catch {
print("Failed to read tapback \(tapback.messageId)")
}
}
}
}
}
.padding(10)