Przeglądaj źródła

Delete redundant shortcuts; Refactoring for Swift 6 (solves missing conformance to Sendable)

polscm32 aka Marvout 1 rok temu
rodzic
commit
d7cf7ff7b5

+ 1 - 9
FreeAPS.xcodeproj/project.pbxproj

@@ -19,7 +19,6 @@
 		110AEDEE2C51A0AE00615CC9 /* ShortcutsConfigStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110AEDE92C51A0AE00615CC9 /* ShortcutsConfigStateModel.swift */; };
 		118DF76A2C5ECBC60067FEB7 /* ApplyOverridePresetIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 118DF7642C5ECBC60067FEB7 /* ApplyOverridePresetIntent.swift */; };
 		118DF76B2C5ECBC60067FEB7 /* CancelOverrideIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 118DF7652C5ECBC60067FEB7 /* CancelOverrideIntent.swift */; };
-		118DF76C2C5ECBC60067FEB7 /* ListOverridePresetIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 118DF7662C5ECBC60067FEB7 /* ListOverridePresetIntent.swift */; };
 		118DF76D2C5ECBC60067FEB7 /* OverridePresetEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 118DF7672C5ECBC60067FEB7 /* OverridePresetEntity.swift */; };
 		118DF76E2C5ECBC60067FEB7 /* OverridePresetsIntentRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 118DF7682C5ECBC60067FEB7 /* OverridePresetsIntentRequest.swift */; };
 		17A9D0899046B45E87834820 /* CarbRatioEditorProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C8D5F457B5AFF763F8CF3DF /* CarbRatioEditorProvider.swift */; };
@@ -376,7 +375,6 @@
 		CE7CA34F2A064973004BE681 /* BaseIntentsRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA3442A064973004BE681 /* BaseIntentsRequest.swift */; };
 		CE7CA3502A064973004BE681 /* CancelTempPresetIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA3462A064973004BE681 /* CancelTempPresetIntent.swift */; };
 		CE7CA3512A064973004BE681 /* ApplyTempPresetIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA3472A064973004BE681 /* ApplyTempPresetIntent.swift */; };
-		CE7CA3522A064973004BE681 /* ListTempPresetsIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA3482A064973004BE681 /* ListTempPresetsIntent.swift */; };
 		CE7CA3532A064973004BE681 /* TempPresetIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA3492A064973004BE681 /* TempPresetIntent.swift */; };
 		CE7CA3542A064973004BE681 /* TempPresetsIntentRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA34A2A064973004BE681 /* TempPresetsIntentRequest.swift */; };
 		CE7CA3552A064973004BE681 /* ListStateIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7CA34C2A064973004BE681 /* ListStateIntent.swift */; };
@@ -639,7 +637,6 @@
 		110AEDE92C51A0AE00615CC9 /* ShortcutsConfigStateModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShortcutsConfigStateModel.swift; sourceTree = "<group>"; };
 		118DF7642C5ECBC60067FEB7 /* ApplyOverridePresetIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplyOverridePresetIntent.swift; sourceTree = "<group>"; };
 		118DF7652C5ECBC60067FEB7 /* CancelOverrideIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CancelOverrideIntent.swift; sourceTree = "<group>"; };
-		118DF7662C5ECBC60067FEB7 /* ListOverridePresetIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListOverridePresetIntent.swift; sourceTree = "<group>"; };
 		118DF7672C5ECBC60067FEB7 /* OverridePresetEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverridePresetEntity.swift; sourceTree = "<group>"; };
 		118DF7682C5ECBC60067FEB7 /* OverridePresetsIntentRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverridePresetsIntentRequest.swift; sourceTree = "<group>"; };
 		19012CDB291D2CB900FB8210 /* LoopStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopStats.swift; sourceTree = "<group>"; };
@@ -1064,7 +1061,6 @@
 		CE7CA3442A064973004BE681 /* BaseIntentsRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseIntentsRequest.swift; sourceTree = "<group>"; };
 		CE7CA3462A064973004BE681 /* CancelTempPresetIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CancelTempPresetIntent.swift; sourceTree = "<group>"; };
 		CE7CA3472A064973004BE681 /* ApplyTempPresetIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplyTempPresetIntent.swift; sourceTree = "<group>"; };
-		CE7CA3482A064973004BE681 /* ListTempPresetsIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTempPresetsIntent.swift; sourceTree = "<group>"; };
 		CE7CA3492A064973004BE681 /* TempPresetIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TempPresetIntent.swift; sourceTree = "<group>"; };
 		CE7CA34A2A064973004BE681 /* TempPresetsIntentRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TempPresetsIntentRequest.swift; sourceTree = "<group>"; };
 		CE7CA34C2A064973004BE681 /* ListStateIntent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListStateIntent.swift; sourceTree = "<group>"; };
@@ -1353,7 +1349,6 @@
 			children = (
 				118DF7642C5ECBC60067FEB7 /* ApplyOverridePresetIntent.swift */,
 				118DF7652C5ECBC60067FEB7 /* CancelOverrideIntent.swift */,
