2019-07-22 22:53:30 +00:00
|
|
|
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
|
2020-05-21 18:50:40 +00:00
|
|
|
import Comp.ScanMailboxManage
|
2020-06-06 22:51:11 +00:00
|
|
|
import Comp.UiSettingsManage
|
2019-12-29 20:55:12 +00:00
|
|
|
import Data.Flags exposing (Flags)
|
|
|
|
import Page.UserSettings.Data exposing (..)
|
|
|
|
|
2019-07-22 22:53:30 +00:00
|
|
|
|
2020-06-06 22:51:11 +00:00
|
|
|
update : Flags -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
2019-07-22 22:53:30 +00:00
|
|
|
update flags msg model =
|
|
|
|
case msg of
|
|
|
|
SetTab t ->
|
|
|
|
let
|
2019-12-29 20:55:12 +00:00
|
|
|
m =
|
|
|
|
{ model | currentTab = Just t }
|
2020-06-06 22:51:11 +00:00
|
|
|
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
|
|
|
|
2020-06-06 22:51:11 +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
|
|
|
|
2020-06-06 22:51:11 +00:00
|
|
|
ChangePassTab ->
|
|
|
|
( m, Cmd.none, Sub.none )
|
2020-05-05 20:48:08 +00:00
|
|
|
|
2020-06-06 22:51:11 +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
|
|
|
|
2020-06-06 22:51:11 +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
|
|
|
|
2020-06-06 22:51:11 +00:00
|
|
|
UiSettingsTab ->
|
|
|
|
( m, Cmd.none, Sub.none )
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
|
|
ChangePassMsg m ->
|
|
|
|
let
|
2019-12-29 20:55:12 +00:00
|
|
|
( m2, c2 ) =
|
|
|
|
Comp.ChangePasswordForm.update flags m model.changePassModel
|
2019-07-22 22:53:30 +00:00
|
|
|
in
|
2020-06-06 22:51:11 +00:00
|
|
|
( { 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
|
2020-06-06 22:51:11 +00:00
|
|
|
( { 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
|
2020-06-06 22:51:11 +00:00
|
|
|
( { 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
|
2020-06-06 22:51:11 +00:00
|
|
|
, Sub.none
|
2020-04-17 22:50:46 +00:00
|
|
|
)
|
2020-05-18 07:55:49 +00:00
|
|
|
|
|
|
|
ScanMailboxMsg lm ->
|
|
|
|
let
|
|
|
|
( m2, c2 ) =
|
2020-05-21 18:50:40 +00:00
|
|
|
Comp.ScanMailboxManage.update flags lm model.scanMailboxModel
|
2020-05-18 07:55:49 +00:00
|
|
|
in
|
|
|
|
( { model | scanMailboxModel = m2 }
|
|
|
|
, Cmd.map ScanMailboxMsg c2
|
2020-06-06 22:51:11 +00:00
|
|
|
, Sub.none
|
|
|
|
)
|
|
|
|
|
|
|
|
GetUiSettings settings ->
|
2020-06-07 19:42:11 +00:00
|
|
|
let
|
|
|
|
( um, uc ) =
|
|
|
|
Comp.UiSettingsManage.init flags settings
|
|
|
|
in
|
|
|
|
( { model | uiSettingsModel = um }
|
|
|
|
, Cmd.map UiSettingsMsg uc
|
2020-06-06 22:51:11 +00:00
|
|
|
, 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
|
|
|
)
|