Commit 8a6a1da 1 parent ae9eec7 commit 8a6a1da Copy full SHA for 8a6a1da
File tree 2 files changed +24
-8
lines changed
2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -131,10 +131,23 @@ impl Library {
131
131
}
132
132
}
133
133
134
+ pub fn could_reset_music_dir ( & self ) -> bool {
135
+ self . state ( )
136
+ . settings ( )
137
+ . read_observable ( )
138
+ . music_dir
139
+ . is_some ( )
140
+ }
141
+
134
142
pub fn reset_music_dir ( & self ) {
135
143
self . update_music_dir ( None ) ;
136
144
}
137
145
146
+ pub fn could_spawn_rescan_collection_task ( & self ) -> bool {
147
+ self . pending_rescan_collection_task . is_none ( )
148
+ && self . state ( ) . collection ( ) . read_observable ( ) . is_ready ( )
149
+ }
150
+
138
151
pub fn spawn_rescan_collection_task ( & mut self , rt : & tokio:: runtime:: Handle ) -> bool {
139
152
if let Some ( rescan_collection_task) = self . pending_rescan_collection_task . as_ref ( ) {
140
153
if rescan_collection_task. is_finished ( ) {
@@ -165,10 +178,6 @@ impl Library {
165
178
changed
166
179
}
167
180
168
- pub const fn has_pending_rescan_collection_task ( & self ) -> bool {
169
- self . pending_rescan_collection_task . is_some ( )
170
- }
171
-
172
181
pub fn abort_pending_rescan_collection_task ( & mut self ) -> Option < SynchronizeVfsTask > {
173
182
let pending_rescan_collection_task = self . pending_rescan_collection_task . take ( ) ;
174
183
let Some ( rescan_collection_task) = pending_rescan_collection_task else {
@@ -200,6 +209,14 @@ impl Library {
200
209
}
201
210
}
202
211
212
+ pub fn could_spawn_fetch_more_track_search_results ( & self ) -> bool {
213
+ self . state
214
+ . track_search ( )
215
+ . read_observable ( )
216
+ . can_fetch_more ( )
217
+ . unwrap_or ( false )
218
+ }
219
+
203
220
pub fn spawn_fetch_more_track_search_results < E > (
204
221
& self ,
205
222
tokio_rt : & tokio:: runtime:: Handle ,
Original file line number Diff line number Diff line change @@ -476,7 +476,7 @@ impl eframe::App for App {
476
476
ui. label ( "" ) ;
477
477
if ui
478
478
. add_enabled (
479
- settings_state . music_dir . is_some ( ) ,
479
+ self . library . could_reset_music_dir ( ) ,
480
480
Button :: new ( "Reset music directory" ) ,
481
481
)
482
482
. clicked ( )
@@ -521,8 +521,7 @@ impl eframe::App for App {
521
521
ui. label ( "" ) ;
522
522
if ui
523
523
. add_enabled (
524
- collection_state. is_ready ( )
525
- && !self . library . has_pending_rescan_collection_task ( ) ,
524
+ self . library . could_spawn_rescan_collection_task ( ) ,
526
525
Button :: new ( "Rescan collection" ) ,
527
526
)
528
527
. clicked ( )
@@ -556,7 +555,7 @@ impl eframe::App for App {
556
555
. show ( ui, |ui| {
557
556
if ui
558
557
. add_enabled (
559
- track_search_state . can_fetch_more ( ) . unwrap_or ( false ) ,
558
+ self . library . could_spawn_fetch_more_track_search_results ( ) ,
560
559
Button :: new ( "Fetch more" ) ,
561
560
)
562
561
. clicked ( )
You can’t perform that action at this time.
0 commit comments