A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Clean up main modules

+142 -113
+20 -16
src/Applications/Brain.elm
··· 308 308 return model 309 309 310 310 311 - saveTracks : Model -> List Tracks.Track -> Return Model Msg 312 - saveTracks model tracks = 313 - tracks 314 - -- Store in model 315 - |> hypaethralLenses.setTracks model 316 - -- Update search index 317 - |> update 318 - (tracks 319 - |> Json.Encode.list Tracks.encodeTrack 320 - |> Tracks.UpdateSearchIndex 321 - |> TracksMsg 322 - ) 323 - -- Save with delay 324 - |> andThen (saveHypaethralDataBitWithDelay Tracks) 325 - 326 - 327 311 updateWithModel : Model -> Msg -> Return Model Msg 328 312 updateWithModel model msg = 329 313 update msg model ··· 435 419 { model = model.tracks 436 420 , msg = sub 437 421 } 422 + 423 + 424 + 425 + -- 📣 ░░ FUNCTIONS 426 + 427 + 428 + saveTracks : Model -> List Tracks.Track -> Return Model Msg 429 + saveTracks model tracks = 430 + tracks 431 + -- Store in model 432 + |> hypaethralLenses.setTracks model 433 + -- Update search index 434 + |> update 435 + (tracks 436 + |> Json.Encode.list Tracks.encodeTrack 437 + |> Tracks.UpdateSearchIndex 438 + |> TracksMsg 439 + ) 440 + -- Save with delay 441 + |> andThen (saveHypaethralDataBitWithDelay Tracks) 438 442 439 443 440 444
+122 -97
src/Applications/UI.elm
··· 8 8 import Browser.Navigation as Nav 9 9 import Chunky exposing (..) 10 10 import Classes as C 11 - import Color 11 + import Color exposing (Color) 12 12 import Color.Ext as Color 13 13 import Common exposing (Switch(..)) 14 14 import Conditional exposing (..) ··· 244 244 | LoadEnclosedUserData Json.Decode.Value 245 245 | LoadHypaethralUserData Json.Decode.Value 246 246 | ResizedWindow ( Int, Int ) 247 + | ShowNotification (Notification Reply) 247 248 | SetCurrentTime Time.Posix 248 249 | SetIsOnline Bool 249 250 | StoppedDragging ··· 284 285 | Import File 285 286 | ImportJson String 286 287 ----------------------------------------- 287 - -- Notifications 288 - ----------------------------------------- 289 - | ShowNotification (Notification Reply) 290 - ----------------------------------------- 291 288 -- Page Transitions 292 289 ----------------------------------------- 293 290 | PageChanged Page ··· 326 323 } 327 324 328 325 HideOverlay -> 329 - return { model | alfred = { instance = Nothing }, contextMenu = Nothing } 326 + hideOverlay model 330 327 331 328 KeyboardMsg subMsg -> 332 - { model | pressedKeys = Keyboard.update subMsg model.pressedKeys } 333 - |> (\m -> 334 - ifThenElse 335 - (List.member Keyboard.Escape m.pressedKeys) 336 - (update HideOverlay m) 337 - (return m) 338 - ) 329 + (\m -> 330 + ifThenElse 331 + (List.member Keyboard.Escape m.pressedKeys) 332 + (hideOverlay m) 333 + (return m) 334 + ) 335 + { model | pressedKeys = Keyboard.update subMsg model.pressedKeys } 339 336 340 337 LoadEnclosedUserData json -> 341 338 model ··· 377 374 | contextMenu = Nothing 378 375 , viewport = { height = toFloat height, width = toFloat width } 379 376 } 377 + -- 380 378 , Cmd.none 381 379 ) 382 380 ··· 389 387 | currentTime = time 390 388 , sources = { sources | currentTime = time } 391 389 } 390 + -- 392 391 , Cmd.none 393 392 ) 394 393 ··· 408 407 ) 409 408 410 409 SetIsOnline True -> 411 - andThen 412 - -- We're caching the user's data in the browser while offline. 413 - -- If we're back online again, sync all the user's data. 414 - (case model.authentication of 415 - Authentication.Authenticated (Dropbox _) -> 416 - syncHypaethralData 410 + -- We're caching the user's data in the browser while offline. 411 + -- If we're back online again, sync all the user's data. 412 + (case model.authentication of 413 + Authentication.Authenticated (Dropbox _) -> 414 + syncHypaethralData 417 415 418 - Authentication.Authenticated (RemoteStorage _) -> 419 - syncHypaethralData 416 + Authentication.Authenticated (RemoteStorage _) -> 417 + syncHypaethralData 420 418 421 - _ -> 422 - return 423 - ) 424 - ( { model | isOnline = True } 425 - , Cmd.none 426 - ) 419 + _ -> 420 + return 421 + ) 422 + { model | isOnline = True } 423 + 424 + ShowNotification notification -> 425 + showNotification notification model 427 426 428 427 StoppedDragging -> 429 428 let 430 429 notDragging = 431 430 { model | isDragging = False } 432 431 in 432 + -- Depending on where we stopped dragging something, 433 + -- do the appropriate thing. 433 434 case model.page of 434 435 Page.Queue _ -> 435 436 DnD.stoppedDragging ··· 519 520 520 521 MissingSecretKey json -> 521 522 "There seems to be existing data that's encrypted, I will need the passphrase (ie. encryption key) to continue." 522 - |> ShowErrorNotification 523 - |> translateReplyWithModel model 523 + |> Notifications.error 524 + |> showNotificationWithModel model 524 525 |> andThen (translateReply <| Reply.LoadDefaultBackdrop) 525 526 |> andThen (translateReply <| Reply.ToggleLoadingScreen Off) 526 527 527 528 NotAuthenticated -> 528 529 -- This is the message we get when the app initially 529 530 -- finds out we're not authenticated. 530 - let 531 - upgradeNote = 532 - """ 533 - Thank you for using Diffuse V1! 534 - If you want to import your old data, 535 - please pick the storage method you used before and 536 - go to the [import page](#/settings/import-export). 537 - """ 538 - in 539 - { model | isUpgrading = False } 540 - |> update (BackdropMsg Backdrop.Default) 541 - |> andThen 542 - (if model.isUpgrading then 543 - translateReply (ShowStickySuccessNotification upgradeNote) 544 - 545 - else 546 - return 547 - ) 531 + """ 532 + Thank you for using Diffuse V1! 533 + If you want to import your old data, 534 + please pick the storage method you used before and 535 + go to the [import page](#/settings/import-export). 536 + """ 537 + |> Notifications.stickySuccess 538 + |> showNotificationWithModel { model | isUpgrading = False } 539 + |> andThen (update <| BackdropMsg Backdrop.Default) 548 540 549 541 RemoteStorageWebfinger remoteStorage (Ok oauthOrigin) -> 550 542 let ··· 686 678 -- Save all the imported data 687 679 ----------------------------- 688 680 |> saveAllHypaethralData 689 - 690 - ----------------------------------------- 691 - -- Notifications 692 - ----------------------------------------- 693 - ShowNotification notification -> 694 - showNotification notification model 695 681 696 682 ----------------------------------------- 697 683 -- Page Transitions ··· 854 840 returnWithModel model (resetUrl model.navKey url Page.Index) 855 841 856 842 857 - resetUrl : Nav.Key -> Url -> Page.Page -> Cmd Msg 858 - resetUrl key url page = 859 - Nav.replaceUrl key (url.path ++ Page.toString page) 860 - 861 - 862 - showNotification : Notification Reply -> Model -> Return Model Msg 863 - showNotification notification model = 864 - model.notifications 865 - |> UI.Notifications.show notification 866 - |> mapModel (\n -> { model | isLoading = False, notifications = n }) 867 - |> mapCommand Reply 868 - 869 - 870 - showNotificationWithModel : Model -> Notification Reply -> Return Model Msg 871 - showNotificationWithModel model notification = 872 - showNotification notification model 873 - 874 - 875 - syncHypaethralData : Model -> Return Model Msg 876 - syncHypaethralData model = 877 - "Syncing" 878 - |> Notifications.warning 879 - |> showNotificationWithModel model 880 - |> addCommand (Ports.toBrain <| Alien.trigger Alien.SyncHypaethralData) 881 - 882 - 883 843 updateTracksModel : (Tracks.Model -> Tracks.Model) -> Model -> Model 884 844 updateTracksModel fn model = 885 845 { model | tracks = fn model.tracks } ··· 891 851 892 852 893 853 894 - -- 📣 ░░ CHILDREN & REPLIES 854 + -- 📣 ░░ REPLIES 895 855 896 856 897 857 translateReply : Reply -> Model -> Return Model Msg ··· 1344 1304 |> Ports.toBrain 1345 1305 |> returnWithModel (updateTracksModel (\m -> { m | cached = [] }) model) 1346 1306 |> andThen (update <| TracksMsg Tracks.Harvest) 1347 - |> andThen (translateReply SaveEnclosedUserData) 1307 + |> andThen (translateReply <| SaveEnclosedUserData) 1348 1308 |> andThen (translateReply <| ShowWarningNotification "Tracks cache was cleared") 1349 1309 1350 1310 DisableTracksGrouping -> ··· 1651 1611 |> returnWithModel model 1652 1612 1653 1613 1614 + translateReplyWithModel : Model -> Reply -> Return Model Msg 1615 + translateReplyWithModel model reply = 1616 + translateReply reply model 1617 + 1618 + 1619 + 1620 + -- 📣 ░░ FUNCTIONS 1621 + 1622 + 1623 + hideOverlay : Model -> Return Model Msg 1624 + hideOverlay model = 1625 + ( { model 1626 + | alfred = { instance = Nothing } 1627 + , contextMenu = Nothing 1628 + } 1629 + -- 1630 + , Cmd.none 1631 + ) 1632 + 1633 + 1634 + resetUrl : Nav.Key -> Url -> Page.Page -> Cmd Msg 1635 + resetUrl key url page = 1636 + Nav.replaceUrl key (url.path ++ Page.toString page) 1637 + 1638 + 1654 1639 saveAllHypaethralData : Return Model Msg -> Return Model Msg 1655 1640 saveAllHypaethralData return = 1656 1641 List.foldl ··· 1678 1663 hypaethralBit.list 1679 1664 1680 1665 1681 - translateReplyWithModel : Model -> Reply -> Return Model Msg 1682 - translateReplyWithModel model reply = 1683 - translateReply reply model 1666 + showNotification : Notification Reply -> Model -> Return Model Msg 1667 + showNotification notification model = 1668 + model.notifications 1669 + |> UI.Notifications.show notification 1670 + |> mapModel (\n -> { model | isLoading = False, notifications = n }) 1671 + |> mapCommand Reply 1672 + 1673 + 1674 + showNotificationWithModel : Model -> Notification Reply -> Return Model Msg 1675 + showNotificationWithModel model notification = 1676 + showNotification notification model 1677 + 1678 + 1679 + syncHypaethralData : Model -> Return Model Msg 1680 + syncHypaethralData model = 1681 + "Syncing" 1682 + |> Notifications.warning 1683 + |> showNotificationWithModel model 1684 + |> addCommand (Ports.toBrain <| Alien.trigger Alien.SyncHypaethralData) 1684 1685 1685 1686 1686 1687 ··· 1716 1717 (Sub.map AlfredMsg <| Alfred.subscriptions model.alfred) 1717 1718 Sub.none 1718 1719 1719 - -- ... 1720 - ------ 1720 + -- Resize 1721 + --------- 1721 1722 , Browser.Events.onResize 1722 1723 (\w h -> 1723 1724 ( w, h ) ··· 1749 1750 1750 1751 translateAlienData : Alien.Event -> Msg 1751 1752 translateAlienData event = 1752 - case Alien.tagFromString event.tag of 1753 + case 1754 + Alien.tagFromString event.tag 1755 + of 1753 1756 Just Alien.AddTracks -> 1754 1757 TracksMsg (Tracks.Add event.data) 1755 1758 ··· 1803 1806 TracksMsg (Tracks.SetSearchResults event.data) 1804 1807 1805 1808 Just Alien.StoreTracksInCache -> 1806 - case Json.Decode.decodeValue (Json.Decode.list Json.Decode.string) event.data of 1809 + case 1810 + Json.Decode.decodeValue 1811 + (Json.Decode.list Json.Decode.string) 1812 + event.data 1813 + of 1807 1814 Ok list -> 1808 1815 FinishedStoringTracksInCache list 1809 1816 ··· 1822 1829 1823 1830 translateAlienError : Alien.Event -> String -> Msg 1824 1831 translateAlienError event err = 1825 - case Alien.tagFromString event.tag of 1832 + case 1833 + Alien.tagFromString event.tag 1834 + of 1826 1835 Just Alien.AuthAnonymous -> 1827 1836 AuthenticationBootFailure err 1828 1837 ··· 1842 1851 AuthenticationBootFailure err 1843 1852 1844 1853 Just Alien.StoreTracksInCache -> 1845 - case Json.Decode.decodeValue (Json.Decode.list Json.Decode.string) event.data of 1854 + case 1855 + Json.Decode.decodeValue 1856 + (Json.Decode.list Json.Decode.string) 1857 + event.data 1858 + of 1846 1859 Ok trackIds -> 1847 1860 FailedToStoreTracksInCache trackIds 1848 1861 ··· 1991 2004 1992 2005 Page.Playlists subPage -> 1993 2006 model.backdrop.bgColor 1994 - |> Lazy.lazy4 Playlists.view subPage model.playlists model.tracks.selectedPlaylist 2007 + |> Lazy.lazy4 2008 + Playlists.view 2009 + subPage 2010 + model.playlists 2011 + model.tracks.selectedPlaylist 1995 2012 |> Html.map PlaylistsMsg 1996 2013 1997 2014 Page.Queue subPage -> ··· 2177 2194 ----------------------------------------- 2178 2195 -- Bits & Pieces 2179 2196 ----------------------------------------- 2180 - , Css.Global.selector ".bg-accent" [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colorKit.accent) ] 2181 - , Css.Global.selector ".bg-base-00" [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colorKit.base00) ] 2182 - , Css.Global.selector ".bg-base-01" [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colorKit.base01) ] 2183 - , Css.Global.selector ".bg-base-0D" [ Css.backgroundColor (Color.toElmCssColor UI.Kit.colorKit.base0D) ] 2197 + , Css.Global.selector ".bg-accent" [ backgroundColor UI.Kit.colorKit.accent ] 2198 + , Css.Global.selector ".bg-base-00" [ backgroundColor UI.Kit.colorKit.base00 ] 2199 + , Css.Global.selector ".bg-base-01" [ backgroundColor UI.Kit.colorKit.base01 ] 2200 + , Css.Global.selector ".bg-base-0D" [ backgroundColor UI.Kit.colorKit.base0D ] 2184 2201 , Css.Global.selector ".dragging-something" [ Css.cursor Css.grabbing ] 2185 2202 , Css.Global.selector ".dragging-something *" [ Css.important (Css.cursor Css.grabbing) ] 2186 2203 , Css.Global.selector ".grab-cursor" [ Css.cursor Css.grab ] ··· 2196 2213 , Css.property "user-select" "none" 2197 2214 ] 2198 2215 ] 2216 + 2217 + 2218 + backgroundColor : Color -> Css.Style 2219 + backgroundColor = 2220 + Color.toElmCssColor >> Css.backgroundColor 2199 2221 2200 2222 2201 2223 placeholderStyles : List Css.Style ··· 2232 2254 2233 2255 vesselInnerStyles : List Css.Style 2234 2256 vesselInnerStyles = 2235 - [ Css.property "-webkit-mask-image" "-webkit-radial-gradient(white, black)" 2236 - ] 2257 + [ Css.property "-webkit-mask-image" "-webkit-radial-gradient(white, black)" ] 2237 2258 2238 2259 2239 2260 ··· 2289 2310 , processAutomatically = Maybe.unwrap True .processAutomatically data.settings 2290 2311 , rememberProgress = Maybe.unwrap True .rememberProgress data.settings 2291 2312 } 2313 + -- 2292 2314 , Cmd.batch 2293 2315 [ Cmd.map PlaylistsMsg playlistsCmd 2294 2316 , Cmd.map TracksMsg tracksCmd 2295 2317 ] 2318 + -- 2296 2319 , playlistsReplies ++ tracksReplies 2297 2320 ) 2298 2321 ··· 2377 2400 , queue = newQueue 2378 2401 , tracks = newTracks 2379 2402 } 2403 + -- 2380 2404 , Cmd.batch 2381 2405 [ Cmd.map EqualizerMsg (Equalizer.adjustAllKnobs newEqualizer) 2382 2406 , Ports.setRepeat data.repeat 2383 2407 ] 2408 + -- 2384 2409 , [] 2385 2410 ) 2386 2411