Sign In Sign Up

Move update view model to AppDelegate

Move the update view model data to AppDelegate since the update information will be app-global.

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:

  1. Search for update view model related code
  2. Find the AppDelegate file
  3. 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.

Find the update view model implementation in the macOS app that manages update information
Find the AppDelegate file in the macOS app
UpdateViewModel|updateViewModel 6 matches

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:

terminalWindow\.updateUIModel|window\.updateUIModel 1 match
createUpdateActions 2 matches

Now I understand the structure. I need to:

  1. Move updateUIModel from TerminalWindow to AppDelegate
  2. Update references to access it from AppDelegate instead
  3. 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