Skip to content

Commit

Permalink
Fix for bug in 33fa7b9
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Oct 7, 2024
1 parent d76f5e9 commit 38d1c75
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
15 changes: 14 additions & 1 deletion psst-gui/src/controller/nav.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
cmd,
data::{AppState, Nav, SpotifyUrl},
ui::{album, artist, library, playlist, recommend, search, show},
ui::{album, artist, library, lyrics, playlist, recommend, search, show},
};
use druid::widget::{prelude::*, Controller};

Expand Down Expand Up @@ -97,6 +97,19 @@ where
ctx.set_handled();
self.load_route_data(ctx, data);
}
Event::Command(cmd) if cmd.is(cmd::TOGGLE_LYRICS) => {
match data.nav {
Nav::Lyrics => data.navigate_back(),
_ => {
data.navigate(&Nav::Lyrics);
if let Some(np) = data.playback.now_playing.as_ref() {
ctx.submit_command(lyrics::SHOW_LYRICS.with(np.clone()));
}
}
}
ctx.set_handled();
self.load_route_data(ctx, data);
}
Event::MouseDown(cmd) if cmd.button.is_x1() => {
data.navigate_back();
ctx.set_handled();
Expand Down
2 changes: 1 addition & 1 deletion psst-gui/src/controller/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ where
}
Event::Command(cmd) if cmd.is(cmd::SKIP_TO_POSITION) => {
let location = cmd.get_unchecked(cmd::SKIP_TO_POSITION);
self.seek(Duration::from_millis(location.clone()));
self.seek(Duration::from_millis(*location));

ctx.set_handled();
}
Expand Down
18 changes: 2 additions & 16 deletions psst-gui/src/ui/lyrics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use druid::widget::{Container, CrossAxisAlignment, Flex, Label, LineBreaking, List, Scroll};
use druid::{EventCtx, Insets, LensExt, Selector, Widget, WidgetExt};
use druid::{Insets, LensExt, Selector, Widget, WidgetExt};

use crate::cmd;
use crate::data::{AppState, Ctx, Nav, NowPlaying, Playable, TrackLines};
use crate::data::{AppState, Ctx, NowPlaying, Playable, TrackLines};
use crate::widget::MyWidgetExt;
use crate::{webapi::WebApi, widget::Async};

Expand All @@ -25,9 +25,6 @@ pub fn lyrics_widget() -> impl Widget<AppState> {
.center(),
)
.vertical()
.on_command(cmd::TOGGLE_LYRICS, |ctx, _, data| {
toggle_lyrics(data, ctx);
})
}

fn track_info_widget() -> impl Widget<AppState> {
Expand Down Expand Up @@ -95,14 +92,3 @@ fn track_lyrics_widget() -> impl Widget<AppState> {
|_, data, r| data.lyrics.update(((), r.1)),
)
}

pub fn toggle_lyrics(data: &mut AppState, ctx: &mut EventCtx) {
if data.nav == Nav::Lyrics {
ctx.submit_command(cmd::NAVIGATE_BACK.with(1));
} else {
if let Some(now_playing) = &data.playback.now_playing {
ctx.submit_command(SHOW_LYRICS.with(now_playing.clone()));
ctx.submit_command(cmd::NAVIGATE.with(Nav::Lyrics));
}
}
}
2 changes: 1 addition & 1 deletion psst-gui/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub mod artist;
pub mod episode;
pub mod find;
pub mod home;
pub mod lyrics;
pub mod library;
pub mod lyrics;
pub mod menu;
pub mod playable;
pub mod playback;
Expand Down

0 comments on commit 38d1c75

Please sign in to comment.