···33import Alfred
44import Alien
55import Browser
66+import Browser.Events
67import Browser.Navigation as Nav
78import Chunky exposing (..)
89import Common exposing (Switch(..))
···1011import Css exposing (url)
1112import Debouncer.Basic as Debouncer
1213import Json.Decode
1414+import Keyboard
1315import LastFm
1416import Maybe.Extra as Maybe
1517import Notifications
···2830import UI.Audio.Types as Audio
2931import UI.Authentication as Authentication
3032import UI.Authentication.ContextMenu as Authentication
3333+import UI.Authentication.State as Authentication
3134import UI.Backdrop as Backdrop
3232-import UI.Common.State exposing (showNotification, showNotificationWithModel)
3535+import UI.Common.State as Common
3336import UI.Equalizer as Equalizer
3737+import UI.EtCetera.State as EtCetera
3438import UI.Interface.State as Interface
3535-import UI.Interface.Types as Interface
3639import UI.Page as Page
3740import UI.Playlists as Playlists
3841import UI.Playlists.ContextMenu as Playlists
···4851import UI.Tracks as Tracks
4952import UI.Tracks.ContextMenu as Tracks
5053import UI.Tracks.State as Tracks
5151-import UI.Types exposing (..)
5454+import UI.Types as UI exposing (..)
5255import UI.User.State as User
5356import UI.View exposing (view)
5457import Url exposing (Protocol(..), Url)
5558import User.Layer exposing (..)
5656-import User.Layer.Methods.RemoteStorage as RemoteStorage
575958605961···141143 Cmd.none
142144 )
143145 |> addCommand
144144- (Task.perform
145145- (Interface.SetCurrentTime >> Interface)
146146- Time.now
147147- )
146146+ (Task.perform SetCurrentTime Time.now)
148147149148150149···152151153152154153update : Msg -> Model -> Return Model Msg
155155-update msg model =
154154+update msg =
156155 case msg of
157156 Bypass ->
158158- return model
157157+ return
159158160159 Reply reply ->
161161- Reply.translate reply model
160160+ Reply.translate reply
162161163162 --
164163 Audio a ->
165165- Audio.update a model
166166-167167- Interface a ->
168168- Interface.update a model
164164+ Audio.update a
169165170166 -----------------------------------------
171167 -- Authentication
172168 -----------------------------------------
173173- AuthenticationBootFailure err ->
174174- model
175175- |> showNotification (Notifications.error err)
176176- |> andThen (Reply.translate LoadDefaultBackdrop)
169169+ AuthenticationBootFailure a ->
170170+ Authentication.authenticationBootFailure a
177171178178- MissingSecretKey json ->
179179- "There seems to be existing data that's encrypted, I will need the passphrase (ie. encryption key) to continue."
180180- |> Notifications.error
181181- |> showNotificationWithModel model
182182- |> andThen (Reply.translate <| Reply.LoadDefaultBackdrop)
183183- |> andThen (Reply.translate <| Reply.ToggleLoadingScreen Off)
172172+ MissingSecretKey a ->
173173+ Authentication.missingSecretKey a
184174185175 NotAuthenticated ->
186186- -- This is the message we get when the app initially
187187- -- finds out we're not authenticated.
188188- andThen
189189- (update <| BackdropMsg Backdrop.Default)
190190- (if model.isUpgrading then
191191- """
192192- Thank you for using Diffuse V1!
193193- If you want to import your old data,
194194- please pick the storage method you used before and
195195- go to the [import page](#/settings/import-export).
196196- """
197197- |> Notifications.stickySuccess
198198- |> showNotificationWithModel { model | isUpgrading = False }
176176+ Authentication.notAuthenticated
199177200200- else
201201- return model
202202- )
203203-204204- RemoteStorageWebfinger remoteStorage (Ok oauthOrigin) ->
205205- let
206206- origin =
207207- Common.urlOrigin model.url
208208- in
209209- remoteStorage
210210- |> RemoteStorage.oauthAddress
211211- { oauthOrigin = oauthOrigin
212212- , origin = origin
213213- }
214214- |> Nav.load
215215- |> returnWithModel model
216216-217217- RemoteStorageWebfinger _ (Err _) ->
218218- RemoteStorage.webfingerError
219219- |> Notifications.error
220220- |> showNotificationWithModel model
178178+ RemoteStorageWebfinger a b ->
179179+ Authentication.remoteStorageWebfinger a b
221180222181 -----------------------------------------
223182 -- Children
224183 -----------------------------------------
225184 AlfredMsg sub ->
226226- Return3.wieldNested
227227- Reply.translate
228228- { mapCmd = AlfredMsg
229229- , mapModel = \child -> { model | alfred = child }
230230- , update = Alfred.update
231231- }
232232- { model = model.alfred
233233- , msg = sub
234234- }
185185+ \model ->
186186+ Return3.wieldNested
187187+ Reply.translate
188188+ { mapCmd = AlfredMsg
189189+ , mapModel = \child -> { model | alfred = child }
190190+ , update = Alfred.update
191191+ }
192192+ { model = model.alfred
193193+ , msg = sub
194194+ }
235195236196 AuthenticationMsg sub ->
237237- Return3.wieldNested
238238- Reply.translate
239239- { mapCmd = AuthenticationMsg
240240- , mapModel = \child -> { model | authentication = child }
241241- , update = Authentication.update
242242- }
243243- { model = model.authentication
244244- , msg = sub
245245- }
197197+ \model ->
198198+ Return3.wieldNested
199199+ Reply.translate
200200+ { mapCmd = AuthenticationMsg
201201+ , mapModel = \child -> { model | authentication = child }
202202+ , update = Authentication.update
203203+ }
204204+ { model = model.authentication
205205+ , msg = sub
206206+ }
246207247208 BackdropMsg sub ->
248248- Return3.wieldNested
249249- Reply.translate
250250- { mapCmd = BackdropMsg
251251- , mapModel = \child -> { model | backdrop = child }
252252- , update = Backdrop.update
253253- }
254254- { model = model.backdrop
255255- , msg = sub
256256- }
209209+ \model ->
210210+ Return3.wieldNested
211211+ Reply.translate
212212+ { mapCmd = BackdropMsg
213213+ , mapModel = \child -> { model | backdrop = child }
214214+ , update = Backdrop.update
215215+ }
216216+ { model = model.backdrop
217217+ , msg = sub
218218+ }
257219258220 EqualizerMsg sub ->
259259- Return3.wieldNested
260260- Reply.translate
261261- { mapCmd = EqualizerMsg
262262- , mapModel = \child -> { model | equalizer = child }
263263- , update = Equalizer.update
264264- }
265265- { model = model.equalizer
266266- , msg = sub
267267- }
221221+ \model ->
222222+ Return3.wieldNested
223223+ Reply.translate
224224+ { mapCmd = EqualizerMsg
225225+ , mapModel = \child -> { model | equalizer = child }
226226+ , update = Equalizer.update
227227+ }
228228+ { model = model.equalizer
229229+ , msg = sub
230230+ }
268231269232 PlaylistsMsg sub ->
270270- Return3.wieldNested
271271- Reply.translate
272272- { mapCmd = PlaylistsMsg
273273- , mapModel = \child -> { model | playlists = child }
274274- , update = Playlists.update
275275- }
276276- { model = model.playlists
277277- , msg = sub
278278- }
233233+ \model ->
234234+ Return3.wieldNested
235235+ Reply.translate
236236+ { mapCmd = PlaylistsMsg
237237+ , mapModel = \child -> { model | playlists = child }
238238+ , update = Playlists.update
239239+ }
240240+ { model = model.playlists
241241+ , msg = sub
242242+ }
279243280244 QueueMsg sub ->
281281- Return3.wieldNested
282282- Reply.translate
283283- { mapCmd = QueueMsg
284284- , mapModel = \child -> { model | queue = child }
285285- , update = Queue.update
286286- }
287287- { model = model.queue
288288- , msg = sub
289289- }
245245+ \model ->
246246+ Return3.wieldNested
247247+ Reply.translate
248248+ { mapCmd = QueueMsg
249249+ , mapModel = \child -> { model | queue = child }
250250+ , update = Queue.update
251251+ }
252252+ { model = model.queue
253253+ , msg = sub
254254+ }
290255291256 SourcesMsg sub ->
292292- Return3.wieldNested
293293- Reply.translate
294294- { mapCmd = SourcesMsg
295295- , mapModel = \child -> { model | sources = child }
296296- , update = Sources.update
297297- }
298298- { model = model.sources
299299- , msg = sub
300300- }
257257+ \model ->
258258+ Return3.wieldNested
259259+ Reply.translate
260260+ { mapCmd = SourcesMsg
261261+ , mapModel = \child -> { model | sources = child }
262262+ , update = Sources.update
263263+ }
264264+ { model = model.sources
265265+ , msg = sub
266266+ }
301267302268 TracksMsg sub ->
303303- Return3.wieldNested
304304- Reply.translate
305305- { mapCmd = TracksMsg
306306- , mapModel = \child -> { model | tracks = child }
307307- , update = Tracks.update
308308- }
309309- { model = model.tracks
310310- , msg = sub
311311- }
269269+ \model ->
270270+ Return3.wieldNested
271271+ Reply.translate
272272+ { mapCmd = TracksMsg
273273+ , mapModel = \child -> { model | tracks = child }
274274+ , update = Tracks.update
275275+ }
276276+ { model = model.tracks
277277+ , msg = sub
278278+ }
279279+280280+ -----------------------------------------
281281+ -- Interface
282282+ -----------------------------------------
283283+ Blur ->
284284+ Interface.blur
285285+286286+ Debounce a ->
287287+ Interface.debounce update a
288288+289289+ FocusedOnInput ->
290290+ Interface.focusedOnInput
291291+292292+ HideOverlay ->
293293+ Interface.hideOverlay
294294+295295+ KeyboardMsg a ->
296296+ Interface.keyboardMsg a
297297+298298+ PreferredColorSchemaChanged a ->
299299+ Interface.preferredColorSchemaChanged a
300300+301301+ RemoveQueueSelection ->
302302+ Interface.removeQueueSelection
303303+304304+ RemoveTrackSelection ->
305305+ Interface.removeTrackSelection
306306+307307+ ResizedWindow a ->
308308+ Interface.resizedWindow a
309309+310310+ SetIsTouchDevice a ->
311311+ Interface.setIsTouchDevice a
312312+313313+ ShowNotification a ->
314314+ Common.showNotification a
315315+316316+ StoppedDragging ->
317317+ Interface.stoppedDragging
318318+319319+ UI.ToggleLoadingScreen a ->
320320+ Interface.toggleLoadingScreen a
312321313322 -----------------------------------------
314323 -- Routing
315324 -----------------------------------------
316325 ChangeUrlUsingPage a ->
317317- Routing.changeUrlUsingPage a model
326326+ Routing.changeUrlUsingPage a
318327319328 LinkClicked a ->
320320- Routing.linkClicked a model
329329+ Routing.linkClicked a
321330322331 PageChanged a ->
323323- Routing.transition a model
332332+ Routing.transition a
324333325334 UrlChanged a ->
326326- Routing.urlChanged a model
335335+ Routing.urlChanged a
327336328337 -----------------------------------------
329338 -- Services
330339 -----------------------------------------
331340 GotLastFmSession a ->
332332- Services.gotLastFmSession a model
341341+ Services.gotLastFmSession a
333342334343 Scrobble a ->
335335- Services.scrobble a model
344344+ Services.scrobble a
336345337346 -----------------------------------------
338347 -- Tracks
339348 -----------------------------------------
340349 DownloadTracksFinished ->
341341- Tracks.downloadTracksFinished model
350350+ Tracks.downloadTracksFinished
342351343352 FailedToStoreTracksInCache a ->
344344- Tracks.failedToStoreTracksInCache a model
353353+ Tracks.failedToStoreTracksInCache a
345354346355 FinishedStoringTracksInCache a ->
347347- Tracks.finishedStoringTracksInCache a model
356356+ Tracks.finishedStoringTracksInCache a
348357349358 -----------------------------------------
350359 -- User
351360 -----------------------------------------
352361 ImportFile a ->
353353- User.importFile a model
362362+ User.importFile a
354363355364 ImportJson a ->
356356- User.importJson a model
365365+ User.importJson a
357366358367 LoadEnclosedUserData a ->
359359- User.loadEnclosedUserData a model
368368+ User.loadEnclosedUserData a
360369361370 LoadHypaethralUserData a ->
362362- User.loadHypaethralUserData a model
371371+ User.loadHypaethralUserData a
372372+373373+ -----------------------------------------
374374+ -- 📭 Et Cetera
375375+ -----------------------------------------
376376+ SetCurrentTime a ->
377377+ EtCetera.setCurrentTime a
378378+379379+ SetIsOnline a ->
380380+ EtCetera.setIsOnline a
363381364382365383···369387subscriptions : Model -> Sub Msg
370388subscriptions model =
371389 Sub.batch
372372- [ Ports.fromAlien alien
390390+ [ Audio.subscriptions model
391391+ , Ports.fromAlien alien
392392+393393+ -----------------------------------------
394394+ -- Alfred
395395+ -----------------------------------------
396396+ , case model.alfred.instance of
397397+ Just _ ->
398398+ Sub.map AlfredMsg (Alfred.subscriptions model.alfred)
399399+400400+ Nothing ->
401401+ Sub.none
373402403403+ -----------------------------------------
404404+ -- Backdrop
405405+ -----------------------------------------
406406+ , Ports.setAverageBackgroundColor (Backdrop.BackgroundColor >> BackdropMsg)
407407+408408+ -----------------------------------------
409409+ -- Interface
410410+ -----------------------------------------
411411+ , Ports.indicateTouchDevice (\_ -> SetIsTouchDevice True)
412412+ , Ports.preferredColorSchemaChanged PreferredColorSchemaChanged
413413+ , Ports.showErrorNotification (Notifications.error >> ShowNotification)
414414+ , Ports.showStickyErrorNotification (Notifications.stickyError >> ShowNotification)
415415+416416+ -----------------------------------------
374417 -- Queue
375375- --------
418418+ -----------------------------------------
376419 , Ports.activeQueueItemEnded (QueueMsg << always Queue.Shift)
377420 , Ports.requestNext <| always (QueueMsg Queue.Shift)
378421 , Ports.requestPrevious <| always (QueueMsg Queue.Rewind)
379422380380- -- Children
381381- -----------
382382- , ifThenElse
383383- (Maybe.isJust model.alfred.instance)
384384- (Sub.map AlfredMsg <| Alfred.subscriptions model.alfred)
385385- Sub.none
423423+ -----------------------------------------
424424+ -- Services
425425+ -----------------------------------------
426426+ , Ports.scrobble Scrobble
386427387387- --
428428+ -----------------------------------------
429429+ -- Tracks
430430+ -----------------------------------------
388431 , Ports.downloadTracksFinished (\_ -> DownloadTracksFinished)
389389- , Ports.scrobble Scrobble
390390- , Ports.setAverageBackgroundColor (Backdrop.BackgroundColor >> BackdropMsg)
391432392392- --
393393- , Audio.subscriptions model
394394- , Interface.subscriptions model
433433+ -----------------------------------------
434434+ -- 📭 Et Cetera
435435+ -----------------------------------------
436436+ , Ports.setIsOnline SetIsOnline
437437+ , Sub.map KeyboardMsg Keyboard.subscriptions
438438+ , Time.every (60 * 1000) SetCurrentTime
439439+440440+ -- Resize
441441+ ---------
442442+ , Browser.Events.onResize
443443+ (\w h ->
444444+ ( w, h )
445445+ |> ResizedWindow
446446+ |> Debouncer.provideInput
447447+ |> Debounce
448448+ )
395449 ]
396450397451···433487 SourcesMsg Sources.FinishedProcessing
434488435489 Just Alien.HideLoadingScreen ->
436436- Interface (Interface.ToggleLoadingScreen Off)
490490+ UI.ToggleLoadingScreen Off
437491438492 Just Alien.ImportLegacyData ->
439493 "Imported data successfully!"
440494 |> Notifications.success
441441- |> Interface.ShowNotification
442442- |> Interface
495495+ |> ShowNotification
443496444497 Just Alien.LoadEnclosedUserData ->
445498 LoadEnclosedUserData event.data
···475528 FinishedStoringTracksInCache list
476529477530 Err err ->
478478- err
479479- |> Json.Decode.errorToString
480480- |> Notifications.error
481481- |> Interface.ShowNotification
482482- |> Interface
531531+ showErrorNotification (Json.Decode.errorToString err)
483532484533 Just Alien.UpdateSourceData ->
485534 SourcesMsg (Sources.UpdateSourceData event.data)
···521570 FailedToStoreTracksInCache trackIds
522571523572 Err _ ->
524524- err
525525- |> Notifications.error
526526- |> Interface.ShowNotification
527527- |> Interface
573573+ showErrorNotification err
528574529575 _ ->
530530- err
531531- |> Notifications.error
532532- |> Interface.ShowNotification
533533- |> Interface
576576+ showErrorNotification err
577577+578578+579579+580580+-- ⚗️
581581+582582+583583+showErrorNotification : String -> Msg
584584+showErrorNotification =
585585+ Notifications.error >> ShowNotification
+79
src/Applications/UI/Authentication/State.elm
···11+module UI.Authentication.State exposing (..)
22+33+import Browser.Navigation as Nav
44+import Common exposing (Switch(..))
55+import Http
66+import Json.Decode as Json
77+import Management
88+import Monocle.Lens as Lens
99+import Notifications
1010+import Return exposing (andThen, return)
1111+import Return.Ext as Return exposing (communicate)
1212+import UI.Common.State as Common exposing (showNotification, showNotificationWithModel)
1313+import UI.Reply as Reply exposing (Reply(..))
1414+import UI.Reply.Translate as Reply
1515+import UI.Types as UI exposing (Manager, Msg(..))
1616+import User.Layer.Methods.RemoteStorage as RemoteStorage
1717+1818+1919+2020+-- 📣
2121+2222+2323+authenticationBootFailure : String -> UI.Manager
2424+authenticationBootFailure err model =
2525+ model
2626+ |> showNotification (Notifications.error err)
2727+ |> andThen (Reply.translate LoadDefaultBackdrop)
2828+2929+3030+missingSecretKey : Json.Value -> UI.Manager
3131+missingSecretKey _ model =
3232+ "There seems to be existing data that's encrypted, I will need the passphrase (ie. encryption key) to continue."
3333+ |> Notifications.error
3434+ |> showNotificationWithModel model
3535+ |> andThen (Reply.translate <| Reply.LoadDefaultBackdrop)
3636+ |> andThen (Reply.translate <| Reply.ToggleLoadingScreen Off)
3737+3838+3939+notAuthenticated : UI.Manager
4040+notAuthenticated model =
4141+ -- This is the message we get when the app initially
4242+ -- finds out we're not authenticated.
4343+ andThen
4444+ (Reply.translate Reply.LoadDefaultBackdrop)
4545+ (if model.isUpgrading then
4646+ """
4747+ Thank you for using Diffuse V1!
4848+ If you want to import your old data,
4949+ please pick the storage method you used before and
5050+ go to the [import page](#/settings/import-export).
5151+ """
5252+ |> Notifications.stickySuccess
5353+ |> showNotificationWithModel { model | isUpgrading = False }
5454+5555+ else
5656+ Return.singleton model
5757+ )
5858+5959+6060+remoteStorageWebfinger : RemoteStorage.Attributes -> Result Http.Error String -> UI.Manager
6161+remoteStorageWebfinger remoteStorage result model =
6262+ case result of
6363+ Ok oauthOrigin ->
6464+ let
6565+ origin =
6666+ Common.urlOrigin model.url
6767+ in
6868+ remoteStorage
6969+ |> RemoteStorage.oauthAddress
7070+ { oauthOrigin = oauthOrigin
7171+ , origin = origin
7272+ }
7373+ |> Nav.load
7474+ |> return model
7575+7676+ Err _ ->
7777+ RemoteStorage.webfingerError
7878+ |> Notifications.error
7979+ |> showNotificationWithModel model
+84
src/Applications/UI/EtCetera/State.elm
···11+module UI.EtCetera.State exposing (..)
22+33+import Alien
44+import Browser.Events
55+import Common exposing (Switch(..))
66+import Debouncer.Basic as Debouncer
77+import Keyboard
88+import Management
99+import Maybe.Extra as Maybe
1010+import Monocle.Lens as Lens
1111+import Notifications
1212+import Return exposing (return)
1313+import Return.Ext as Return exposing (communicate)
1414+import Time
1515+import UI.Authentication as Authentication
1616+import UI.Common.State as Common exposing (modifySingleton)
1717+import UI.DnD as DnD
1818+import UI.Page as Page
1919+import UI.Ports as Ports
2020+import UI.Queue as Queue
2121+import UI.Queue.State as Queue
2222+import UI.Reply as Reply
2323+import UI.Sources.State as Sources
2424+import UI.Tracks as Tracks
2525+import UI.Tracks.Scene.List
2626+import UI.Tracks.State as Tracks
2727+import UI.Types as UI exposing (..)
2828+import User.Layer exposing (..)
2929+3030+3131+3232+-- 📣
3333+3434+3535+setIsOnline : Bool -> UI.Manager
3636+setIsOnline bool model =
3737+ if bool then
3838+ -- We're caching the user's data in the browser while offline.
3939+ -- If we're back online again, sync all the user's data.
4040+ (case model.authentication of
4141+ Authentication.Authenticated (Dropbox _) ->
4242+ syncHypaethralData
4343+4444+ Authentication.Authenticated (RemoteStorage _) ->
4545+ syncHypaethralData
4646+4747+ _ ->
4848+ Return.singleton
4949+ )
5050+ { model | isOnline = True }
5151+5252+ else
5353+ -- The app went offline, cache everything
5454+ -- (if caching is supported).
5555+ ( { model | isOnline = False }
5656+ , case model.authentication of
5757+ Authentication.Authenticated (Dropbox _) ->
5858+ Ports.toBrain (Alien.trigger Alien.SyncHypaethralData)
5959+6060+ Authentication.Authenticated (RemoteStorage _) ->
6161+ Ports.toBrain (Alien.trigger Alien.SyncHypaethralData)
6262+6363+ _ ->
6464+ Cmd.none
6565+ )
6666+6767+6868+setCurrentTime : Time.Posix -> UI.Manager
6969+setCurrentTime time model =
7070+ model
7171+ |> (\m -> { m | currentTime = time })
7272+ |> Lens.modify Sources.lens (\s -> { s | currentTime = time })
7373+ |> Return.singleton
7474+7575+7676+7777+-- ⚗️
7878+7979+8080+syncHypaethralData : UI.Manager
8181+syncHypaethralData model =
8282+ model
8383+ |> Common.showNotification (Notifications.warning "Syncing")
8484+ |> Return.command (Ports.toBrain <| Alien.trigger Alien.SyncHypaethralData)
+3-139
src/Applications/UI/Interface/State.elm
···1515import UI.Authentication as Authentication
1616import UI.Common.State as Common exposing (modifySingleton)
1717import UI.DnD as DnD
1818-import UI.Interface.Types as Interface exposing (Msg(..))
1918import UI.Page as Page
2019import UI.Ports as Ports
2120import UI.Queue as Queue
···3332-- 📣
343335343636-update : Interface.Msg -> Manager
3737-update msg =
3838- case msg of
3939- Blur ->
4040- blur
4141-4242- Debounce a ->
4343- debounce a
4444-4545- FocusedOnInput ->
4646- focusedOnInput
4747-4848- HideOverlay ->
4949- hideOverlay
5050-5151- KeyboardMsg a ->
5252- keyboardMsg a
5353-5454- PreferredColorSchemaChanged a ->
5555- preferredColorSchemaChanged a
5656-5757- RemoveQueueSelection ->
5858- removeQueueSelection
5959-6060- RemoveTrackSelection ->
6161- removeTrackSelection
6262-6363- ResizedWindow a ->
6464- resizedWindow a
6565-6666- SetCurrentTime a ->
6767- setCurrentTime a
6868-6969- SetIsOnline a ->
7070- setIsOnline a
7171-7272- SetIsTouchDevice a ->
7373- setIsTouchDevice a
7474-7575- ShowNotification a ->
7676- Common.showNotification a
7777-7878- StoppedDragging ->
7979- stoppedDragging
8080-8181- ToggleLoadingScreen a ->
8282- toggleLoadingScreen a
8383-8484-8585-8686--- 📰
8787-8888-8989-subscriptions : UI.Model -> Sub UI.Msg
9090-subscriptions _ =
9191- [ Ports.indicateTouchDevice (\_ -> SetIsTouchDevice True)
9292- , Ports.preferredColorSchemaChanged PreferredColorSchemaChanged
9393- , Ports.setIsOnline SetIsOnline
9494- , Ports.showErrorNotification (Notifications.error >> ShowNotification)
9595- , Ports.showStickyErrorNotification (Notifications.stickyError >> ShowNotification)
9696-9797- -- Resize
9898- ---------
9999- , Browser.Events.onResize
100100- (\w h ->
101101- ( w, h )
102102- |> ResizedWindow
103103- |> Debouncer.provideInput
104104- |> Debounce
105105- )
106106-107107- --
108108- , Sub.map KeyboardMsg Keyboard.subscriptions
109109- , Time.every (60 * 1000) SetCurrentTime
110110- ]
111111- |> Sub.batch
112112- |> Sub.map UI.Interface
113113-114114-115115-116116--- 🔱
117117-118118-11935blur : UI.Manager
12036blur model =
12137 Return.singleton { model | focusedOnInput = False }
1223812339124124-debounce : Debouncer.Msg Interface.Msg -> UI.Manager
125125-debounce debouncerMsg model =
4040+debounce : (Msg -> Model -> ( Model, Cmd Msg )) -> Debouncer.Msg Msg -> UI.Manager
4141+debounce update debouncerMsg model =
12642 let
12743 ( subModel, subCmd, emittedMsg ) =
12844 Debouncer.update debouncerMsg model.debounce
1294513046 mappedCmd =
131131- Cmd.map (Debounce >> UI.Interface) subCmd
4747+ Cmd.map Debounce subCmd
1324813349 updatedModel =
13450 { model | debounce = subModel }
···236152 }
237153238154239239-setIsOnline : Bool -> UI.Manager
240240-setIsOnline bool model =
241241- if bool then
242242- -- We're caching the user's data in the browser while offline.
243243- -- If we're back online again, sync all the user's data.
244244- (case model.authentication of
245245- Authentication.Authenticated (Dropbox _) ->
246246- syncHypaethralData
247247-248248- Authentication.Authenticated (RemoteStorage _) ->
249249- syncHypaethralData
250250-251251- _ ->
252252- Return.singleton
253253- )
254254- { model | isOnline = True }
255255-256256- else
257257- -- The app went offline, cache everything
258258- -- (if caching is supported).
259259- ( { model | isOnline = False }
260260- , case model.authentication of
261261- Authentication.Authenticated (Dropbox _) ->
262262- Ports.toBrain (Alien.trigger Alien.SyncHypaethralData)
263263-264264- Authentication.Authenticated (RemoteStorage _) ->
265265- Ports.toBrain (Alien.trigger Alien.SyncHypaethralData)
266266-267267- _ ->
268268- Cmd.none
269269- )
270270-271271-272272-setCurrentTime : Time.Posix -> UI.Manager
273273-setCurrentTime time model =
274274- model
275275- |> (\m -> { m | currentTime = time })
276276- |> Lens.modify Sources.lens (\s -> { s | currentTime = time })
277277- |> Return.singleton
278278-279279-280155setIsTouchDevice : Bool -> UI.Manager
281156setIsTouchDevice bool model =
282157 Return.singleton { model | isTouchDevice = bool }
···320195321196 Off ->
322197 Return.singleton { model | isLoading = False }
323323-324324-325325-326326--- ⚗️
327327-328328-329329-syncHypaethralData : UI.Manager
330330-syncHypaethralData model =
331331- model
332332- |> Common.showNotification (Notifications.warning "Syncing")
333333- |> Return.command (Ports.toBrain <| Alien.trigger Alien.SyncHypaethralData)
···5858import UI.Demo as Demo
5959import UI.Equalizer as Equalizer
6060import UI.Interface.State as Interface
6161-import UI.Interface.Types as Interface
6261import UI.Navigation as Navigation
6362import UI.Notifications
6463import UI.Page as Page
···111110 StartedDragging ->
112111 Return.singleton { model | isDragging = True }
113112114114- ToggleLoadingScreen a ->
113113+ Reply.ToggleLoadingScreen a ->
115114 Interface.toggleLoadingScreen a model
116115117116 -----------------------------------------