Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Cork/CorkApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import CorkTerminalFunctions

@main
struct CorkApp: App

Check warning on line 22 in Cork/CorkApp.swift

View workflow job for this annotation

GitHub Actions / test

Type Body Length Violation: Type body should span 600 lines or less excluding comments and whitespace: currently spans 620 lines (type_body_length)
{
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate: AppDelegate

Expand Down Expand Up @@ -665,6 +665,14 @@

// MARK: - Background updating

nonisolated static func backgroundNewlyOutdatedPackages(
refreshed refreshedOutdatedPackages: Set<OutdatedPackage>,
previous previousOutdatedPackages: Set<OutdatedPackage>
) -> Set<OutdatedPackage>
{
refreshedOutdatedPackages.subtracting(previousOutdatedPackages)
}

func handleBackgroundUpdating()
{
// Start the background update scheduler when the app starts
Expand Down Expand Up @@ -696,14 +704,19 @@
newOutdatedPackages = .init()
}

if await newOutdatedPackages.count > outdatedPackagesTracker.outdatedPackages.count
let previousOutdatedPackages: Set<OutdatedPackage> = await outdatedPackagesTracker.outdatedPackages

if await newOutdatedPackages.count > previousOutdatedPackages.count
{
AppConstants.shared.logger.log("New updates found")

/// Set this to `true` so the normal notification doesn't get sent
await setWhetherToSendStandardUpdatesAvailableNotification(to: false)

let differentPackages: Set<OutdatedPackage> = await newOutdatedPackages.subtracting(outdatedPackagesTracker.allDisplayableOutdatedPackages)
let differentPackages: Set<OutdatedPackage> = Self.backgroundNewlyOutdatedPackages(
refreshed: newOutdatedPackages,
previous: previousOutdatedPackages
)
AppConstants.shared.logger.debug("Changed packages: \(differentPackages, privacy: .auto)")

sendNotification(title: String(localized: "notification.new-outdated-packages-found.title"), subtitle: differentPackages.map{$0.package.name(withPrecision: .precise)}.formatted(.list(type: .and)))
Expand Down Expand Up @@ -774,4 +787,3 @@
}
}
}

Loading