refactor(chat): remove unused section unloading
This commit is contained in:
parent
7f3a66b68d
commit
a362cdad16
|
@ -27,14 +27,6 @@ QtObject:
|
|||
proc newChatInMemory(sectionId, chatId: string): ChatInMemory =
|
||||
(sectionId, chatId)
|
||||
|
||||
proc unloadSection*(self: LoaderDeactivator, searchSectionId: string): bool =
|
||||
if searchSectionId.len == 0:
|
||||
return false
|
||||
for (sectionId, _) in self.keepInMemory.items:
|
||||
if sectionId == searchSectionId:
|
||||
return false
|
||||
return true
|
||||
|
||||
proc addChatInMemory*(self: LoaderDeactivator, sectionId, chatId: string): ChatInMemory =
|
||||
if self.keepInMemory.contains(newChatInMemory(sectionId, chatId)):
|
||||
return
|
||||
|
|
|
@ -461,7 +461,7 @@ method activeItemSet*(self: Module, itemId: string) =
|
|||
|
||||
# notify parent module about active chat/channel
|
||||
self.delegate.onActiveChatChange(mySectionId, activeChatId)
|
||||
self.delegate.onDeactivateSectionAndChatLoader(deactivateSectionId, deactivateChatId)
|
||||
self.delegate.onDeactivateChatLoader(deactivateSectionId, deactivateChatId)
|
||||
|
||||
method getModuleAsVariant*(self: Module): QVariant =
|
||||
return self.viewVariant
|
||||
|
|
|
@ -306,7 +306,7 @@ method onAcceptRequestToJoinLoading*(self: AccessInterface, communityId: string,
|
|||
method onAcceptRequestToJoinSuccess*(self: AccessInterface, communityId: string, memberKey: string, requestId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onDeactivateSectionAndChatLoader*(self: AccessInterface, sectionId: string, chatId: string) {.base.} =
|
||||
method onDeactivateChatLoader*(self: AccessInterface, sectionId: string, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# This way (using concepts) is used only for the modules managed by AppController
|
||||
|
|
|
@ -369,7 +369,6 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto):
|
|||
) else: @[],
|
||||
channelGroup.encrypted,
|
||||
communityTokensItems,
|
||||
loaderActive = active,
|
||||
)
|
||||
|
||||
method load*[T](
|
||||
|
@ -1194,8 +1193,6 @@ method activateStatusDeepLink*[T](self: Module[T], statusDeepLink: string) =
|
|||
let linkToActivate = self.urlsManager.convertExternalLinkToInternal(statusDeepLink)
|
||||
self.urlsManager.onUrlActivated(linkToActivate)
|
||||
|
||||
method onDeactivateSectionAndChatLoader*[T](self: Module[T], sectionId: string, chatId: string) =
|
||||
method onDeactivateChatLoader*[T](self: Module[T], sectionId: string, chatId: string) =
|
||||
if (sectionId.len > 0 and self.channelGroupModules.contains(sectionId)):
|
||||
self.channelGroupModules[sectionId].onDeactivateChatLoader(chatId)
|
||||
if (singletonInstance.loaderDeactivator.unloadSection(sectionId)):
|
||||
self.view.model().disableSectionLoader(sectionId)
|
|
@ -55,7 +55,6 @@ type
|
|||
declinedMemberRequestsModel: member_model.Model
|
||||
encrypted: bool
|
||||
communityTokensModel: community_tokens_model.TokenModel
|
||||
loaderActive: bool
|
||||
|
||||
proc initItem*(
|
||||
id: string,
|
||||
|
@ -92,7 +91,6 @@ proc initItem*(
|
|||
declinedMemberRequests: seq[MemberItem] = @[],
|
||||
encrypted: bool = false,
|
||||
communityTokens: seq[TokenItem] = @[],
|
||||
loaderActive = false,
|
||||
): SectionItem =
|
||||
result.id = id
|
||||
result.sectionType = sectionType
|
||||
|
@ -134,7 +132,6 @@ proc initItem*(
|
|||
result.encrypted = encrypted
|
||||
result.communityTokensModel = newTokenModel()
|
||||
result.communityTokensModel.setItems(communityTokens)
|
||||
result.loaderActive = loaderActive
|
||||
|
||||
proc isEmpty*(self: SectionItem): bool =
|
||||
return self.id.len == 0
|
||||
|
@ -174,7 +171,6 @@ proc `$`*(self: SectionItem): string =
|
|||
declinedMemberRequests:{self.declinedMemberRequestsModel},
|
||||
encrypted:{self.encrypted},
|
||||
communityTokensModel:{self.communityTokensModel},
|
||||
loaderActive:{self.loaderActive},
|
||||
]"""
|
||||
|
||||
proc id*(self: SectionItem): string {.inline.} =
|
||||
|
@ -326,9 +322,3 @@ proc communityTokens*(self: SectionItem): community_tokens_model.TokenModel {.in
|
|||
|
||||
proc updatePendingRequestLoadingState*(self: SectionItem, memberKey: string, loading: bool) {.inline.} =
|
||||
self.pendingMemberRequestsModel.updateLoadingState(memberKey, loading)
|
||||
|
||||
proc loaderActive*(self: SectionItem): bool {.inline.} =
|
||||
self.loaderActive
|
||||
|
||||
proc `loaderActive=`*(self: var SectionItem, value: bool) {.inline.} =
|
||||
self.loaderActive = value
|
||||
|
|
|
@ -42,7 +42,6 @@ type
|
|||
PendingMemberRequestsModel
|
||||
DeclinedMemberRequestsModel
|
||||
AmIBanned
|
||||
LoaderActive
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
@ -115,7 +114,6 @@ QtObject:
|
|||
ModelRole.PendingMemberRequestsModel.int:"pendingMemberRequests",
|
||||
ModelRole.DeclinedMemberRequestsModel.int:"declinedMemberRequests",
|
||||
ModelRole.AmIBanned.int:"amIBanned",
|
||||
ModelRole.LoaderActive.int:"loaderActive"
|
||||
}.toTable
|
||||
|
||||
method data(self: SectionModel, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -199,8 +197,6 @@ QtObject:
|
|||
result = newQVariant(item.declinedMemberRequests)
|
||||
of ModelRole.AmIBanned:
|
||||
result = newQVariant(item.amIBanned)
|
||||
of ModelRole.LoaderActive:
|
||||
result = newQVariant(item.loaderActive)
|
||||
|
||||
proc isItemExist(self: SectionModel, id: string): bool =
|
||||
for it in self.items:
|
||||
|
@ -299,7 +295,6 @@ QtObject:
|
|||
ModelRole.PendingMemberRequestsModel.int,
|
||||
ModelRole.DeclinedMemberRequestsModel.int,
|
||||
ModelRole.AmIBanned.int,
|
||||
ModelRole.LoaderActive.int
|
||||
])
|
||||
|
||||
proc getNthEnabledItem*(self: SectionModel, nth: int): SectionItem =
|
||||
|
@ -339,9 +334,8 @@ QtObject:
|
|||
let index = self.createIndex(i, 0, nil)
|
||||
defer: index.delete
|
||||
self.items[i].active = true
|
||||
self.items[i].loaderActive = true
|
||||
|
||||
self.dataChanged(index, index, @[ModelRole.Active.int, ModelRole.LoaderActive.int])
|
||||
self.dataChanged(index, index, @[ModelRole.Active.int])
|
||||
|
||||
proc sectionVisibilityUpdated*(self: SectionModel) {.signal.}
|
||||
|
||||
|
@ -441,14 +435,5 @@ QtObject:
|
|||
"ensOnly": item.ensOnly,
|
||||
"nbMembers": item.members.getCount(),
|
||||
"encrypted": item.encrypted,
|
||||
"loaderActive": item.loaderActive,
|
||||
}
|
||||
return $jsonObj
|
||||
|
||||
proc disableSectionLoader*(self: SectionModel, sectionId: string) =
|
||||
for i in 0 ..< self.items.len:
|
||||
if(self.items[i].id == sectionId):
|
||||
let index = self.createIndex(i, 0, nil)
|
||||
defer: index.delete
|
||||
self.items[i].loaderActive = false
|
||||
self.dataChanged(index, index, @[ModelRole.LoaderActive.int])
|
Loading…
Reference in New Issue