File tree Expand file tree Collapse file tree 6 files changed +48
-16
lines changed
Expand file tree Collapse file tree 6 files changed +48
-16
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ let package = Package(
117117 " GitHubCopilotService " ,
118118 " CodeiumService " ,
119119 " LaunchAgentManager " ,
120+ " PlusFeatureFlag " ,
120121 . product( name: " Toast " , package : " Tool " ) ,
121122 . product( name: " SuggestionModel " , package : " Tool " ) ,
122123 . product( name: " MarkdownUI " , package : " swift-markdown-ui " ) ,
@@ -266,8 +267,9 @@ let package = Package(
266267 . target(
267268 name: " PlusFeatureFlag " ,
268269 dependencies: [
269- . product( name: " LicenseManagement " , package : " Tool " ) ,
270- ]
270+ ] . pro ( [
271+ " LicenseManagement "
272+ ] )
271273 ) ,
272274
273275 // MARK: - GitHub Copilot
Original file line number Diff line number Diff line change @@ -18,12 +18,16 @@ struct CustomCommandFeature: ReducerProtocol {
1818 case deleteCommand( CustomCommand )
1919 }
2020
21- @Dependency ( \. toastController ) var toastController
21+ @Dependency ( \. toast ) var toast
2222
2323 var body : some ReducerProtocol < State , Action > {
2424 Reduce { state, action in
2525 switch action {
2626 case . createNewCommand:
27+ if settings. customCommands. count >= 10 {
28+ toast ( " Upgrade to Plus to add more commands " , . info)
29+ return . none
30+ }
2731 state. editCustomCommand = EditCustomCommand . State ( nil )
2832 return . none
2933 case let . editCommand( command) :
Original file line number Diff line number Diff line change 11import ComposableArchitecture
22import MarkdownUI
3+ import PlusFeatureFlag
34import Preferences
45import SwiftUI
56
@@ -72,7 +73,12 @@ struct CustomCommandView: View {
7273 Button ( action: {
7374 store. send ( . createNewCommand)
7475 } ) {
75- Text ( Image ( systemName: " plus.circle.fill " ) ) + Text( " New Command " )
76+ if isFeatureAvailable ( \. unlimitedCustomCommands) {
77+ Text ( Image ( systemName: " plus.circle.fill " ) ) + Text( " New Command " )
78+ } else {
79+ Text ( Image ( systemName: " plus.circle.fill " ) ) +
80+ Text( " New Command ( \( settings. customCommands. count) /10) " )
81+ }
7682 }
7783 . buttonStyle ( . plain)
7884 . padding ( )
Original file line number Diff line number Diff line change @@ -29,17 +29,19 @@ struct HostApp: ReducerProtocol {
2929 case . appear:
3030 return . none
3131 case . informExtensionServiceAboutLicenseKeyChange:
32+ #if canImport(LicenseManagement)
3233 return . run { _ in
33- #if canImport(LicenseManagement)
3434 let service = try getService ( )
3535 do {
3636 try await service
3737 . postNotification ( name: Notification . Name. licenseKeyChanged. rawValue)
3838 } catch {
3939 toast ( error. localizedDescription, . error)
4040 }
41- #endif
4241 }
42+ #else
43+ return . none
44+ #endif
4345 case . general:
4446 return . none
4547 }
Original file line number Diff line number Diff line change 1- import Dependencies
21import Foundation
32import SwiftUI
43
54#if canImport(LicenseManagement)
65
76import LicenseManagement
87
8+ #else
9+
10+ public typealias PlusFeatureFlag = Int
11+
12+ public struct PlusFeatureFlags {
13+ public let browserTab = 1
14+ public let unlimitedCustomCommands = 1
15+ init ( ) { }
16+ }
17+
18+ #endif
19+
920public func withFeatureEnabled(
1021 _ flag: KeyPath < PlusFeatureFlags , PlusFeatureFlag > ,
1122 then: ( ) throws -> Void
1223) rethrows {
24+ #if canImport(LicenseManagement)
1325 try LicenseManagement . withFeatureEnabled ( flag, then: then)
26+ #endif
1427}
1528
1629public func withFeatureEnabled(
1730 _ flag: KeyPath < PlusFeatureFlags , PlusFeatureFlag > ,
1831 then: ( ) async throws -> Void
1932) async rethrows {
33+ #if canImport(LicenseManagement)
2034 try await LicenseManagement . withFeatureEnabled ( flag, then: then)
35+ #endif
2136}
2237
2338public func isFeatureAvailable( _ flag: KeyPath < PlusFeatureFlags , PlusFeatureFlag > ) -> Bool {
24- LicenseManagement . isFeatureAvailable ( flag)
39+ #if canImport(LicenseManagement)
40+ return LicenseManagement . isFeatureAvailable ( flag)
41+ #else
42+ return false
43+ #endif
2544}
2645
27- #endif
Original file line number Diff line number Diff line change 7878 "name" : "ChatServiceTests"
7979 }
8080 },
81- {
82- "target" : {
83- "containerPath" : "container:Core",
84- "identifier" : "SharedUIComponentsTests",
85- "name" : "SharedUIComponentsTests"
86- }
87- },
8881 {
8982 "target" : {
9083 "containerPath" : "container:Tool",
10598 "identifier" : "SuggestionModelTests",
10699 "name" : "SuggestionModelTests"
107100 }
101+ },
102+ {
103+ "target" : {
104+ "containerPath" : "container:Tool",
105+ "identifier" : "SharedUIComponentsTests",
106+ "name" : "SharedUIComponentsTests"
107+ }
108108 }
109109 ],
110110 "version" : 1
You can’t perform that action at this time.
0 commit comments