-				118DF7662C5ECBC60067FEB7 /* ListOverridePresetIntent.swift */,
 				118DF7672C5ECBC60067FEB7 /* OverridePresetEntity.swift */,
 				118DF7682C5ECBC60067FEB7 /* OverridePresetsIntentRequest.swift */,
 			);
@@ -2531,9 +2526,8 @@
 		CE7CA3452A064973004BE681 /* TempPresets */ = {
 			isa = PBXGroup;
 			children = (
-				CE7CA3462A064973004BE681 /* CancelTempPresetIntent.swift */,
 				CE7CA3472A064973004BE681 /* ApplyTempPresetIntent.swift */,
-				CE7CA3482A064973004BE681 /* ListTempPresetsIntent.swift */,
+				CE7CA3462A064973004BE681 /* CancelTempPresetIntent.swift */,
 				CE7CA3492A064973004BE681 /* TempPresetIntent.swift */,
 				CE7CA34A2A064973004BE681 /* TempPresetsIntentRequest.swift */,
 			);
@@ -3471,7 +3465,6 @@
 				CEE9A6592BBB418300EB5194 /* CalibrationsDataFlow.swift in Sources */,
 				3811DE3525C9D49500A708ED /* HomeRootView.swift in Sources */,
 				38E98A2925F52C9300C0CED0 /* Error+Extensions.swift in Sources */,
-				118DF76C2C5ECBC60067FEB7 /* ListOverridePresetIntent.swift in Sources */,
 				38EA05DA261F6E7C0064E39B /* SimpleLogReporter.swift in Sources */,
 				3811DE6125C9D4D500A708ED /* ViewModifiers.swift in Sources */,
 				3811DEAC25C9D88300A708ED /* NightscoutManager.swift in Sources */,
@@ -3574,7 +3567,6 @@
 				E974172296125A5AE99E634C /* PumpConfigRootView.swift in Sources */,
 				DD1745502C55CA5500211FAC /* UnitsLimitsSettingsProvider.swift in Sources */,
 				581AC4392BE22ED10038760C /* JSONConverter.swift in Sources */,
-				CE7CA3522A064973004BE681 /* ListTempPresetsIntent.swift in Sources */,
 				BD4064D12C4ED26900582F43 /* CoreDataObserver.swift in Sources */,
 				58645B9B2CA2D24F008AFCE7 /* CarbSetup.swift in Sources */,
 				38E44536274E411700EC9A94 /* Disk.swift in Sources */,

+ 1 - 1
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -256,7 +256,7 @@ extension Home {
             var target = (latestTempTarget.target ?? 100) as Decimal
             var halfBasalTarget: Decimal = 160
             if latestTempTarget.halfBasalTarget != nil {
-                halfBasalTarget = latestTempTarget.halfBasalTarget as! Decimal
+                halfBasalTarget = latestTempTarget.halfBasalTarget! as Decimal
             } else { halfBasalTarget = state.settingHalfBasalTarget }
             var showPercentage = false
             if target > 100, state.isExerciseModeActive || state.highTTraisesSens { showPercentage = true }

+ 1 - 7
FreeAPS/Sources/Shortcuts/Bolus/BolusIntent.swift

@@ -10,12 +10,6 @@ import Swinject
     // Description of the action in the Shortcuts app
     static var description = IntentDescription(.init("Allow to send a bolus to the app", table: "ShortcutsDetail"))
 
-    internal var bolusRequest: BolusIntentRequest
-
-    init() {
-        bolusRequest = BolusIntentRequest()
-    }
-
     @Parameter(
         title: LocalizedStringResource("Amount", table: "ShortcutsDetail"),
         description: LocalizedStringResource("Bolus amount in U", table: "ShortcutsDetail"),
@@ -64,7 +58,7 @@ import Swinject
                 )
             }
 
-            let finalBolusDisplay = try await bolusRequest.bolus(amount)
+            let finalBolusDisplay = try await BolusIntentRequest().bolus(amount)
             return .result(
                 dialog: IntentDialog(finalBolusDisplay)
             )

+ 3 - 9
FreeAPS/Sources/Shortcuts/Override/ApplyOverridePresetIntent.swift

@@ -1,19 +1,13 @@
 import AppIntents
 import Foundation
 
-@available(iOS 16.0, *) struct ApplyOverridePresetIntent: AppIntent {
+struct ApplyOverridePresetIntent: AppIntent {
     // Title of the action in the Shortcuts app
     static var title = LocalizedStringResource("Activate an override", table: "ShortcutsDetail")
 
     // Description of the action in the Shortcuts app
     static var description = IntentDescription(.init("Activate an override", table: "ShortcutsDetail"))
 
-    internal var intentRequest: OverridePresetsIntentRequest
-
-    init() {
-        intentRequest = OverridePresetsIntentRequest()
-    }
-
     @Parameter(
         title: LocalizedStringResource("Override", table: "ShortcutsDetail"),
         description: LocalizedStringResource("Override choice", table: "ShortcutsDetail")
@@ -44,7 +38,7 @@ import Foundation
                 presetToApply = preset
             } else {
                 presetToApply = try await $preset.requestDisambiguation(
-                    among: await intentRequest.fetchAndProcessOverrides(),
+                    among: await OverridePresetsIntentRequest().fetchAndProcessOverrides(),
                     dialog: IntentDialog(LocalizedStringResource("Select override", table: "ShortcutsDetail"))
                 )
             }
@@ -61,7 +55,7 @@ import Foundation
                 )
             }
 
-            if await intentRequest.enactOverride(presetToApply) {
+            if await OverridePresetsIntentRequest().enactOverride(presetToApply) {
                 return .result(
                     dialog: IntentDialog(
                         LocalizedStringResource(

+ 1 - 1
FreeAPS/Sources/Shortcuts/Override/CancelOverrideIntent.swift

@@ -1,7 +1,7 @@
 import AppIntents
 import Foundation
 
-@available(iOS 16.0, *) struct CancelOverrideIntent: AppIntent {
+struct CancelOverrideIntent: AppIntent {
     // Title of the action in the Shortcuts app
     static var title = LocalizedStringResource("Cancel override", table: "ShortcutsDetail")
 

+ 0 - 30
FreeAPS/Sources/Shortcuts/Override/ListOverridePresetIntent.swift

@@ -1,30 +0,0 @@
-import AppIntents
-import Foundation
-
-@available(iOS 16.0, *) struct ListOverridePresetsIntent: AppIntent {
-    // Title of the action in the Shortcuts app
-    static var title = LocalizedStringResource("List overrides", table: "ShortcutsDetail")
-
-    // Description of the action in the Shortcuts app
-    static var description = IntentDescription(
-        .init(
-            "Allow to list and choose a specific override",
-            table: "ShortcutsDetail"
-        )
-    )
-
-    @Parameter(
-        title: LocalizedStringResource("Override", table: "ShortcutsDetail"),
-        description: LocalizedStringResource("Override choice", table: "ShortcutsDetail")
-    ) var preset: OverridePreset?
-
-    static var parameterSummary: some ParameterSummary {
-        Summary("Choose the Override  \(\.$preset)", table: "ShortcutsDetail")
-    }
-
-    @MainActor func perform() async throws -> some ReturnsValue<OverridePreset> {
-        .result(
-            value: preset!
-        )
-    }
-}

+ 4 - 10
FreeAPS/Sources/Shortcuts/Override/OverridePresetEntity.swift

@@ -3,7 +3,7 @@ import Foundation
 import Intents
 import Swinject
 
-@available(iOS 16.0, *) struct OverridePreset: AppEntity, Identifiable {
+struct OverridePreset: AppEntity, Identifiable {
     static var defaultQuery = OverridePresetsQuery()
 
     var id: String
@@ -16,18 +16,12 @@ import Swinject
     static var typeDisplayRepresentation: TypeDisplayRepresentation = "Override"
 }
 
-@available(iOS 16.0, *) struct OverridePresetsQuery: EntityQuery {
-    internal var intentRequest: OverridePresetsIntentRequest
-
-    init() {
-        intentRequest = OverridePresetsIntentRequest()
-    }
-
+struct OverridePresetsQuery: EntityQuery {
     func entities(for identifiers: [OverridePreset.ID]) async throws -> [OverridePreset] {
-        await intentRequest.fetchIDs(identifiers)
+        await OverridePresetsIntentRequest().fetchIDs(identifiers)
     }
 
     func suggestedEntities() async throws -> [OverridePreset] {
-        await intentRequest.fetchAndProcessOverrides()
+        await OverridePresetsIntentRequest().fetchAndProcessOverrides()
     }
 }

+ 6 - 6
FreeAPS/Sources/Shortcuts/Override/OverridePresetsIntentRequest.swift

@@ -80,11 +80,11 @@ import UIKit
     @MainActor func enactOverride(_ preset: OverridePreset) async -> Bool {
         // Start background task
         var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid
-        backgroundTaskID = await UIApplication.shared.beginBackgroundTask(withName: "Override Upload") {
+        backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "Override Upload") {
             guard backgroundTaskID != .invalid else { return }
             Task {
                 // End background task when the time is about to expire
-                await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                UIApplication.shared.endBackgroundTask(backgroundTaskID)
             }
             backgroundTaskID = .invalid
         }
@@ -93,7 +93,7 @@ import UIKit
         defer {
             if backgroundTaskID != .invalid {
                 Task {
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }
@@ -147,11 +147,11 @@ import UIKit
 
         if shouldStartBackgroundTask {
             // Start background task
-            backgroundTaskID = await UIApplication.shared.beginBackgroundTask(withName: "Override Cancel") {
+            backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "Override Cancel") {
                 guard backgroundTaskID != .invalid else { return }
                 Task {
                     // End background task when the time is about to expire
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }
@@ -161,7 +161,7 @@ import UIKit
         defer {
             if shouldStartBackgroundTask, backgroundTaskID != .invalid {
                 Task {
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }

+ 1 - 2
FreeAPS/Sources/Shortcuts/State/ListStateIntent.swift

@@ -5,8 +5,6 @@ import Foundation
     // Title of the action in the Shortcuts app
     static var title: LocalizedStringResource = "List last state available with Trio"
 
-    var stateIntent = StateIntentRequest()
-
     // Description of the action in the Shortcuts app
     static var description = IntentDescription(
         "Allow to list the last Blood Glucose, trends, IOB and COB available in Trio"
@@ -18,6 +16,7 @@ import Foundation
 
     @MainActor func perform() async throws -> some ReturnsValue<StateResults> & ShowsSnippetView {
         let context = CoreDataStack.shared.persistentContainer.viewContext
+        let stateIntent = StateIntentRequest()
 
         let glucoseValues = try? stateIntent.getLastGlucose(onContext: context)
         let iob_cob_value = try? stateIntent.getIobAndCob(onContext: context)

+ 3 - 3
FreeAPS/Sources/Shortcuts/State/StateIntentRequest.swift

@@ -8,7 +8,7 @@ enum StateIntentError: Error {
     case NoIOBCOB
 }
 
-@available(iOS 16, *) struct StateResults: AppEntity {
+struct StateResults: AppEntity {
     static var defaultQuery = StateBGQuery()
 
     static var typeDisplayRepresentation: TypeDisplayRepresentation = "Trio State Result"
@@ -44,7 +44,7 @@ enum StateIntentError: Error {
     }
 }
 
-@available(iOS 16.0, *) struct StateBGQuery: EntityQuery {
+struct StateBGQuery: EntityQuery {
     func entities(for _: [StateResults.ID]) async throws -> [StateResults] {
         []
     }
@@ -54,7 +54,7 @@ enum StateIntentError: Error {
     }
 }
 
-@available(iOS 16.0, *) final class StateIntentRequest: BaseIntentsRequest {
+final class StateIntentRequest: BaseIntentsRequest {
     let moc = CoreDataStack.shared.newTaskContext()
 
     func getLastGlucose(onContext: NSManagedObjectContext) throws

+ 4 - 9
FreeAPS/Sources/Shortcuts/TempPresets/ApplyTempPresetIntent.swift

@@ -1,18 +1,12 @@
 import AppIntents
 import Foundation
 
-@available(iOS 16.0, *) struct ApplyTempPresetIntent: AppIntent {
+struct ApplyTempPresetIntent: AppIntent {
     // Title of the action in the Shortcuts app
-    static var title: LocalizedStringResource = "Apply a temporary target"
+    static var title: LocalizedStringResource = "Apply a Temporary Target"
 
     // Description of the action in the Shortcuts app
-    static var description = IntentDescription("Enable a temporary target")
-
-    internal var intentRequest: TempPresetsIntentRequest
-
-    init() {
-        intentRequest = TempPresetsIntentRequest()
-    }
+    static var description = IntentDescription("Enable a Temporary Target")
 
     @Parameter(title: "Preset") var preset: TempPreset?
 
@@ -46,6 +40,7 @@ import Foundation
 
     @MainActor func perform() async throws -> some ProvidesDialog {
         do {
+            let intentRequest = TempPresetsIntentRequest()
             let presetToApply: TempPreset
             if let preset = preset {
                 presetToApply = preset

+ 7 - 17
FreeAPS/Sources/Shortcuts/TempPresets/CancelTempPresetIntent.swift

@@ -1,27 +1,17 @@
 import AppIntents
 import Foundation
 
-@available(iOS 16.0, *) struct CancelTempPresetIntent: AppIntent {
+struct CancelTempPresetIntent: AppIntent {
     // Title of the action in the Shortcuts app
-    static var title: LocalizedStringResource = "Cancel a temporary Preset"
+    static var title: LocalizedStringResource = "Cancel a Temporary Target"
 
     // Description of the action in the Shortcuts app
-    static var description = IntentDescription("Cancel temporary preset.")
-
-    internal var intentRequest: TempPresetsIntentRequest
-
-    init() {
-        intentRequest = TempPresetsIntentRequest()
-    }
+    static var description = IntentDescription("Cancel Temporary Target.")
 
     @MainActor func perform() async throws -> some ProvidesDialog {
-        do {
-            try await intentRequest.cancelTempTarget()
-            return .result(
-                dialog: IntentDialog(stringLiteral: "Temporary Target canceled")
-            )
-        } catch {
-            throw error
-        }
+        await TempPresetsIntentRequest().cancelTempTarget()
+        return .result(
+            dialog: IntentDialog(stringLiteral: "Temporary Target canceled")
+        )
     }
 }

+ 0 - 25
FreeAPS/Sources/Shortcuts/TempPresets/ListTempPresetsIntent.swift

@@ -1,25 +0,0 @@
-import AppIntents
-import Foundation
-
-@available(iOS 16.0, *) struct ListTempPresetsIntent: AppIntent {
-    // Title of the action in the Shortcuts app
-    static var title: LocalizedStringResource = "Choose Temporary Presets"
-
-    // Description of the action in the Shortcuts app
-    static var description = IntentDescription(
-        "Allow to list and choose a specific temporary Preset.",
-        categoryName: "Navigation"
-    )
-
-    @Parameter(title: "Preset") var preset: TempPreset?
-
-    static var parameterSummary: some ParameterSummary {
-        Summary("Choose the Temp Target preset  \(\.$preset)")
-    }
-
-    @MainActor func perform() async throws -> some ReturnsValue<TempPreset> {
-        .result(
-            value: preset!
-        )
-    }
-}

+ 3 - 20
FreeAPS/Sources/Shortcuts/TempPresets/TempPresetIntent.swift

@@ -3,7 +3,7 @@ import Foundation
 import Intents
 import Swinject
 
-@available(iOS 16.0, *) struct TempPreset: AppEntity, Identifiable {
+struct TempPreset: AppEntity, Identifiable {
     static var defaultQuery = TempPresetsQuery()
 
     var id: UUID
@@ -17,31 +17,14 @@ import Swinject
     }
 
     static var typeDisplayRepresentation: TypeDisplayRepresentation = "Presets"
-
-//    static func convert(_ tempTarget: TempTarget) -> TempPreset {
-//        var tp = TempPreset(
-//            id: UUID(uuidString: tempTarget.id)!,
-//            name: tempTarget.displayName,
-//            duration: tempTarget.duration
-//        )
-//        tp.targetTop = tempTarget.targetTop
-//        tp.targetBottom = tempTarget.targetBottom
-//        return tp
-//    }
 }
 
 struct TempPresetsQuery: EntityQuery {
-    internal var intentRequest: TempPresetsIntentRequest
-
-    init() {
-        intentRequest = TempPresetsIntentRequest()
-    }
-
     func entities(for identifiers: [TempPreset.ID]) async throws -> [TempPreset] {
-        await intentRequest.fetchIDs(identifiers)
+        await TempPresetsIntentRequest().fetchIDs(identifiers)
     }
 
     func suggestedEntities() async throws -> [TempPreset] {
-        await intentRequest.fetchAndProcessTempTargets()
+        await TempPresetsIntentRequest().fetchAndProcessTempTargets()
     }
 }

+ 7 - 7
FreeAPS/Sources/Shortcuts/TempPresets/TempPresetsIntentRequest.swift

@@ -2,7 +2,7 @@ import CoreData
 import Foundation
 import UIKit
 
-@available(iOS 16.0, *) final class TempPresetsIntentRequest: BaseIntentsRequest {
+final class TempPresetsIntentRequest: BaseIntentsRequest {
     enum TempPresetsError: Error {
         case noTempTargetFound
         case noDurationDefined
@@ -87,11 +87,11 @@ import UIKit
     @MainActor func enactTempTarget(_ preset: TempPreset) async -> Bool {
         // Start background task
         var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid
-        backgroundTaskID = await UIApplication.shared.beginBackgroundTask(withName: "Override Upload") {
+        backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "Override Upload") {
             guard backgroundTaskID != .invalid else { return }
             Task {
                 // End background task when the time is about to expire
-                await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                UIApplication.shared.endBackgroundTask(backgroundTaskID)
             }
             backgroundTaskID = .invalid
         }
@@ -100,7 +100,7 @@ import UIKit
         defer {
             if backgroundTaskID != .invalid {
                 Task {
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }
@@ -158,11 +158,11 @@ import UIKit
 
         if shouldStartBackgroundTask {
             // Start background task
-            backgroundTaskID = await UIApplication.shared.beginBackgroundTask(withName: "TempTarget Cancel") {
+            backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "TempTarget Cancel") {
                 guard backgroundTaskID != .invalid else { return }
                 Task {
                     // End background task when the time is about to expire
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }
@@ -172,7 +172,7 @@ import UIKit
         defer {
             if shouldStartBackgroundTask, backgroundTaskID != .invalid {
                 Task {
-                    await UIApplication.shared.endBackgroundTask(backgroundTaskID)
+                    UIApplication.shared.endBackgroundTask(backgroundTaskID)
                 }
                 backgroundTaskID = .invalid
             }