From 2f8d46fa76f492d4610d232a30e23f5de32aab26 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 3 Mar 2021 13:19:12 -0500 Subject: [PATCH] fix: fix community channel color undefined issue --- src/app/chat/view.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 3ee2efac88..2532fd205d 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -100,7 +100,10 @@ QtObject: 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)) + let index = self.communities.activeCommunity.chats.chats.findIndexById(channel) + if (index == -1): + return + return self.communities.activeCommunity.chats.getChannel(index) else: return self.chats.getChannel(self.chats.chats.findIndexById(channel)) @@ -146,7 +149,7 @@ QtObject: proc getChannelColor*(self: ChatsView, channel: string): string {.slot.} = if (channel == ""): return let selectedChannel = self.getChannelById(channel) - if (selectedChannel.id == "") : return + if (selectedChannel.isNil or selectedChannel.id == "") : return return selectedChannel.color proc replaceMentionsWithPubKeys(self: ChatsView, mentions: seq[string], contacts: seq[Profile], message: string, predicate: proc (contact: Profile): string): string =