mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-13 01:39:33 +00:00
Fix setting ui theme for anonymous
This commit is contained in:
parent
3c0abcadb9
commit
70fa57587b
@ -11,6 +11,7 @@ import Browser exposing (UrlRequest)
|
|||||||
import Browser.Navigation exposing (Key)
|
import Browser.Navigation exposing (Key)
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
|
import Data.UiTheme exposing (UiTheme)
|
||||||
import Http
|
import Http
|
||||||
import Page exposing (Page(..))
|
import Page exposing (Page(..))
|
||||||
import Page.CollectiveSettings.Data
|
import Page.CollectiveSettings.Data
|
||||||
@ -46,6 +47,7 @@ type alias Model =
|
|||||||
, subs : Sub Msg
|
, subs : Sub Msg
|
||||||
, uiSettings : UiSettings
|
, uiSettings : UiSettings
|
||||||
, sidebarVisible : Bool
|
, sidebarVisible : Bool
|
||||||
|
, anonymousTheme : UiTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +96,7 @@ init key url flags_ settings =
|
|||||||
, subs = Sub.none
|
, subs = Sub.none
|
||||||
, uiSettings = settings
|
, uiSettings = settings
|
||||||
, sidebarVisible = settings.sideMenuVisible
|
, sidebarVisible = settings.sideMenuVisible
|
||||||
|
, anonymousTheme = Data.UiTheme.Light
|
||||||
}
|
}
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ Cmd.map UserSettingsMsg uc
|
[ Cmd.map UserSettingsMsg uc
|
||||||
|
@ -52,18 +52,18 @@ updateWithSub msg model =
|
|||||||
( { model | sidebarVisible = not model.sidebarVisible }, Cmd.none, Sub.none )
|
( { model | sidebarVisible = not model.sidebarVisible }, Cmd.none, Sub.none )
|
||||||
|
|
||||||
ToggleDarkMode ->
|
ToggleDarkMode ->
|
||||||
let
|
|
||||||
settings =
|
|
||||||
model.uiSettings
|
|
||||||
|
|
||||||
next =
|
|
||||||
Data.UiTheme.cycle settings.uiTheme
|
|
||||||
|
|
||||||
newSettings =
|
|
||||||
{ settings | uiTheme = next }
|
|
||||||
in
|
|
||||||
case model.flags.account of
|
case model.flags.account of
|
||||||
Just _ ->
|
Just _ ->
|
||||||
|
let
|
||||||
|
settings =
|
||||||
|
model.uiSettings
|
||||||
|
|
||||||
|
next =
|
||||||
|
Data.UiTheme.cycle settings.uiTheme
|
||||||
|
|
||||||
|
newSettings =
|
||||||
|
{ settings | uiTheme = next }
|
||||||
|
in
|
||||||
-- when authenticated, store it in settings only
|
-- when authenticated, store it in settings only
|
||||||
-- once new settings arrive via a subscription,
|
-- once new settings arrive via a subscription,
|
||||||
-- the ui is updated. so it is also updated on
|
-- the ui is updated. so it is also updated on
|
||||||
@ -74,8 +74,12 @@ updateWithSub msg model =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
let
|
||||||
|
next =
|
||||||
|
Data.UiTheme.cycle model.anonymousTheme
|
||||||
|
in
|
||||||
-- when not logged in, simply set the theme
|
-- when not logged in, simply set the theme
|
||||||
( { model | userMenuOpen = False }
|
( { model | userMenuOpen = False, anonymousTheme = next }
|
||||||
, Ports.setUiTheme next
|
, Ports.setUiTheme next
|
||||||
, Sub.none
|
, Sub.none
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user