refactor(@chat): mark messages as read
This commit is contained in:
parent
e5a414a927
commit
8ddda242d8
|
@ -42,14 +42,18 @@ method delete*(self: Controller) =
|
|||
discard
|
||||
|
||||
method init*(self: Controller) =
|
||||
self.events.on(SIGNAL_CHAT_MUTED) do(e:Args):
|
||||
let args = ChatArgs(e)
|
||||
self.events.on(chat_service.SIGNAL_CHAT_MUTED) do(e:Args):
|
||||
let args = chat_service.ChatArgs(e)
|
||||
self.delegate.onChatMuted(args.chatId)
|
||||
|
||||
self.events.on(SIGNAL_CHAT_UNMUTED) do(e:Args):
|
||||
let args = ChatArgs(e)
|
||||
self.events.on(chat_service.SIGNAL_CHAT_UNMUTED) do(e:Args):
|
||||
let args = chat_service.ChatArgs(e)
|
||||
self.delegate.onChatUnmuted(args.chatId)
|
||||
|
||||
self.events.on(message_service.SIGNAL_MESSAGES_MARKED_AS_READ) do(e: Args):
|
||||
let args = message_service.MessagesMarkedAsReadArgs(e)
|
||||
self.delegate.onMarkAllMessagesRead(args.chatId)
|
||||
|
||||
method getMySectionId*(self: Controller): string =
|
||||
return self.sectionId
|
||||
|
||||
|
@ -127,4 +131,7 @@ method muteChat*(self: Controller, chatId: string) =
|
|||
self.chatService.muteChat(chatId)
|
||||
|
||||
method unmuteChat*(self: Controller, chatId: string) =
|
||||
self.chatService.unmuteChat(chatId)
|
||||
self.chatService.unmuteChat(chatId)
|
||||
|
||||
method markAllMessagesRead*(self: Controller, chatId: string) =
|
||||
self.messageService.markAllMessagesRead(chatId)
|
|
@ -58,4 +58,7 @@ method muteChat*(self: AccessInterface, chatId: string) {.base.} =
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -192,3 +192,12 @@ QtObject:
|
|||
var found = false
|
||||
if self.items[i].subItems.muteUnmuteItemById(id, mute):
|
||||
return
|
||||
|
||||
proc setHasUnreadMessage*(self: Model, id: string, value: bool) =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].id == id):
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
self.items[i].BaseItem.hasUnreadMessages = value
|
||||
self.dataChanged(index, index, @[ModelRole.HasUnreadMessages.int])
|
||||
return
|
||||
|
|
@ -286,7 +286,13 @@ method unmuteChat*(self: Module, chatId: string) =
|
|||
self.controller.unmuteChat(chatId)
|
||||
|
||||
method onChatMuted*(self: Module, chatId: string) =
|
||||
self.view.model().muteUnmuteItemOrSubItemById(chatId, true)
|
||||
self.view.model().muteUnmuteItemOrSubItemById(chatId, mute=true)
|
||||
|
||||
method onChatUnmuted*(self: Module, chatId: string) =
|
||||
self.view.model().muteUnmuteItemOrSubItemById(chatId, false)
|
||||
self.view.model().muteUnmuteItemOrSubItemById(chatId, false)
|
||||
|
||||
method onMarkAllMessagesRead*(self: Module, chatId: string) =
|
||||
self.view.model().setHasUnreadMessage(chatId, value=false)
|
||||
|
||||
method markAllMessagesRead*(self: Module, chatId: string) =
|
||||
self.controller.markAllMessagesRead(chatId)
|
|
@ -10,4 +10,7 @@ method onChatMuted*(self: AccessInterface, chatId: string) {.base.} =
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onChatUnmuted*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onMarkAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -31,4 +31,7 @@ method muteChat*(self: AccessInterface, chatId: string) {.base.} =
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -103,4 +103,7 @@ QtObject:
|
|||
self.delegate.muteChat(chatId)
|
||||
|
||||
proc unmuteChat*(self: View, chatId: string) {.slot.} =
|
||||
self.delegate.unmuteChat(chatId)
|
||||
self.delegate.unmuteChat(chatId)
|
||||
|
||||
proc markAllMessagesRead*(self: View, chatId: string) {.slot.} =
|
||||
self.delegate.markAllMessagesRead(chatId)
|
|
@ -41,7 +41,7 @@ type
|
|||
chatId*: string
|
||||
messageId*: string
|
||||
|
||||
MessagesMarkedAsReadArgs = ref object of Args
|
||||
MessagesMarkedAsReadArgs* = ref object of Args
|
||||
chatId*: string
|
||||
allMessagesMarked*: bool
|
||||
messagesIds*: seq[string]
|
||||
|
|
|
@ -25,7 +25,7 @@ StatusPopupMenu {
|
|||
signal requestAllHistoricMessages(string id)
|
||||
signal unmuteChat(string id)
|
||||
signal muteChat(string id)
|
||||
signal markAsRead(string id)
|
||||
signal markAllMessagesRead(string id)
|
||||
signal clearChatHistory(string id)
|
||||
signal editChannel(string id)
|
||||
signal downloadMessages(string file)
|
||||
|
@ -112,7 +112,7 @@ StatusPopupMenu {
|
|||
icon.name: "checkmark-circle"
|
||||
enabled: root.chatType !== Constants.chatType.privateGroupChat
|
||||
onTriggered: {
|
||||
root.markAsRead(root.chatId)
|
||||
root.markAllMessagesRead(root.chatId)
|
||||
}
|
||||
|
||||
// Will be deleted later
|
||||
|
|
|
@ -284,6 +284,10 @@ Item {
|
|||
onUnmuteChat: {
|
||||
root.communitySectionModule.unmuteChat(id)
|
||||
}
|
||||
|
||||
onMarkAllMessagesRead: {
|
||||
root.communitySectionModule.markAllMessagesRead(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,6 +283,10 @@ Item {
|
|||
onUnmuteChat: {
|
||||
root.chatSectionModule.unmuteChat(id)
|
||||
}
|
||||
|
||||
onMarkAllMessagesRead: {
|
||||
root.chatSectionModule.markAllMessagesRead(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue