mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Using elm-format for all files
This commit is contained in:
@ -1,58 +1,75 @@
|
||||
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 (..)
|
||||
module Main exposing (init, main)
|
||||
|
||||
import Api
|
||||
import Ports
|
||||
import Page
|
||||
import Data.Flags exposing (Flags)
|
||||
import App.Data exposing (..)
|
||||
import App.Update exposing (..)
|
||||
import App.View exposing (..)
|
||||
import Browser exposing (Document)
|
||||
import Browser.Navigation exposing (Key)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
import Page
|
||||
import Ports
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
|
||||
-- MAIN
|
||||
|
||||
main: Program Flags Model Msg
|
||||
|
||||
main : Program Flags Model Msg
|
||||
main =
|
||||
Browser.application
|
||||
{ init = init
|
||||
, view = viewDoc
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
, onUrlRequest = NavRequest
|
||||
, onUrlChange = NavChange
|
||||
}
|
||||
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 -> ( Model, Cmd Msg )
|
||||
init flags url key =
|
||||
let
|
||||
im = App.Data.init key url flags
|
||||
page = checkPage flags im.page
|
||||
(m, cmd) = if im.page == page then App.Update.initPage im page
|
||||
else (im, Page.goto page)
|
||||
im =
|
||||
App.Data.init key url flags
|
||||
|
||||
page =
|
||||
checkPage flags im.page
|
||||
|
||||
( m, cmd ) =
|
||||
if im.page == page then
|
||||
App.Update.initPage im page
|
||||
|
||||
else
|
||||
( im, Page.goto page )
|
||||
|
||||
sessionCheck =
|
||||
case m.flags.account of
|
||||
Just _ -> Api.loginSession flags SessionCheckResp
|
||||
Nothing -> Cmd.none
|
||||
in
|
||||
(m, Cmd.batch [ cmd, Ports.initElements(), Api.versionInfo flags VersionResp, sessionCheck ])
|
||||
Just _ ->
|
||||
Api.loginSession flags SessionCheckResp
|
||||
|
||||
viewDoc: Model -> Document Msg
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
in
|
||||
( m, Cmd.batch [ cmd, Api.versionInfo flags VersionResp, sessionCheck ] )
|
||||
|
||||
|
||||
viewDoc : Model -> Document Msg
|
||||
viewDoc model =
|
||||
{ title = model.flags.config.appName ++ ": " ++ (Page.pageName model.page)
|
||||
, body = [ (view model) ]
|
||||
{ title = model.flags.config.appName ++ ": " ++ Page.pageName model.page
|
||||
, body = [ view model ]
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- SUBSCRIPTIONS
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user