@@ -217,30 +217,6 @@ impl Pane for PlaylistsPane {
217
217
self . stack = DirStack :: new ( data) ;
218
218
self . prepare_preview ( context) ?;
219
219
}
220
- ( REINIT , MpdQueryResult :: SongsList { data : songs, .. } ) => {
221
- // Select the same song by filename or index as before
222
- let old_viewport_len = self . stack . current ( ) . state . viewport_len ( ) ;
223
-
224
- self . stack_mut ( )
225
- . replace ( songs. into_iter ( ) . map ( DirOrSong :: Song ) . collect ( ) ) ;
226
- self . prepare_preview ( context) ?;
227
- if let Some ( ( idx, song) ) = & self . selected_song {
228
- let idx_to_select = self
229
- . stack
230
- . current ( )
231
- . items
232
- . iter ( )
233
- . find_position ( |item| item. as_path ( ) == song)
234
- . map_or ( * idx, |( idx, _) | idx) ;
235
- self . stack . current_mut ( ) . state . set_viewport_len ( old_viewport_len) ;
236
- self . stack
237
- . current_mut ( )
238
- . state
239
- . select ( Some ( idx_to_select) , context. config . scrolloff ) ;
240
- } ;
241
- self . prepare_preview ( context) ?;
242
- context. render ( ) ?;
243
- }
244
220
( REINIT , MpdQueryResult :: DirOrSong { data, .. } ) => {
245
221
let mut new_stack = DirStack :: new ( data) ;
246
222
let old_viewport_len = self . stack . current ( ) . state . viewport_len ( ) ;
@@ -268,10 +244,33 @@ impl Pane for PlaylistsPane {
268
244
if let Some ( ( idx, DirOrSong :: Song ( song) ) ) = self . stack ( ) . current ( ) . selected_with_idx ( ) {
269
245
self . selected_song = Some ( ( idx, song. as_path ( ) . to_owned ( ) ) ) ;
270
246
}
247
+ let playlist = playlist_name. to_owned ( ) ;
271
248
self . stack = new_stack;
272
- self . open_or_play ( false , context, REINIT ) ?;
273
249
self . stack_mut ( ) . current_mut ( ) . state . set_content_len ( old_content_len) ;
274
250
self . stack_mut ( ) . current_mut ( ) . state . set_viewport_len ( old_viewport_len) ;
251
+
252
+ let songs =
253
+ context. query_sync ( move |client| Ok ( client. list_playlist_info ( & playlist, None ) ?) ) ?;
254
+
255
+ self . stack_mut ( ) . push ( songs. into_iter ( ) . map ( DirOrSong :: Song ) . collect ( ) ) ;
256
+ self . prepare_preview ( context) ?;
257
+ if let Some ( ( idx, song) ) = & self . selected_song {
258
+ let idx_to_select = self
259
+ . stack
260
+ . current ( )
261
+ . items
262
+ . iter ( )
263
+ . find_position ( |item| item. as_path ( ) == song)
264
+ . map_or ( * idx, |( idx, _) | idx) ;
265
+ self . stack . current_mut ( ) . state . set_viewport_len ( old_viewport_len) ;
266
+ self . stack
267
+ . current_mut ( )
268
+ . state
269
+ . select ( Some ( idx_to_select) , context. config . scrolloff ) ;
270
+ } ;
271
+ self . stack_mut ( ) . clear_preview ( ) ;
272
+ self . prepare_preview ( context) ?;
273
+ context. render ( ) ?;
275
274
}
276
275
[ ] => {
277
276
let Some ( ( selected_idx, selected_playlist) ) = self
0 commit comments