feat: speedup/slowdown archives import based on window state
closes: #10815
This commit is contained in:
parent
4b2d328a07
commit
b582afb03a
|
@ -478,4 +478,10 @@ proc getCommunityTokenOwnerName*(self: Controller, chainId: int, contractAddress
|
|||
return self.communityTokensService.contractOwnerName(chainId, contractAddress)
|
||||
|
||||
proc getNetwork*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetwork(chainId)
|
||||
self.networksService.getNetwork(chainId)
|
||||
|
||||
proc slowdownArchivesImport*(self:Controller) =
|
||||
communityService.slowdownArchivesImport()
|
||||
|
||||
proc speedupArchivesImport*(self:Controller) =
|
||||
communityService.speedupArchivesImport()
|
||||
|
|
|
@ -315,6 +315,12 @@ method onAcceptRequestToJoinSuccess*(self: AccessInterface, communityId: string,
|
|||
method onDeactivateChatLoader*(self: AccessInterface, sectionId: string, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method windowActivated*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method windowDeactivated*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# This way (using concepts) is used only for the modules managed by AppController
|
||||
type
|
||||
DelegateInterface* = concept c
|
||||
|
|
|
@ -1211,3 +1211,9 @@ method activateStatusDeepLink*[T](self: Module[T], statusDeepLink: 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)
|
||||
|
||||
method windowActivated*[T](self: Module[T]) =
|
||||
self.controller.slowdownArchivesImport()
|
||||
|
||||
method windowDeactivated*[T](self: Module[T]) =
|
||||
self.controller.speedupArchivesImport()
|
||||
|
|
|
@ -263,5 +263,8 @@ QtObject:
|
|||
proc emitDestroyKeycardSharedModuleFlow*(self: View) =
|
||||
self.destroyKeycardSharedModuleFlow()
|
||||
|
||||
proc setCommunityIdToSpectate*(self: View, communityId: string) {.slot.} =
|
||||
self.delegate.setCommunityIdToSpectate(communityId)
|
||||
proc windowActivated*(self: View) {.slot.} =
|
||||
self.delegate.windowActivated()
|
||||
|
||||
proc windowDeactivated*(self: View) {.slot.} =
|
||||
self.delegate.windowDeactivated()
|
||||
|
|
|
@ -1534,6 +1534,24 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "Error exporting community", msg = e.msg
|
||||
|
||||
proc speedupArchivesImport*() =
|
||||
try:
|
||||
let response = status_go.speedupArchivesImport()
|
||||
if (response.error != nil):
|
||||
let error = Json.decode($response.error, RpcError)
|
||||
raise newException(RpcException, fmt"err: {error.message}")
|
||||
except Exception as e:
|
||||
error "Error speeding up archives import: ", msg = e.msg
|
||||
|
||||
proc slowdownArchivesImport*() =
|
||||
try:
|
||||
let response = status_go.slowdownArchivesImport()
|
||||
if (response.error != nil):
|
||||
let error = Json.decode($response.error, RpcError)
|
||||
raise newException(RpcException, fmt"err: {error.message}")
|
||||
except Exception as e:
|
||||
error "Error slowing down archives import: ", msg = e.msg
|
||||
|
||||
proc getPendingRequestIndex(self: Service, communityId: string, requestId: string): int =
|
||||
let community = self.communities[communityId]
|
||||
var i = 0
|
||||
|
|
|
@ -317,6 +317,12 @@ proc importCommunity*(communityKey: string): RpcResponse[JsonNode] {.raises: [Ex
|
|||
proc exportCommunity*(communityId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("exportCommunity".prefix, %*[communityId])
|
||||
|
||||
proc speedupArchivesImport*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("speedupArchivesImport".prefix)
|
||||
|
||||
proc slowdownArchivesImport*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("slowdownArchivesImport".prefix)
|
||||
|
||||
proc removeUserFromCommunity*(communityId: string, pubKey: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("removeUserFromCommunity".prefix, %*[communityId, pubKey])
|
||||
|
||||
|
|
|
@ -148,4 +148,12 @@ QtObject {
|
|||
function resolveENS(value) {
|
||||
mainModuleInst.resolveENS(value, "")
|
||||
}
|
||||
|
||||
function windowActivated() {
|
||||
mainModuleInst.windowActivated()
|
||||
}
|
||||
|
||||
function windowDeactivated() {
|
||||
mainModuleInst.windowDeactivated()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,6 +200,15 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Global.applicationWindow
|
||||
|
||||
function onActiveChanged() {
|
||||
if (Global.applicationWindow.active) appMain.rootStore.windowActivated()
|
||||
else appMain.rootStore.windowDeactivated()
|
||||
}
|
||||
}
|
||||
|
||||
function changeAppSectionBySectionId(sectionId) {
|
||||
appMain.rootStore.mainModuleInst.setActiveSectionById(sectionId)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue