chore(chat/service): small cleanup

This commit is contained in:
Jonathan Rainville 2023-05-19 15:20:44 -04:00
parent 1e8ab03f18
commit 243728b769
1 changed files with 4 additions and 12 deletions

View File

@ -165,13 +165,6 @@ QtObject:
proc getChannelGroups*(self: Service): seq[ChannelGroupDto] = proc getChannelGroups*(self: Service): seq[ChannelGroupDto] =
return toSeq(self.channelGroups.values) return toSeq(self.channelGroups.values)
proc loadChannelGroups*(self: Service) =
try:
let response = status_chat.getChannelGroups()
self.hydrateChannelGroups(response.result)
except Exception as e:
error "error loadChannelGroups: ", errorDescription = e.msg
proc loadChannelGroupById*(self: Service, channelGroupId: string) = proc loadChannelGroupById*(self: Service, channelGroupId: string) =
try: try:
let response = status_chat.getChannelGroupById(channelGroupId) let response = status_chat.getChannelGroupById(channelGroupId)
@ -329,15 +322,14 @@ QtObject:
# Community channel groups have less info because they come from community signals # Community channel groups have less info because they come from community signals
proc updateOrAddChannelGroup*(self: Service, channelGroup: ChannelGroupDto, isCommunityChannelGroup: bool = false) = proc updateOrAddChannelGroup*(self: Service, channelGroup: ChannelGroupDto, isCommunityChannelGroup: bool = false) =
var newChannelGroup = channelGroup
var newChannelGroups = channelGroup
if isCommunityChannelGroup and self.channelGroups.contains(channelGroup.id): if isCommunityChannelGroup and self.channelGroups.contains(channelGroup.id):
# We need to update missing fields in the chats seq before saving # We need to update missing fields in the chats seq before saving
let newChats = channelGroup.chats.mapIt(self.updateMissingFieldsInCommunityChat(channelGroup.id, it)) let newChats = channelGroup.chats.mapIt(self.updateMissingFieldsInCommunityChat(channelGroup.id, it))
newChannelGroups.chats = newChats newChannelGroup.chats = newChats
self.channelGroups[channelGroup.id] = newChannelGroups self.channelGroups[channelGroup.id] = newChannelGroup
for chat in newChannelGroups.chats: for chat in newChannelGroup.chats:
self.updateOrAddChat(chat) self.updateOrAddChat(chat)
proc getChannelGroupById*(self: Service, channelGroupId: string): ChannelGroupDto = proc getChannelGroupById*(self: Service, channelGroupId: string): ChannelGroupDto =