From 13eed7898bfc3a87a49262a03b4a28d47040a127 Mon Sep 17 00:00:00 2001 From: Tobi Omotayo Date: Tue, 8 Oct 2024 17:00:40 +0100 Subject: [PATCH] replace ObservedObject with StateObject in HomeView so that it's initialised once. --- Example/SmileID/Home/HomeView.swift | 5 ++--- Sources/SmileID/Classes/SmileID.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Example/SmileID/Home/HomeView.swift b/Example/SmileID/Home/HomeView.swift index e6c8437f..877e2c54 100644 --- a/Example/SmileID/Home/HomeView.swift +++ b/Example/SmileID/Home/HomeView.swift @@ -4,11 +4,10 @@ import SwiftUI struct HomeView: View { let version = SmileID.version let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "Unknown" - @ObservedObject var viewModel: HomeViewModel - @ObservedObject var networkMonitor = NetworkMonitor.shared + @StateObject var viewModel: HomeViewModel init(config: Config) { - viewModel = HomeViewModel(config: config) + _viewModel = StateObject(wrappedValue: HomeViewModel(config: config)) } var body: some View { diff --git a/Sources/SmileID/Classes/SmileID.swift b/Sources/SmileID/Classes/SmileID.swift index f07d5729..6e86b385 100644 --- a/Sources/SmileID/Classes/SmileID.swift +++ b/Sources/SmileID/Classes/SmileID.swift @@ -207,7 +207,7 @@ public class SmileID { LocalStorage.getFileByType(jobId: jobId, fileType: .selfie), LocalStorage.getFileByType(jobId: jobId, fileType: .documentFront), LocalStorage.getFileByType(jobId: jobId, fileType: .documentBack), - LocalStorage.getInfoJsonFile(jobId: jobId), + LocalStorage.getInfoJsonFile(jobId: jobId) ].compactMap { $0 } allFiles = livenessFiles + additionalFiles } catch {