From a3d22b335bdcda2a78e83d987128ce72581ac717 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sat, 6 Apr 2019 00:05:17 +0200 Subject: [PATCH] Fix repeat button --- src/Applications/UI/Ports.elm | 8 ++++---- src/Applications/UI/Queue.elm | 5 ++++- src/Applications/UI/UserData.elm | 6 +++++- src/Javascript/index.js | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Applications/UI/Ports.elm b/src/Applications/UI/Ports.elm index 663fb975..27cdb145 100644 --- a/src/Applications/UI/Ports.elm +++ b/src/Applications/UI/Ports.elm @@ -1,4 +1,4 @@ -port module UI.Ports exposing (activeQueueItemChanged, activeQueueItemEnded, adjustEqualizerSetting, fromAlien, giveBrain, nudgeBrain, pause, play, seek, setAudioDuration, setAudioHasStalled, setAudioIsLoading, setAudioIsPlaying, toBrain, toggleRepeat, unstall) +port module UI.Ports exposing (activeQueueItemChanged, activeQueueItemEnded, adjustEqualizerSetting, fromAlien, giveBrain, nudgeBrain, pause, play, seek, setAudioDuration, setAudioHasStalled, setAudioIsLoading, setAudioIsPlaying, setRepeat, toBrain, unstall) import Alien import Json.Encode as Json @@ -24,13 +24,13 @@ port play : () -> Cmd msg port seek : Float -> Cmd msg -port unstall : () -> Cmd msg +port setRepeat : Bool -> Cmd msg -port toBrain : Alien.Event -> Cmd msg +port unstall : () -> Cmd msg -port toggleRepeat : Bool -> Cmd msg +port toBrain : Alien.Event -> Cmd msg diff --git a/src/Applications/UI/Queue.elm b/src/Applications/UI/Queue.elm index 55c0a733..98840fc3 100644 --- a/src/Applications/UI/Queue.elm +++ b/src/Applications/UI/Queue.elm @@ -175,7 +175,10 @@ update msg model = -- Settings ------------------------------------ ToggleRepeat -> - ( { model | repeat = not model.repeat }, Cmd.none, Just [ SaveEnclosedUserData ] ) + ( { model | repeat = not model.repeat } + , Ports.setRepeat (not model.repeat) + , Just [ SaveEnclosedUserData ] + ) ToggleShuffle -> { model | shuffle = not model.shuffle } diff --git a/src/Applications/UI/UserData.elm b/src/Applications/UI/UserData.elm index 8eadfb22..bf3445aa 100644 --- a/src/Applications/UI/UserData.elm +++ b/src/Applications/UI/UserData.elm @@ -19,6 +19,7 @@ import UI.Backdrop import UI.Core import UI.Equalizer as Equalizer import UI.Notifications +import UI.Ports as Ports import UI.Reply as UI import UI.Sources as Sources import UI.Tracks as Tracks @@ -197,7 +198,10 @@ importEnclosed value model = , queue = newQueue , tracks = newTracks } - , Cmd.map UI.Core.EqualizerMsg (Equalizer.adjustAllKnobs newEqualizer) + , Cmd.batch + [ Cmd.map UI.Core.EqualizerMsg (Equalizer.adjustAllKnobs newEqualizer) + , Ports.setRepeat data.repeat + ] , Nothing ) diff --git a/src/Javascript/index.js b/src/Javascript/index.js index 27d54228..df00286f 100644 --- a/src/Javascript/index.js +++ b/src/Javascript/index.js @@ -98,6 +98,11 @@ app.ports.seek.subscribe(percentage => { }) +app.ports.setRepeat.subscribe(repeat => { + orchestrion.repeat = repeat +}) + + app.ports.unstall.subscribe(_ => { if (orchestrion.audio) { clearTimeout(orchestrion.unstallTimeoutId) -- 2.51.2