ios: scroll buttons and unread counts (#937)

* ios: scroll buttons and unread counts

* floating buttons for unread counts

* remove commented code

* remove prints
This commit is contained in:
Evgeny Poberezkin
2022-08-16 13:13:29 +01:00
committed by GitHub
parent 0a2f7681d8
commit 76bde53206
5 changed files with 179 additions and 84 deletions

View File

@@ -540,13 +540,13 @@ func apiCallStatus(_ contact: Contact, _ status: String) async throws {
}
}
func markChatRead(_ chat: Chat) async {
func markChatRead(_ chat: Chat, aboveItem: ChatItem? = nil) async {
do {
let minItemId = chat.chatStats.minUnreadItemId
let itemRange = (minItemId, chat.chatItems.last?.id ?? minItemId)
let itemRange = (minItemId, aboveItem?.id ?? chat.chatItems.last?.id ?? minItemId)
let cInfo = chat.chatInfo
try await apiChatRead(type: cInfo.chatType, id: cInfo.apiId, itemRange: itemRange)
DispatchQueue.main.async { ChatModel.shared.markChatItemsRead(cInfo) }
DispatchQueue.main.async { ChatModel.shared.markChatItemsRead(cInfo, aboveItem: aboveItem) }
} catch {
logger.error("markChatRead apiChatRead error: \(responseError(error))")
}