From ed46533740c80d01383996390d27227ed06cca7d Mon Sep 17 00:00:00 2001 From: david-swift Date: Mon, 2 Feb 2026 22:07:57 +0100 Subject: [PATCH] App updates automatically after constructing UI Before, a backend had to implement the update right after the construction of the UI manually --- Sources/Model/User Interface/App/App.swift | 1 + Sources/Model/User Interface/App/AppStorage.swift | 8 +++++++- .../Model/User Interface/View/Properties/Property.swift | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/Model/User Interface/App/App.swift b/Sources/Model/User Interface/App/App.swift index 3b415f4..073e502 100644 --- a/Sources/Model/User Interface/App/App.swift +++ b/Sources/Model/User Interface/App/App.swift @@ -45,6 +45,7 @@ extension App { for element in app.scene where element is Storage.SceneElementType { element.setupInitialContainers(app: app.app) } + StateManager.updateViews(force: true) } } diff --git a/Sources/Model/User Interface/App/AppStorage.swift b/Sources/Model/User Interface/App/AppStorage.swift index 25c5007..c17d317 100644 --- a/Sources/Model/User Interface/App/AppStorage.swift +++ b/Sources/Model/User Interface/App/AppStorage.swift @@ -29,7 +29,12 @@ extension AppStorage { /// Focus the scene element with a certain id (if supported). Create the element if it doesn't already exist. /// - Parameter id: The element's id. public func showSceneElement(_ id: String) { - storage.sceneStorage.last { $0.id == id && !$0.destroy }?.show() ?? addSceneElement(id) + guard let storage = storage.sceneStorage.last(where: { $0.id == id && !$0.destroy }) else { + addSceneElement(id) + StateManager.updateViews(force: true) + return + } + storage.show() } /// Add a new scene element with the content of the scene element with a certain id. @@ -39,6 +44,7 @@ extension AppStorage { let container = element.container(app: self) storage.sceneStorage.append(container) showSceneElement(id) + StateManager.updateViews(force: true) } } diff --git a/Sources/Model/User Interface/View/Properties/Property.swift b/Sources/Model/User Interface/View/Properties/Property.swift index b50a7a6..db33cbb 100644 --- a/Sources/Model/User Interface/View/Properties/Property.swift +++ b/Sources/Model/User Interface/View/Properties/Property.swift @@ -143,7 +143,6 @@ extension Widget { ) -> ViewStorage where Data: ViewRenderData { let storage = ViewStorage(initializeWidget()) initProperties(storage, data: data, type: type) - update(storage, data: data, updateProperties: true, type: type) return storage }