makes it compile as is

This commit is contained in:
2019-11-11 15:49:39 +01:00
parent 5725d81236
commit 3aee238cd9
6 changed files with 794 additions and 845 deletions

View File

@@ -3,7 +3,7 @@ module Main exposing (..)
import Api exposing (Claim, Claims, Item, Loot, Player, Wealth)
import Browser
import Browser.Navigation as Nav
import Chest exposing (Msg)
import Page.Chest as Chest exposing (Msg)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
@@ -19,7 +19,7 @@ import Session exposing (..)
-- Main
main : Program () Model Msg
main : Program (Maybe Int) Model Msg
main =
Browser.application
{ init = init
@@ -36,7 +36,7 @@ main =
type Model
= Chest Chest.Model
| Admin Admin.Model
-- | Admin Admin.Model
| About
-- This is not what we really want.
@@ -51,14 +51,14 @@ type Model
-- - just loggend in -> See Loading page then Chest
-- - coming back being still logged in -> See Chest (or same as above)
init : Maybe Int -> Url.Url -> Nav.Key -> ( Model, Cmd Msg )
init flags url key =
init flags _ key =
case flags of
Just id ->
let
session =
Session.LoggedIn key <| Session.User.Player id
session = Session.playerSession key id
(chest, cmd) = Chest.init session
in
(Chest <| Chest.init id, Cmd.none)
(Chest chest, Cmd.map GotChestMsg cmd)
Nothing ->
(About, Cmd.none)
@@ -72,65 +72,66 @@ init flags url key =
view : Model -> Browser.Document Msg
view model =
let
(title, body) =
(title, content) =
case model of
Chest chest ->
("Loot-a-lot", Chest.view chest)
Admin session ->
("Administration", Admin.view session)
("Loot-a-lot", List.map (Html.map GotChestMsg) (Chest.view chest))
-- Admin admin ->
-- ("Administration", Admin.view admin)
About ->
("A propos", p [] ["A propos"])
("A propos", [ p [] [text "A propos"] ])
in
{ title = title
, body = body }
, body = content }
type Msg
= UrlChanged Url.Url
| LinkClicked Browser.UrlRequest
| GotChestMsg Chest.Msg
| GotAdminMsg Admin.Msg
-- | GotAdminMsg Admin.Msg
update msg model =
let
updateChest chestMsg =
case model of
Chest chest ->
let
(newChest, cmd) =
Chest.update chestMsg chest
in
(Chest newChest, Cmd.map GotChestMsg cmd)
_ -> (About, Cmd.none)
in
case msg of
LinkClicked urlRequest ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl model.navKey (Url.toString url) )
case model of
Chest chestModel ->
case urlRequest of
Browser.Internal url ->
( model, Nav.pushUrl chestModel.navKey (Url.toString url) )
Browser.External href ->
( setError ("External request '" ++ href ++ "'") model
, Cmd.none
)
Browser.External href ->
( model, Cmd.none)
_ -> (model, Cmd.none)
UrlChanged url ->
let
route =
routeParser url
Route.fromUrl url
in
case route of
Just page ->
{ model | route = page }
|> update
(case page of
-- Directly enter add mode on NewLoot view
NewLoot ->
ModeMsg (Modes.ModeSwitched Modes.Add)
other ->
ModeMsg (Modes.ModeSwitched Modes.None)
)
Nothing ->
( setError "Invalid route" model, Cmd.none )
Just (Route.Home content) ->
updateChest (Chest.SetContent content)
_ ->
(About, Cmd.none)
GotChestMsg chestMsg ->
let
( chest, cmd ) =
Chest.update chestMsg model.chest
in
( Chest chest, Cmd.map GotChestMsg cmd )
updateChest chestMsg
-- STATE Utils
-- SUBSCRIPTIONS