@@ -66,6 +66,7 @@ pub struct NxShell {
6666 pub clipboard : ClipboardContext ,
6767 pub db : DbConn ,
6868 pub opts : NxShellOptions ,
69+ pub toasts : Toasts ,
6970}
7071
7172impl NxShell {
@@ -89,6 +90,9 @@ impl NxShell {
8990 ..Default :: default ( )
9091 } ,
9192 state_manager,
93+ toasts : Toasts :: new ( )
94+ . anchor ( Align2 :: CENTER_CENTER , ( 10.0 , 10.0 ) )
95+ . direction ( egui:: Direction :: TopDown ) ,
9296 } )
9397 }
9498
@@ -112,10 +116,6 @@ impl eframe::App for NxShell {
112116 fn update ( & mut self , ctx : & egui:: Context , _frame : & mut eframe:: Frame ) {
113117 self . recv_event ( ) ;
114118
115- let mut toasts = Toasts :: new ( )
116- . anchor ( Align2 :: CENTER_CENTER , ( 10.0 , 10.0 ) )
117- . direction ( egui:: Direction :: TopDown ) ;
118-
119119 egui:: TopBottomPanel :: top ( "main_top_panel" ) . show ( ctx, |ui| {
120120 self . menubar ( ui) ;
121121 } ) ;
@@ -131,7 +131,7 @@ impl eframe::App for NxShell {
131131
132132 self . search_sessions ( ui) ;
133133 ui. separator ( ) ;
134- self . list_sessions ( ctx, ui, & mut toasts ) ;
134+ self . list_sessions ( ctx, ui) ;
135135 } ) ;
136136 egui:: TopBottomPanel :: bottom ( "main_bottom_panel" ) . show ( ctx, |ui| {
137137 ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: TOP ) , |ui| {
@@ -141,14 +141,14 @@ impl eframe::App for NxShell {
141141
142142 if * self . opts . show_add_session_modal . borrow ( ) {
143143 self . opts . surrender_focus ( ) ;
144- self . show_add_session_window ( ctx, & mut toasts ) ;
144+ self . show_add_session_window ( ctx) ;
145145 }
146146
147147 egui:: CentralPanel :: default ( ) . show ( ctx, |_ui| {
148148 self . tab_view ( ctx) ;
149149 } ) ;
150150
151- toasts. show ( ctx) ;
151+ self . toasts . show ( ctx) ;
152152 }
153153}
154154
@@ -165,7 +165,7 @@ impl NxShell {
165165 }
166166 }
167167
168- fn list_sessions ( & mut self , ctx : & egui:: Context , ui : & mut egui:: Ui , toasts : & mut Toasts ) {
168+ fn list_sessions ( & mut self , ctx : & egui:: Context , ui : & mut egui:: Ui ) {
169169 if let Some ( sessions) = self . state_manager . sessions . take ( ) {
170170 for ( group, sessions) in sessions. iter ( ) {
171171 CollapsingHeader :: new ( group)
@@ -183,12 +183,12 @@ impl NxShell {
183183 if let Err ( err) =
184184 self . add_shell_tab_with_secret ( ctx, session)
185185 {
186- toasts. add ( error_toast ( err. to_string ( ) ) ) ;
186+ self . toasts . add ( error_toast ( err. to_string ( ) ) ) ;
187187 }
188188 }
189189 Ok ( None ) => { }
190190 Err ( err) => {
191- toasts. add ( error_toast ( err. to_string ( ) ) ) ;
191+ self . toasts . add ( error_toast ( err. to_string ( ) ) ) ;
192192 }
193193 }
194194 } else if response. secondary_clicked ( ) {
0 commit comments