forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHostApp.swift
More file actions
51 lines (44 loc) · 1.31 KB
/
Copy pathHostApp.swift
File metadata and controls
51 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import Client
import ComposableArchitecture
import Foundation
#if canImport(LicenseManagement)
import LicenseManagement
#endif
struct HostApp: ReducerProtocol {
struct State: Equatable {
var general = General.State()
}
enum Action: Equatable {
case appear
case informExtensionServiceAboutLicenseKeyChange
case general(General.Action)
}
@Dependency(\.toast) var toast
var body: some ReducerProtocol<State, Action> {
Scope(state: \.general, action: /Action.general) {
General()
}
Reduce { _, action in
switch action {
case .appear:
return .none
case .informExtensionServiceAboutLicenseKeyChange:
#if canImport(LicenseManagement)
return .run { _ in
let service = try getService()
do {
try await service
.postNotification(name: Notification.Name.licenseKeyChanged.rawValue)
} catch {
toast(error.localizedDescription, .error)
}
}
#else
return .none
#endif
case .general:
return .none
}
}
}
}