mirror of
https://github.com/status-im/status-app.git
synced 2026-08-27 15:11:20 +00:00
refactor(network): rewire connection checks to use the NetworkChecker
Some parts of the wallet and the gif loader used to be refreshed using the waku connection state. While it does work in theory, it's highly inefficient, because waku can take multiple seconds before the disconnection is detected (all peers are gone). The NetworkChecker is way faster. As soon as the connection is loast or regained, the status is propagated. So those two code paths now use the NetworkChecker instead of waku connections.
This commit is contained in:
@@ -315,12 +315,6 @@ proc init*(self: Controller) =
|
||||
var args = CommunityRequestArgs(e)
|
||||
self.delegate.communityMemberRevealedAccountsAdded(args.communityRequest)
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_CONNECTED) do(e: Args):
|
||||
self.delegate.onNetworkConnected()
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_DISCONNECTED) do(e: Args):
|
||||
self.delegate.onNetworkDisconnected()
|
||||
|
||||
self.events.on(SIGNAL_CURRENT_USER_STATUS_UPDATED) do (e: Args):
|
||||
var args = CurrentUserStatusArgs(e)
|
||||
singletonInstance.userProfile.setCurrentUserStatus(args.statusType.int)
|
||||
|
||||
@@ -244,12 +244,6 @@ method meMentionedCountChanged*(self: AccessInterface, allMentions: int) {.base.
|
||||
method onPlayNotificationSound*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onNetworkConnected*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onNetworkDisconnected*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method viewDidLoad*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
@@ -405,7 +399,7 @@ method windowActivated*(self: AccessInterface) {.base.} =
|
||||
method windowDeactivated*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method connectionChange*(self: AccessInterface, connectionType: string, isExpensive: bool) {.base.} =
|
||||
method connectionChange*(self: AccessInterface, connectionType: string, isExpensive: bool, isOnline: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method communityMembersRevealedAccountsLoaded*(self: AccessInterface, communityId: string, membersRevealedAccounts: MembersRevealedAccounts) {.base.} =
|
||||
|
||||
@@ -237,6 +237,7 @@ proc newModule*[T](
|
||||
result.walletAccountService = walletAccountService
|
||||
result.savedAddressService = savedAddressService
|
||||
result.followingAddressService = followingAddressService
|
||||
result.networkConnectionService = networkConnectionService
|
||||
result.stickersService = stickersService
|
||||
result.communityTokensService = communityTokensService
|
||||
result.transactionService = transactionService
|
||||
@@ -1270,12 +1271,6 @@ method onNotificationsUpdated[T](self: Module[T], sectionId: string, sectionHasU
|
||||
method onPlayNotificationSound[T](self: Module[T]) =
|
||||
self.view.playNotificationSound()
|
||||
|
||||
method onNetworkConnected[T](self: Module[T]) =
|
||||
self.view.setConnected(true)
|
||||
|
||||
method onNetworkDisconnected[T](self: Module[T]) =
|
||||
self.view.setConnected(false)
|
||||
|
||||
method isConnected[T](self: Module[T]): bool =
|
||||
self.controller.isConnected()
|
||||
|
||||
@@ -2097,7 +2092,9 @@ method windowActivated*[T](self: Module[T]) =
|
||||
method windowDeactivated*[T](self: Module[T]) =
|
||||
self.controller.speedupArchivesImport()
|
||||
|
||||
method connectionChange*[T](self: Module[T], connectionType: string, isExpensive: bool) =
|
||||
method connectionChange*[T](self: Module[T], connectionType: string, isExpensive: bool, isOnline: bool) =
|
||||
self.view.setConnected(isOnline)
|
||||
self.networkConnectionService.networkConnected(isOnline)
|
||||
self.controller.connectionChange(connectionType, isExpensive)
|
||||
|
||||
method communityMembersRevealedAccountsLoaded*[T](self: Module[T], communityId: string, membersRevealedAccounts: MembersRevealedAccounts) =
|
||||
|
||||
@@ -30,12 +30,6 @@ proc init*(self: Controller) =
|
||||
let args = NetworkConnectionsArgs(e)
|
||||
self.delegate.networkConnectionStatusUpdate(args.website, args.completelyDown, ord(args.connectionState), args.chainIds, args.lastCheckedAt)
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_CONNECTED) do(e: Args):
|
||||
self.networkConnectionService.networkConnected(true)
|
||||
|
||||
self.events.on(SIGNAL_NETWORK_DISCONNECTED) do(e: Args):
|
||||
self.networkConnectionService.networkConnected(false)
|
||||
|
||||
proc refreshBlockchainValues*(self: Controller) =
|
||||
self.networkConnectionService.blockchainsRetry()
|
||||
|
||||
|
||||
@@ -334,8 +334,8 @@ QtObject:
|
||||
proc windowDeactivated*(self: View) {.slot.} =
|
||||
self.delegate.windowDeactivated()
|
||||
|
||||
proc connectionChange*(self: View, connectionType: string, isExpensive: bool) {.slot.} =
|
||||
self.delegate.connectionChange(connectionType, isExpensive)
|
||||
proc connectionChange*(self: View, connectionType: string, isExpensive: bool, isOnline: bool) {.slot.} =
|
||||
self.delegate.connectionChange(connectionType, isExpensive, isOnline)
|
||||
|
||||
proc setCommunityIdToSpectate*(self: View, communityId: string) {.slot.} =
|
||||
self.delegate.setCommunityIdToSpectate(communityId)
|
||||
|
||||
@@ -94,10 +94,10 @@ QtObject {
|
||||
internal.mainModuleInst.windowDeactivated()
|
||||
}
|
||||
|
||||
function connectionChange(connectionType, isExpensive) {
|
||||
function connectionChange(connectionType, isExpensive, isOnline) {
|
||||
if(!internal.mainModuleInst)
|
||||
return
|
||||
internal.mainModuleInst.connectionChange(connectionType, isExpensive)
|
||||
internal.mainModuleInst.connectionChange(connectionType, isExpensive, isOnline)
|
||||
}
|
||||
|
||||
function setActiveSectionBySectionType(sectionType) {
|
||||
|
||||
@@ -869,7 +869,11 @@ Item {
|
||||
}
|
||||
|
||||
function connectionChange() {
|
||||
appMain.rootStore.connectionChange(d.networkChecker.connectionType, d.networkChecker.isExpensive)
|
||||
appMain.rootStore.connectionChange(
|
||||
d.networkChecker.connectionType,
|
||||
d.networkChecker.isExpensive,
|
||||
d.networkChecker.isOnline
|
||||
)
|
||||
}
|
||||
|
||||
function openLinkInBrowser(link: string) {
|
||||
|
||||
Reference in New Issue
Block a user