@@ -17,7 +17,9 @@ import ProChatTabs
1717import ChatTabPersistent
1818#endif
1919
20- struct GUI : ReducerProtocol {
20+ @Reducer
21+ struct GUI {
22+ @ObservableState
2123 struct State : Equatable {
2224 var suggestionWidgetState = WidgetFeature . State ( )
2325
@@ -75,15 +77,15 @@ struct GUI: ReducerProtocol {
7577 case updateChatTabOrder
7678 }
7779
78- var body : some ReducerProtocol < State , Action > {
80+ var body : some ReducerOf < Self > {
7981 CombineReducers {
80- Scope ( state: \. suggestionWidgetState, action: / Action . suggestionWidget) {
82+ Scope ( state: \. suggestionWidgetState, action: \ . suggestionWidget) {
8183 WidgetFeature ( )
8284 }
8385
8486 Scope (
8587 state: \. chatTabGroup,
86- action: / Action . suggestionWidget . . / WidgetFeature . Action . chatPanel
88+ action: \ . suggestionWidget. chatPanel
8789 ) {
8890 Reduce { _, action in
8991 switch action {
@@ -115,7 +117,7 @@ struct GUI: ReducerProtocol {
115117 }
116118
117119 #if canImport(ChatTabPersistent)
118- Scope ( state: \. persistentState, action: / Action . persistent) {
120+ Scope ( state: \. persistentState, action: \ . persistent) {
119121 ChatTabPersistent ( )
120122 }
121123 #endif
@@ -251,10 +253,9 @@ struct GUI: ReducerProtocol {
251253
252254@MainActor
253255public final class GraphicalUserInterfaceController {
254- private let store : StoreOf < GUI >
256+ let store : StoreOf < GUI >
255257 let widgetController : SuggestionWidgetController
256258 let widgetDataSource : WidgetDataSource
257- let viewStore : ViewStoreOf < GUI >
258259 let chatTabPool : ChatTabPool
259260
260261 class WeakStoreHolder {
@@ -289,18 +290,17 @@ public final class GraphicalUserInterfaceController {
289290 }
290291 let store = StoreOf < GUI > (
291292 initialState: . init( ) ,
292- reducer: GUI ( ) ,
293- prepareDependencies : setupDependency
293+ reducer: { GUI ( ) } ,
294+ withDependencies : setupDependency
294295 )
295296 self . store = store
296297 self . chatTabPool = chatTabPool
297- viewStore = ViewStore ( store)
298298 widgetDataSource = . init( )
299299
300300 widgetController = SuggestionWidgetController (
301301 store: store. scope (
302302 state: \. suggestionWidgetState,
303- action: GUI . Action . suggestionWidget
303+ action: \ . suggestionWidget
304304 ) ,
305305 chatTabPool: chatTabPool,
306306 dependency: suggestionDependency
@@ -309,8 +309,7 @@ public final class GraphicalUserInterfaceController {
309309 chatTabPool. createStore = { id in
310310 store. scope (
311311 state: { state in
312- state. chatTabGroup. tabInfo [ id: id]
313- ?? . init( id: id, title: " " )
312+ state. chatTabGroup. tabInfo [ id: id] ?? . init( id: id, title: " " )
314313 } ,
315314 action: { childAction in
316315 . suggestionWidget( . chatPanel( . chatTab( id: id, action: childAction) ) )
@@ -321,8 +320,8 @@ public final class GraphicalUserInterfaceController {
321320 suggestionDependency. suggestionWidgetDataSource = widgetDataSource
322321 suggestionDependency. onOpenChatClicked = { [ weak self] in
323322 Task { [ weak self] in
324- await self ? . viewStore . send ( . createChatGPTChatTabIfNeeded) . finish ( )
325- self ? . viewStore . send ( . openChatPanel( forceDetach: false ) )
323+ await self ? . store . send ( . createChatGPTChatTabIfNeeded) . finish ( )
324+ self ? . store . send ( . openChatPanel( forceDetach: false ) )
326325 }
327326 }
328327 suggestionDependency. onCustomCommandClicked = { command in
@@ -339,8 +338,8 @@ public final class GraphicalUserInterfaceController {
339338
340339 public func openGlobalChat( ) {
341340 Task {
342- await self . viewStore . send ( . createChatGPTChatTabIfNeeded) . finish ( )
343- viewStore . send ( . openChatPanel( forceDetach: true ) )
341+ await self . store . send ( . createChatGPTChatTabIfNeeded) . finish ( )
342+ store . send ( . openChatPanel( forceDetach: true ) )
344343 }
345344 }
346345}
0 commit comments