@@ -25,8 +25,7 @@ use cosmic::app::context_drawer::ContextDrawer;
25
25
use cosmic:: app:: DbusActivationMessage ;
26
26
#[ cfg( feature = "wayland" ) ]
27
27
use cosmic:: cctk:: { sctk:: output:: OutputInfo , wayland_client:: protocol:: wl_output:: WlOutput } ;
28
- use cosmic:: iced:: futures:: SinkExt ;
29
- use cosmic:: iced:: { stream, Subscription } ;
28
+ use cosmic:: iced:: Subscription ;
30
29
use cosmic:: widget:: { self , button, row, text_input} ;
31
30
use cosmic:: {
32
31
app:: { Core , Task } ,
@@ -65,7 +64,6 @@ pub struct SettingsApp {
65
64
config : Config ,
66
65
core : Core ,
67
66
nav_model : nav_bar:: Model ,
68
- page_sender : Option < tokio:: sync:: mpsc:: Sender < crate :: pages:: Message > > ,
69
67
pages : page:: Binder < crate :: pages:: Message > ,
70
68
search_active : bool ,
71
69
search_id : cosmic:: widget:: Id ,
@@ -144,7 +142,6 @@ impl SettingsApp {
144
142
#[ derive( Clone , Debug ) ]
145
143
pub enum Message {
146
144
CloseContextDrawer ,
147
- DelayedInit ( page:: Entity ) ,
148
145
#[ cfg( feature = "wayland" ) ]
149
146
DesktopInfo ,
150
147
Error ( String ) ,
@@ -158,7 +155,6 @@ pub enum Message {
158
155
PageMessage ( crate :: pages:: Message ) ,
159
156
#[ cfg( feature = "wayland" ) ]
160
157
PanelConfig ( CosmicPanelConfig ) ,
161
- RegisterSubscriptionSender ( tokio:: sync:: mpsc:: Sender < pages:: Message > ) ,
162
158
SearchActivate ,
163
159
SearchChanged ( String ) ,
164
160
SearchClear ,
@@ -193,7 +189,6 @@ impl cosmic::Application for SettingsApp {
193
189
config,
194
190
core,
195
191
nav_model : nav_bar:: Model :: default ( ) ,
196
- page_sender : None ,
197
192
pages : page:: Binder :: default ( ) ,
198
193
search_active : false ,
199
194
search_id : cosmic:: widget:: Id :: unique ( ) ,
@@ -228,7 +223,8 @@ impl cosmic::Application for SettingsApp {
228
223
}
229
224
. unwrap_or ( desktop_id) ;
230
225
231
- ( app, cosmic:: task:: message ( Message :: DelayedInit ( active_id) ) )
226
+ let task = app. activate_page ( active_id) ;
227
+ ( app, task)
232
228
}
233
229
234
230
fn nav_model ( & self ) -> Option < & nav_bar:: Model > {
@@ -286,22 +282,6 @@ impl cosmic::Application for SettingsApp {
286
282
287
283
fn subscription ( & self ) -> Subscription < Message > {
288
284
Subscription :: batch ( vec ! [
289
- // Creates a channel that listens to messages from pages.
290
- // The sender is given back to the application so that it may pass it on.
291
- Subscription :: run_with_id(
292
- std:: any:: TypeId :: of:: <Self >( ) ,
293
- stream:: channel( 4 , move |mut output| async move {
294
- let ( tx, mut rx) = tokio:: sync:: mpsc:: channel:: <pages:: Message >( 4 ) ;
295
-
296
- let _res = output. send( Message :: RegisterSubscriptionSender ( tx) ) . await ;
297
-
298
- while let Some ( event) = rx. recv( ) . await {
299
- let _res = output. send( Message :: PageMessage ( event) ) . await ;
300
- }
301
-
302
- futures:: future:: pending:: <( ) >( ) . await ;
303
- } ) ,
304
- ) ,
305
285
#[ cfg( feature = "ashpd" ) ]
306
286
crate :: subscription:: daytime( ) . map( |daytime| {
307
287
Message :: PageMessage ( pages:: Message :: Appearance ( appearance:: Message :: Daytime (
@@ -754,19 +734,6 @@ impl cosmic::Application for SettingsApp {
754
734
Message :: Error ( error) => {
755
735
tracing:: error!( error, "error occurred" ) ;
756
736
}
757
-
758
- Message :: RegisterSubscriptionSender ( sender) => {
759
- self . page_sender = Some ( sender) ;
760
- }
761
-
762
- // It is necessary to delay init to allow time for the page sender to be initialized
763
- Message :: DelayedInit ( active_id) => {
764
- if self . page_sender . is_none ( ) {
765
- return cosmic:: task:: message ( Message :: DelayedInit ( active_id) ) ;
766
- }
767
-
768
- return self . activate_page ( active_id) ;
769
- }
770
737
}
771
738
772
739
Task :: none ( )
@@ -860,17 +827,11 @@ impl SettingsApp {
860
827
self . search_clear ( ) ;
861
828
self . search_active = false ;
862
829
self . activate_navbar ( page) ;
863
-
864
- let sender = self
865
- . page_sender
866
- . clone ( )
867
- . expect ( "sender should be available" ) ;
868
-
869
830
self . loaded_pages . insert ( page) ;
870
831
871
832
let page_task = self
872
833
. pages
873
- . on_enter ( page, sender )
834
+ . on_enter ( page)
874
835
. map ( Message :: PageMessage )
875
836
. map ( Into :: into) ;
876
837
@@ -1032,11 +993,9 @@ impl SettingsApp {
1032
993
}
1033
994
}
1034
995
1035
- if let Some ( ref sender) = self . page_sender {
1036
- for page in load {
1037
- self . loaded_pages . insert ( page) ;
1038
- tasks. push ( self . pages . on_enter ( page, sender. clone ( ) ) ) ;
1039
- }
996
+ for page in load {
997
+ self . loaded_pages . insert ( page) ;
998
+ tasks. push ( self . pages . on_enter ( page) ) ;
1040
999
}
1041
1000
1042
1001
for page in unload {
0 commit comments