App updates automatically after constructing UI
Some checks are pending
Deploy Docs / publish (push) Waiting to run
SwiftLint / SwiftLint (push) Waiting to run

Before, a backend had to implement the update right after the
construction of the UI manually
This commit is contained in:
david-swift 2026-02-02 22:07:57 +01:00
parent 0e2595e2d4
commit ed46533740
3 changed files with 8 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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
}