parent
e52f6daec9
commit
b33a7b8fcf
|
@ -169,6 +169,18 @@ QtObject:
|
||||||
|
|
||||||
self.status.chat.sendMessage(channelId, m, replyTo, contentType)
|
self.status.chat.sendMessage(channelId, m, replyTo, contentType)
|
||||||
|
|
||||||
|
proc getChannel*(self: ChatsView, index: int): Chat =
|
||||||
|
if (self.communities.activeCommunity.active):
|
||||||
|
return self.communities.activeCommunity.chats.getChannel(index)
|
||||||
|
else:
|
||||||
|
return self.chats.getChannel(index)
|
||||||
|
|
||||||
|
proc getChannelById*(self: ChatsView, channel: string): Chat =
|
||||||
|
if (self.communities.activeCommunity.active):
|
||||||
|
return self.communities.activeCommunity.chats.getChannel(self.communities.activeCommunity.chats.chats.findIndexById(channel))
|
||||||
|
else:
|
||||||
|
return self.chats.getChannel(self.chats.chats.findIndexById(channel))
|
||||||
|
|
||||||
proc verifyMessageSent*(self: ChatsView, data: string) {.slot.} =
|
proc verifyMessageSent*(self: ChatsView, data: string) {.slot.} =
|
||||||
let messageData = data.parseJson
|
let messageData = data.parseJson
|
||||||
self.messageList[messageData["chatId"].getStr].checkTimeout(messageData["id"].getStr)
|
self.messageList[messageData["chatId"].getStr].checkTimeout(messageData["id"].getStr)
|
||||||
|
@ -215,7 +227,7 @@ QtObject:
|
||||||
|
|
||||||
proc markAllChannelMessagesReadByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc markAllChannelMessagesReadByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
discard self.status.chat.markAllChannelMessagesRead(selectedChannel.id)
|
discard self.status.chat.markAllChannelMessagesRead(selectedChannel.id)
|
||||||
|
|
||||||
|
@ -228,11 +240,7 @@ QtObject:
|
||||||
proc setActiveChannelByIndexWithForce*(self: ChatsView, index: int, forceUpdate: bool) {.slot.} =
|
proc setActiveChannelByIndexWithForce*(self: ChatsView, index: int, forceUpdate: bool) {.slot.} =
|
||||||
if((self.communities.activeCommunity.active and self.communities.activeCommunity.chats.chats.len == 0) or (not self.communities.activeCommunity.active and self.chats.chats.len == 0)): return
|
if((self.communities.activeCommunity.active and self.communities.activeCommunity.chats.chats.len == 0) or (not self.communities.activeCommunity.active and self.chats.chats.len == 0)): return
|
||||||
|
|
||||||
var selectedChannel =
|
var selectedChannel = self.getChannel(index)
|
||||||
if (self.communities.activeCommunity.active):
|
|
||||||
self.communities.activeCommunity.chats.getChannel(index)
|
|
||||||
else:
|
|
||||||
self.chats.getChannel(index)
|
|
||||||
|
|
||||||
self.clearUnreadIfNeeded(self.activeChannel.chatItem)
|
self.clearUnreadIfNeeded(self.activeChannel.chatItem)
|
||||||
self.clearUnreadIfNeeded(selectedChannel)
|
self.clearUnreadIfNeeded(selectedChannel)
|
||||||
|
@ -266,12 +274,7 @@ QtObject:
|
||||||
|
|
||||||
proc setActiveChannel*(self: ChatsView, channel: string) {.slot.} =
|
proc setActiveChannel*(self: ChatsView, channel: string) {.slot.} =
|
||||||
if(channel == ""): return
|
if(channel == ""): return
|
||||||
|
let selectedChannel = self.getChannelById(channel)
|
||||||
let selectedChannel =
|
|
||||||
if (self.communities.activeCommunity.active):
|
|
||||||
self.communities.activeCommunity.chats.getChannel(self.communities.activeCommunity.chats.chats.findIndexById(channel))
|
|
||||||
else:
|
|
||||||
self.chats.getChannel(self.chats.chats.findIndexById(channel))
|
|
||||||
|
|
||||||
self.activeChannel.setChatItem(selectedChannel)
|
self.activeChannel.setChatItem(selectedChannel)
|
||||||
|
|
||||||
|
@ -288,7 +291,7 @@ QtObject:
|
||||||
notify = activeChannelChanged
|
notify = activeChannelChanged
|
||||||
|
|
||||||
proc setContextChannel*(self: ChatsView, channel: string) {.slot.} =
|
proc setContextChannel*(self: ChatsView, channel: string) {.slot.} =
|
||||||
let contextChannel = self.chats.getChannel(self.chats.chats.findIndexById(channel))
|
let contextChannel = self.getChannelById(channel)
|
||||||
self.contextChannel.setChatItem(contextChannel)
|
self.contextChannel.setChatItem(contextChannel)
|
||||||
self.contextChannelChanged()
|
self.contextChannelChanged()
|
||||||
|
|
||||||
|
@ -460,7 +463,7 @@ QtObject:
|
||||||
|
|
||||||
proc loadMoreMessagesWithIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc loadMoreMessagesWithIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
trace "Loading more messages", chaId = selectedChannel.id
|
trace "Loading more messages", chaId = selectedChannel.id
|
||||||
self.status.chat.chatMessages(selectedChannel.id, false)
|
self.status.chat.chatMessages(selectedChannel.id, false)
|
||||||
|
@ -540,7 +543,7 @@ QtObject:
|
||||||
|
|
||||||
proc leaveChatByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc leaveChatByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
self.status.chat.leave(selectedChannel.id)
|
self.status.chat.leave(selectedChannel.id)
|
||||||
self.status.mailservers.deleteMailserverTopic(selectedChannel.id)
|
self.status.mailservers.deleteMailserverTopic(selectedChannel.id)
|
||||||
|
@ -571,7 +574,7 @@ QtObject:
|
||||||
|
|
||||||
proc clearChatHistoryByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc clearChatHistoryByIndex*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
self.status.chat.clearHistory(selectedChannel.id)
|
self.status.chat.clearHistory(selectedChannel.id)
|
||||||
|
|
||||||
|
@ -654,7 +657,7 @@ QtObject:
|
||||||
|
|
||||||
proc muteChannel*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc muteChannel*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
if (selectedChannel.id == self.activeChannel.id):
|
if (selectedChannel.id == self.activeChannel.id):
|
||||||
self.muteCurrentChannel()
|
self.muteCurrentChannel()
|
||||||
|
@ -665,7 +668,7 @@ QtObject:
|
||||||
|
|
||||||
proc unmuteChannel*(self: ChatsView, channelIndex: int) {.slot.} =
|
proc unmuteChannel*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return
|
if (self.chats.chats.len == 0): return
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return
|
if (selectedChannel == nil): return
|
||||||
if (selectedChannel.id == self.activeChannel.id):
|
if (selectedChannel.id == self.activeChannel.id):
|
||||||
self.unmuteCurrentChannel()
|
self.unmuteCurrentChannel()
|
||||||
|
@ -677,7 +680,7 @@ QtObject:
|
||||||
|
|
||||||
proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} =
|
proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} =
|
||||||
if (self.chats.chats.len == 0): return false
|
if (self.chats.chats.len == 0): return false
|
||||||
let selectedChannel = self.chats.getChannel(channelIndex)
|
let selectedChannel = self.getChannel(channelIndex)
|
||||||
if (selectedChannel == nil): return false
|
if (selectedChannel == nil): return false
|
||||||
result = selectedChannel.muted
|
result = selectedChannel.muted
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue