Krolyxon
Commit 8c4d19f

rmptui8c4d19f

fix #2

Author
krolxon
Date
2024-05-12 20:18 +0530
Parent
3d569cb
Commit
8c4d19f84961bba2f34726e491daf2fa2d981e1d

+12 −0

1 file changed

  1. M src/ui.rs +12 −0
M src/ui.rs View
@@ -343,6 +343,18 @@ fn draw_playlist_viewer(frame: &mut Frame, app: &mut App, area: Rect) {
343343 frame.render_stateful_widget(list, layouts[0], &mut state);
344344
345345 // Playlist viewer
346+
347+ // Handle if there are no playlists in the mpd database
348+ if app.pl_list.list.is_empty() {
349+ let title = Block::default()
350+ .title(Title::from("No Playlists Found".red().bold()))
351+ .title_alignment(Alignment::Center)
352+ .borders(Borders::ALL);
353+ frame.render_widget(Clear, area); //this clears out the background
354+ frame.render_widget(title, area);
355+ return;
356+ }
357+
346358 let pl_name = app.pl_list.list.get(app.pl_list.index).unwrap();
347359 let songs = app.conn.conn.playlist(pl_name).unwrap();
348360 let rows = songs.iter().map(|song| {