Move update view model to AppDelegate
The user wants me to move update view model data to AppDelegate. This seems to be related to a macOS app (based on the directory structure showing a macos/ folder). The update information should be app-global, so they want it moved to AppDelegate rather than having it in a specific view or view controller.
Let me first understand the current structure by finding where the update view model data currently exists, and then finding the AppDelegate to see where it should be moved.
I should:
- Search for update view model related code
- Find the AppDelegate file
- Move the relevant code
Let me start by searching for update-related view models and the AppDelegate.
I'll help you move the update view model data to AppDelegate. Let me first locate the relevant files.
macOS/Sources/Features/Update/UpdateViewModel.swift
This file contains the UpdateViewModel class that manages update information in the macOS app. It includes:
- State management for various update states (idle, checking, downloading, installing, etc.)
- Progress tracking
- Update details (version, build, size, date, release notes)
- Error information
- Computed properties for UI presentation (tooltips, text, icons, colors)
The AppDelegate file for the macOS app is located at:
macos/Sources/App/macOS/AppDelegate.swift
Now I can see the structure. The UpdateViewModel is currently instantiated in TerminalWindow (line 20), but it should be app-global in AppDelegate. Let me check how it's being used in other places:
Now I understand the structure. I need to:
- Move
updateUIModelfromTerminalWindowtoAppDelegate - Update references to access it from AppDelegate instead
- Update the
createUpdateActions()method to work with the app-global model
Let me make these changes:
@@ -100,8 +100,11 @@
/// Manages updates
let updaterController: SPUStandardUpdaterController
let updaterDelegate: UpdaterDelegate = UpdaterDelegate()
/// Update view model for UI display
@Published private(set) var updateUIModel = UpdateViewModel()
/// The elapsed time since the process was started
var timeSinceLaunch: TimeInterval {
return ProcessInfo.processInfo.systemUptime - applicationLaunchTime
Thread
Reference Thread
T-af16fe85-bdc5-4fcb-b7e7-dbc425ca5da7