mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 09:45:07 +00:00
59 lines
1.2 KiB
Elm
59 lines
1.2 KiB
Elm
module Main exposing (..)
|
|
|
|
import Browser exposing (Document)
|
|
import Browser.Navigation exposing (Key)
|
|
import Url exposing (Url)
|
|
import Html exposing (..)
|
|
import Html.Attributes exposing (..)
|
|
import Html.Events exposing (..)
|
|
|
|
import Api
|
|
import Ports
|
|
import Data.Flags exposing (Flags)
|
|
import App.Data exposing (..)
|
|
import App.Update exposing (..)
|
|
import App.View exposing (..)
|
|
|
|
|
|
-- MAIN
|
|
|
|
|
|
main =
|
|
Browser.application
|
|
{ init = init
|
|
, view = viewDoc
|
|
, update = update
|
|
, subscriptions = subscriptions
|
|
, onUrlRequest = NavRequest
|
|
, onUrlChange = NavChange
|
|
}
|
|
|
|
|
|
-- MODEL
|
|
|
|
|
|
init : Flags -> Url -> Key -> (Model, Cmd Msg)
|
|
init flags url key =
|
|
let
|
|
im = App.Data.init key url flags
|
|
(m, cmd) = App.Update.initPage im im.page
|
|
sessionCheck =
|
|
case m.flags.account of
|
|
Just acc -> Api.loginSession flags SessionCheckResp
|
|
Nothing -> Cmd.none
|
|
in
|
|
(m, Cmd.batch [ cmd, Ports.initElements(), Api.versionInfo flags VersionResp, sessionCheck ])
|
|
|
|
viewDoc: Model -> Document Msg
|
|
viewDoc model =
|
|
{ title = model.flags.config.appName
|
|
, body = [ (view model) ]
|
|
}
|
|
|
|
-- SUBSCRIPTIONS
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
subscriptions model =
|
|
Sub.none
|