2017-07-17 09:25:57 +00:00
|
|
|
module Main exposing (..)
|
|
|
|
|
|
|
|
-- Local modules
|
|
|
|
|
|
|
|
import Models exposing (..)
|
|
|
|
import Routing exposing (parseLocation)
|
|
|
|
import Update exposing (update)
|
|
|
|
import Messages exposing (Msg(..))
|
|
|
|
import WebSocketCalls exposing (scheduleServer, sendInitMessage)
|
|
|
|
import Views exposing (view)
|
|
|
|
|
|
|
|
|
|
|
|
-- External modules
|
|
|
|
|
2017-07-17 15:59:38 +00:00
|
|
|
import Html.Lazy exposing (lazy)
|
2017-07-17 09:25:57 +00:00
|
|
|
import WebSocket exposing (listen)
|
|
|
|
import Navigation exposing (Location)
|
|
|
|
|
|
|
|
|
|
|
|
main : Program Flags Model Msg
|
|
|
|
main =
|
|
|
|
Navigation.programWithFlags
|
|
|
|
OnLocationChange
|
|
|
|
{ init = init
|
2017-07-17 15:59:38 +00:00
|
|
|
, view = lazy view
|
2017-07-17 09:25:57 +00:00
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
init : Flags -> Location -> ( Model, Cmd Msg )
|
|
|
|
init flags location =
|
2017-07-17 14:05:38 +00:00
|
|
|
let
|
|
|
|
currentRoute =
|
|
|
|
parseLocation location
|
|
|
|
|
|
|
|
emptyFilter =
|
2017-07-18 11:35:17 +00:00
|
|
|
Filter [] [] []
|
2017-07-17 14:05:38 +00:00
|
|
|
|
|
|
|
initModel =
|
2017-07-19 16:30:50 +00:00
|
|
|
Model [] [] [] [] [] flags emptyFilter currentRoute
|
2017-07-17 14:05:38 +00:00
|
|
|
in
|
2017-07-18 09:26:56 +00:00
|
|
|
initModel ! [ sendInitMessage flags.camp_slug ]
|
2017-07-17 09:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- SUBSCRIPTIONS
|
|
|
|
|
|
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
|
|
subscriptions model =
|
|
|
|
WebSocket.listen scheduleServer WebSocketPayload
|