fix(@desktop/settings): crash enabling/disabling communities
- A crash was happening because of emitting signal from the Q_PROPERTY slot, fixed now. - Checks added to `addChat` methods that only 1:1 and group chats participate in notifications setting exemptions.
This commit is contained in:
parent
14f2e424b7
commit
8974d0a4df
|
@ -141,12 +141,6 @@ QtObject:
|
||||||
|
|
||||||
self.countChanged()
|
self.countChanged()
|
||||||
|
|
||||||
proc removeItemsByType*(self: Model, itemType: Type) =
|
|
||||||
let items = self.items
|
|
||||||
for i in items:
|
|
||||||
if(i.itemType == itemType):
|
|
||||||
self.removeItemById(i.id)
|
|
||||||
|
|
||||||
iterator modelIterator*(self: Model): Item =
|
iterator modelIterator*(self: Model): Item =
|
||||||
for i in 0 ..< self.items.len:
|
for i in 0 ..< self.items.len:
|
||||||
yield self.items[i]
|
yield self.items[i]
|
||||||
|
|
|
@ -131,17 +131,25 @@ method onToggleSection*(self: Module, sectionType: SectionType) =
|
||||||
let channelGroups = self.controller.getChannelGroups()
|
let channelGroups = self.controller.getChannelGroups()
|
||||||
for cg in channelGroups:
|
for cg in channelGroups:
|
||||||
if cg.channelGroupType == ChannelGroupType.Community:
|
if cg.channelGroupType == ChannelGroupType.Community:
|
||||||
|
let ind = self.view.exemptionsModel().findIndexForItemId(cg.id)
|
||||||
|
if(ind != -1):
|
||||||
|
continue
|
||||||
let item = self.createItem(cg.id, cg.name, cg.images.thumbnail, cg.color, joinedTimestamp = 0, item.Type.Community)
|
let item = self.createItem(cg.id, cg.name, cg.images.thumbnail, cg.color, joinedTimestamp = 0, item.Type.Community)
|
||||||
self.view.exemptionsModel().addItem(item)
|
self.view.exemptionsModel().addItem(item)
|
||||||
else:
|
else:
|
||||||
let allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
|
||||||
for item in self.view.exemptionsModel().modelIterator():
|
for item in self.view.exemptionsModel().modelIterator():
|
||||||
|
if(item.itemType != Type.Community):
|
||||||
|
continue
|
||||||
if(allExemptions.contains(item.id)):
|
if(allExemptions.contains(item.id)):
|
||||||
allExemptions.delete(item.id)
|
allExemptions.delete(item.id)
|
||||||
|
self.view.exemptionsModel().removeItemById(item.id)
|
||||||
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
|
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
|
||||||
self.view.exemptionsModel().removeItemsByType(item.Type.Community)
|
|
||||||
|
|
||||||
method addCommunity*(self: Module, communityDto: CommunityDto) =
|
method addCommunity*(self: Module, communityDto: CommunityDto) =
|
||||||
|
let ind = self.view.exemptionsModel().findIndexForItemId(communityDto.id)
|
||||||
|
if(ind != -1):
|
||||||
|
return
|
||||||
let item = self.createItem(communityDto.id, communityDto.name, communityDto.images.thumbnail, communityDto.color,
|
let item = self.createItem(communityDto.id, communityDto.name, communityDto.images.thumbnail, communityDto.color,
|
||||||
joinedTimestamp = 0, item.Type.Community)
|
joinedTimestamp = 0, item.Type.Community)
|
||||||
self.view.exemptionsModel().addItem(item)
|
self.view.exemptionsModel().addItem(item)
|
||||||
|
@ -160,6 +168,8 @@ method removeItemWithId*(self: Module, itemId: string) =
|
||||||
self.view.exemptionsModel().removeItemById(itemId)
|
self.view.exemptionsModel().removeItemById(itemId)
|
||||||
|
|
||||||
method addChat*(self: Module, chatDto: ChatDto) =
|
method addChat*(self: Module, chatDto: ChatDto) =
|
||||||
|
if chatDto.chatType != ChatType.OneToOne and chatDto.chatType != ChatType.PrivateGroupChat:
|
||||||
|
return
|
||||||
let ind = self.view.exemptionsModel().findIndexForItemId(chatDto.id)
|
let ind = self.view.exemptionsModel().findIndexForItemId(chatDto.id)
|
||||||
if(ind != -1):
|
if(ind != -1):
|
||||||
return
|
return
|
||||||
|
@ -171,6 +181,8 @@ method addChat*(self: Module, itemId: string) =
|
||||||
if(ind != -1):
|
if(ind != -1):
|
||||||
return
|
return
|
||||||
let chatDto = self.controller.getChatDetails(itemId)
|
let chatDto = self.controller.getChatDetails(itemId)
|
||||||
|
if chatDto.chatType != ChatType.OneToOne and chatDto.chatType != ChatType.PrivateGroupChat:
|
||||||
|
return
|
||||||
self.addChat(chatDto)
|
self.addChat(chatDto)
|
||||||
|
|
||||||
method setName*(self: Module, itemId: string, name: string) =
|
method setName*(self: Module, itemId: string, name: string) =
|
||||||
|
|
Loading…
Reference in New Issue