Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ios: track initial connectivity change when application is run and bring back general connectivity logs #2245

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ final class ConnectivityMonitoringAdapter: ObservableObject, ConnectivityMonitor
guard isConnected != self.isConnected else { return }
self.isConnected = isConnected
notificationQueue.async {
if isConnected {
try? historyDeviceWasOnline()
}
update(isConnected)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension MainScreenContainer {

private extension MainScreenContainer.ViewModel {
func initialiseAppRun() {
appLaunchMediator.finaliseInitialisation { result in
appLaunchMediator.finaliseInitialisation(connectivityMediator.isConnectivityOn) { result in
switch result {
case .success:
self.checkInitialState()
Expand Down
20 changes: 16 additions & 4 deletions ios/PolkadotVault/StateMediators/AppLaunchMediator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import Foundation

protocol AppLaunchMediating: AnyObject {
func finaliseInitialisation(_ completion: @escaping (Result<Void, ServiceError>) -> Void)
func finaliseInitialisation(
_ isConnected: Bool,
_ completion: @escaping (Result<Void, ServiceError>) -> Void
)
}

final class AppLaunchMediator: ObservableObject, AppLaunchMediating {
Expand All @@ -26,9 +29,12 @@ final class AppLaunchMediator: ObservableObject, AppLaunchMediating {
self.backendService = backendService
}

func finaliseInitialisation(_ completion: @escaping (Result<Void, ServiceError>) -> Void) {
func finaliseInitialisation(
_ isConnected: Bool,
_ completion: @escaping (Result<Void, ServiceError>) -> Void
) {
if databaseMediator.isDatabaseAvailable() {
initialiseOnboardedUserRun(completion)
initialiseOnboardedUserRun(isConnected, completion)
} else {
initialiseFirstRun(completion)
}
Expand All @@ -40,10 +46,16 @@ final class AppLaunchMediator: ObservableObject, AppLaunchMediating {
completion(.success(()))
}

private func initialiseOnboardedUserRun(_ completion: @escaping (Result<Void, ServiceError>) -> Void) {
private func initialiseOnboardedUserRun(
_ isConnected: Bool,
_ completion: @escaping (Result<Void, ServiceError>) -> Void
) {
seedsMediator.refreshSeeds()
backendService.performCall({
try initNavigation(dbname: self.databaseMediator.databaseName, seedNames: self.seedsMediator.seedNames)
if isConnected {
try? historyDeviceWasOnline()
}
}, completion: completion)
}
}
Loading