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

Configure Feed

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

PS. You're storing data …

+99 -45
+1 -1
Makefile
··· 29 29 elm: 30 30 @echo "> Compiling Elm application" 31 31 @elm make $(SRC_DIR)/Applications/Brain.elm --output $(BUILD_DIR)/brain.js 32 - @elm make $(SRC_DIR)/Applications/UI.elm --output $(BUILD_DIR)/application.js --debug 32 + @elm make $(SRC_DIR)/Applications/UI.elm --output $(BUILD_DIR)/application.js 33 33 34 34 35 35 system:
+11 -7
src/Applications/Brain/Authentication.elm
··· 142 142 , case model.method of 143 143 -- 🚀 144 144 Just Ipfs -> 145 + -- TODO 145 146 Cmd.none 146 147 147 - -- TODO 148 148 Just Local -> 149 149 Ports.requestCache (Alien.trigger Alien.AuthAnonymous) 150 150 ··· 157 157 HypaethralDataRetrieved json -> 158 158 ( model 159 159 , noCmd 160 - , terminate (Authenticated json) 160 + , Maybe.andThen (\m -> terminate <| Authenticated m json) model.method 161 161 ) 162 162 163 163 ----------------------------------------- ··· 188 188 , case model.method of 189 189 -- 🚀 190 190 Just Ipfs -> 191 + -- TODO 191 192 Cmd.none 192 193 193 - -- TODO 194 194 Just Local -> 195 195 Ports.toCache (Alien.broadcast Alien.AuthAnonymous json) 196 196 ··· 223 223 224 224 225 225 type Termination 226 - = Authenticated J.Value 226 + = Authenticated Method J.Value 227 227 | NotAuthenticated 228 228 229 229 230 230 terminate : Termination -> Maybe (List Reply) 231 231 terminate t = 232 232 case t of 233 - Authenticated json -> 234 - Just [ GiveUI Alien.LoadHypaethralUserData json ] 233 + Authenticated method hypData -> 234 + Just 235 + [ GiveUI Alien.LoadHypaethralUserData hypData 236 + , GiveUI Alien.AuthMethod (Authentication.encodeMethod method) 237 + ] 235 238 236 239 NotAuthenticated -> 237 - Just [ NudgeUI Alien.HideLoadingScreen ] 240 + Just 241 + [ NudgeUI Alien.HideLoadingScreen ]
+23 -12
src/Applications/UI.elm
··· 15 15 import Html.Styled.Lazy as Lazy 16 16 import Json.Encode as Encode 17 17 import Replying exposing (do, return) 18 - import Return2 19 - import Return3 18 + import Return2 as R2 20 19 import Sources 21 20 import Sources.Encoding 22 21 import Tachyons.Classes as T ··· 153 152 |> UI.UserData.encodedFavourites 154 153 |> Alien.broadcast Alien.SaveFavourites 155 154 |> Ports.toBrain 156 - |> Return2.withModel model 155 + |> R2.withModel model 157 156 158 157 Core.SaveSources -> 159 158 let ··· 171 170 |> UI.UserData.encodedSources 172 171 |> Alien.broadcast Alien.SaveSources 173 172 |> Ports.toBrain 174 - |> Return2.withModel updatedModel 175 - |> Return2.addCmd updatedCmd 173 + |> R2.withModel updatedModel 174 + |> R2.addCmd updatedCmd 176 175 177 176 Core.SaveTracks -> 178 177 model 179 178 |> UI.UserData.encodedTracks 180 179 |> Alien.broadcast Alien.SaveTracks 181 180 |> Ports.toBrain 182 - |> Return2.withModel model 181 + |> R2.withModel model 183 182 184 183 SignOut -> 185 - -- TODO: Reset user data 186 - ( { model | isAuthenticated = False } 187 - , Alien.SignOut 188 - |> Alien.trigger 189 - |> Ports.toBrain 190 - ) 184 + let 185 + alienSigningOut = 186 + Alien.SignOut 187 + |> Alien.trigger 188 + |> Ports.toBrain 189 + in 190 + { model 191 + | isAuthenticated = False 192 + , sources = UI.Sources.initialModel 193 + , tracks = UI.Tracks.initialModel 194 + } 195 + |> update (AuthenticationMsg UI.Authentication.DischargeMethod) 196 + |> R2.addCmd alienSigningOut 191 197 192 198 ----------------------------------------- 193 199 -- Children ··· 317 323 case Alien.tagFromString event.tag of 318 324 Just Alien.AddTracks -> 319 325 TracksMsg (UI.Tracks.Add event.data) 326 + 327 + Just Alien.AuthMethod -> 328 + -- My brain told me which auth method we're using, 329 + -- so we can tell the user in the UI. 330 + AuthenticationMsg (UI.Authentication.ActivateMethod event.data) 320 331 321 332 Just Alien.FinishedProcessingSources -> 322 333 SourcesMsg UI.Sources.FinishedProcessing
+36 -21
src/Applications/UI/Authentication.elm
··· 10 10 import Html.Styled as Html exposing (Html, a, button, div, em, fromUnstyled, img, span, text) 11 11 import Html.Styled.Attributes exposing (attribute, css, href, src, style, type_, width) 12 12 import Html.Styled.Events exposing (onClick) 13 - import Json.Encode as Encode 13 + import Json.Decode as Json 14 + import Json.Encode 14 15 import Material.Icons.Action as Icons 15 16 import Replying exposing (R3D3) 17 + import Return3 as R3 16 18 import Svg exposing (Svg) 17 19 import Tachyons.Classes as T 18 20 import UI.Kit ··· 25 27 26 28 27 29 type alias Model = 28 - { privateKeyInputFor : Maybe Authentication.Method 30 + { methodInUse : Maybe Authentication.Method 31 + , privateKeyInputFor : Maybe Authentication.Method 29 32 } 30 33 31 34 32 35 initialModel : Model 33 36 initialModel = 34 - { privateKeyInputFor = Nothing 37 + { methodInUse = Nothing 38 + , privateKeyInputFor = Nothing 35 39 } 36 40 37 41 ··· 41 45 42 46 type Msg 43 47 = Bypass 48 + | SignIn Authentication.Method 49 + ----------------------------------------- 50 + -- Method 51 + ----------------------------------------- 52 + | ActivateMethod Json.Value 53 + | DischargeMethod 54 + ----------------------------------------- 55 + -- Private Key 56 + ----------------------------------------- 44 57 | HidePrivateKeyScreen 45 58 | ShowPrivateKeyScreen Authentication.Method 46 - | SignIn Authentication.Method 47 59 48 60 49 61 update : Msg -> Model -> R3D3 Model Msg Reply 50 62 update msg model = 51 63 case msg of 52 64 Bypass -> 53 - ( model 54 - , Cmd.none 55 - , Nothing 56 - ) 57 - 58 - HidePrivateKeyScreen -> 59 - ( { model | privateKeyInputFor = Nothing } 60 - , Cmd.none 61 - , Nothing 62 - ) 63 - 64 - ShowPrivateKeyScreen method -> 65 - ( { model | privateKeyInputFor = Just method } 66 - , Cmd.none 67 - , Nothing 68 - ) 65 + R3.withNothing model 69 66 70 67 SignIn method -> 71 68 ( model 72 69 , method 73 70 |> Authentication.methodToString 74 - |> Encode.string 71 + |> Json.Encode.string 75 72 |> Alien.broadcast Alien.SignIn 76 73 |> Ports.toBrain 77 74 , Nothing 78 75 ) 76 + 77 + ----------------------------------------- 78 + -- Method 79 + ----------------------------------------- 80 + ActivateMethod encodedMethod -> 81 + R3.withNothing { model | methodInUse = Authentication.decodeMethod encodedMethod } 82 + 83 + DischargeMethod -> 84 + R3.withNothing { model | methodInUse = Nothing } 85 + 86 + ----------------------------------------- 87 + -- Private Key 88 + ----------------------------------------- 89 + HidePrivateKeyScreen -> 90 + R3.withNothing { model | privateKeyInputFor = Nothing } 91 + 92 + ShowPrivateKeyScreen method -> 93 + R3.withNothing { model | privateKeyInputFor = Just method } 79 94 80 95 81 96
+14 -2
src/Applications/UI/Settings.elm
··· 1 1 module UI.Settings exposing (view) 2 2 3 + import Authentication exposing (Method(..)) 3 4 import Chunky exposing (..) 4 5 import Html.Styled as Html exposing (Html, text) 5 6 import Material.Icons.Action as Icons ··· 45 46 ----------------------------------------- 46 47 , UI.Kit.canister 47 48 [ UI.Kit.h1 "Settings" 48 - , [ text "Changes are automatically saved." 49 + , [ text "Changes are saved automatically." 50 + , lineBreak 51 + , text "PS. You're storing the data for this application " 52 + , case model.authentication.methodInUse of 53 + Just Ipfs -> 54 + text "on IPFS." 55 + 56 + Just Local -> 57 + text "in this browser." 58 + 59 + Nothing -> 60 + text "on nothing, wtf?" 49 61 ] 50 - |> Html.span [] 62 + |> raw 51 63 |> UI.Kit.intro 52 64 ] 53 65 ]
+14 -2
src/Library/Authentication.elm
··· 1 - module Authentication exposing (EnclosedUserData, HypaethralUserData, Method(..), decode, decoder, emptyHypaethralUserData, methodFromString, methodToString) 1 + module Authentication exposing (EnclosedUserData, HypaethralUserData, Method(..), decode, decodeMethod, decoder, emptyHypaethralUserData, encodeMethod, methodFromString, methodToString) 2 2 3 3 import Json.Decode as Json 4 4 import Json.Decode.Pipeline exposing (optional) 5 + import Json.Encode 6 + import Maybe.Extra as Maybe 5 7 import Sources 6 8 import Sources.Encoding as Sources 7 9 import Tracks ··· 64 66 65 67 66 68 67 - -- 🔱 ░░ DECODING 69 + -- 🔱 ░░ DECODING & ENCODING 68 70 69 71 70 72 decode : Json.Value -> Result Json.Error HypaethralUserData ··· 72 74 Json.decodeValue decoder 73 75 74 76 77 + decodeMethod : Json.Value -> Maybe Method 78 + decodeMethod = 79 + Json.decodeValue (Json.map methodFromString Json.string) >> Result.toMaybe >> Maybe.join 80 + 81 + 75 82 decoder : Json.Decoder HypaethralUserData 76 83 decoder = 77 84 Json.succeed HypaethralUserData 78 85 |> optional "favourites" (Json.list Tracks.favouriteDecoder) [] 79 86 |> optional "sources" (Json.list Sources.decoder) [] 80 87 |> optional "tracks" (Json.list Tracks.trackDecoder) [] 88 + 89 + 90 + encodeMethod : Method -> Json.Value 91 + encodeMethod = 92 + methodToString >> Json.Encode.string