docspell/modules/webapp/src/main/elm/Page/UserSettings/Update.elm

118 lines
3.7 KiB
Elm
Raw Normal View History

module Page.UserSettings.Update exposing (update)
import Comp.ChangePasswordForm
2020-01-04 23:12:23 +00:00
import Comp.EmailSettingsManage
2020-05-05 20:48:08 +00:00
import Comp.ImapSettingsManage
2020-04-17 22:50:46 +00:00
import Comp.NotificationForm
import Comp.ScanMailboxManage
import Comp.UiSettingsManage
2019-12-29 20:55:12 +00:00
import Data.Flags exposing (Flags)
import Page.UserSettings.Data exposing (..)
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
update flags msg model =
case msg of
SetTab t ->
let
2019-12-29 20:55:12 +00:00
m =
{ model | currentTab = Just t }
in
case t of
EmailSettingsTab ->
let
( em, c ) =
Comp.EmailSettingsManage.init flags
in
( { m | emailSettingsModel = em }, Cmd.map EmailSettingsMsg c, Sub.none )
2020-01-06 23:20:28 +00:00
ImapSettingsTab ->
let
( em, c ) =
Comp.ImapSettingsManage.init flags
in
( { m | imapSettingsModel = em }, Cmd.map ImapSettingsMsg c, Sub.none )
2020-01-06 23:20:28 +00:00
ChangePassTab ->
( m, Cmd.none, Sub.none )
2020-05-05 20:48:08 +00:00
NotificationTab ->
let
initCmd =
Cmd.map NotificationMsg
(Tuple.second (Comp.NotificationForm.init flags))
in
( m, initCmd, Sub.none )
2020-04-17 22:50:46 +00:00
ScanMailboxTab ->
let
initCmd =
Cmd.map ScanMailboxMsg
(Tuple.second (Comp.ScanMailboxManage.init flags))
in
( m, initCmd, Sub.none )
2020-05-18 07:55:49 +00:00
UiSettingsTab ->
( m, Cmd.none, Sub.none )
ChangePassMsg m ->
let
2019-12-29 20:55:12 +00:00
( m2, c2 ) =
Comp.ChangePasswordForm.update flags m model.changePassModel
in
( { model | changePassModel = m2 }, Cmd.map ChangePassMsg c2, Sub.none )
2020-01-04 23:12:23 +00:00
EmailSettingsMsg m ->
let
( m2, c2 ) =
Comp.EmailSettingsManage.update flags m model.emailSettingsModel
in
( { model | emailSettingsModel = m2 }, Cmd.map EmailSettingsMsg c2, Sub.none )
2020-04-17 22:50:46 +00:00
2020-05-05 20:48:08 +00:00
ImapSettingsMsg m ->
let
( m2, c2 ) =
Comp.ImapSettingsManage.update flags m model.imapSettingsModel
in
( { model | imapSettingsModel = m2 }, Cmd.map ImapSettingsMsg c2, Sub.none )
2020-05-05 20:48:08 +00:00
2020-04-17 22:50:46 +00:00
NotificationMsg lm ->
let
( m2, c2 ) =
Comp.NotificationForm.update flags lm model.notificationModel
in
( { model | notificationModel = m2 }
, Cmd.map NotificationMsg c2
, Sub.none
2020-04-17 22:50:46 +00:00
)
2020-05-18 07:55:49 +00:00
ScanMailboxMsg lm ->
let
( m2, c2 ) =
Comp.ScanMailboxManage.update flags lm model.scanMailboxModel
2020-05-18 07:55:49 +00:00
in
( { model | scanMailboxModel = m2 }
, Cmd.map ScanMailboxMsg c2
, Sub.none
)
GetUiSettings settings ->
let
( um, uc ) =
Comp.UiSettingsManage.init flags settings
in
( { model | uiSettingsModel = um }
, Cmd.map UiSettingsMsg uc
, Sub.none
)
UiSettingsMsg lm ->
let
( m2, c2, s2 ) =
Comp.UiSettingsManage.update flags lm model.uiSettingsModel
in
( { model | uiSettingsModel = m2 }
, Cmd.map UiSettingsMsg c2
, Sub.map UiSettingsMsg s2
2020-05-18 07:55:49 +00:00
)