File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,21 +143,22 @@ async fn main () -> Result<(), Box<dyn Error>> {
143143 }
144144
145145 let global_state = Arc :: new ( AppState :: default ( ) ) ;
146- let have_accounts = if !loaded_clients. is_empty ( ) {
146+ if !loaded_clients. is_empty ( ) {
147147 let mut accounts_lock = global_state. accounts . lock ( ) . await ;
148148 * accounts_lock = Some ( loaded_clients) ;
149- true
150- } else {
151- false
152- } ;
149+ }
153150
154151 let games = config. loaded_games ( ) . await ?;
155152
156153 let items = vec ! [ "Add account" , "Start farming" ] ;
157154 loop {
158- let select = if !games. is_empty ( ) && have_accounts {
155+ let accounts_lock = global_state. accounts . lock ( ) . await ;
156+ let has_accounts = accounts_lock. as_ref ( ) . map_or ( false , |accs| !accs. is_empty ( ) ) ;
157+ drop ( accounts_lock) ;
158+
159+ let select = if !games. is_empty ( ) && has_accounts {
159160 1
160- } else if !have_accounts {
161+ } else if !has_accounts {
161162 0
162163 } else {
163164 dialoguer:: Select :: new ( ) . with_prompt ( "Select option" ) . items ( & items) . default ( 0 ) . interact ( ) ?
You can’t perform that action at this time.
0 commit comments