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:
Jonathan Rainville
2026-07-16 16:48:51 -04:00
parent 65c1e4f63b
commit 839bfca535
7 changed files with 14 additions and 31 deletions
-6
View File
@@ -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)
+1 -7
View File
@@ -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.} =
+4 -7
View File
@@ -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()
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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) {
+5 -1
View File
@@ -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) {