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(..))
|
2017-07-20 09:18:14 +00:00
|
|
|
import WebSocketCalls exposing (sendInitMessage)
|
2017-07-17 09:25:57 +00:00
|
|
|
import Views exposing (view)
|
|
|
|
|
|
|
|
|
|
|
|
-- External modules
|
|
|
|
|
|
|
|
import WebSocket exposing (listen)
|
|
|
|
import Navigation exposing (Location)
|
|
|
|
|
|
|
|
|
|
|
|
main : Program Flags Model Msg
|
|
|
|
main =
|
|
|
|
Navigation.programWithFlags
|
|
|
|
OnLocationChange
|
|
|
|
{ init = init
|
2017-07-23 16:30:27 +00:00
|
|
|
, view = 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 =
|
2017-07-23 16:30:27 +00:00
|
|
|
parseLocation location
|
2017-07-17 14:05:38 +00:00
|
|
|
|
|
|
|
emptyFilter =
|
2018-05-20 18:08:25 +00:00
|
|
|
Filter [] [] [] []
|
2017-07-17 14:05:38 +00:00
|
|
|
|
2017-07-23 00:51:39 +00:00
|
|
|
model =
|
2018-05-20 18:08:25 +00:00
|
|
|
Model [] [] [] [] [] [] [] flags emptyFilter location currentRoute False
|
2017-07-17 14:05:38 +00:00
|
|
|
in
|
2017-07-23 00:51:39 +00:00
|
|
|
model ! [ sendInitMessage flags.camp_slug flags.websocket_server ]
|
2017-07-17 09:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- SUBSCRIPTIONS
|
|
|
|
|
|
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
|
|
subscriptions model =
|
2017-07-20 09:18:14 +00:00
|
|
|
WebSocket.listen model.flags.websocket_server WebSocketPayload
|