Merge pull request #881 from eikek/fix/880-change-category

Only update category options if the query selected all tags
This commit is contained in:
mergify[bot] 2021-06-15 22:24:38 +00:00 committed by GitHub
commit 26265aeb39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,7 +66,7 @@ type Msg
= TableMsg Comp.TagTable.Msg = TableMsg Comp.TagTable.Msg
| FormMsg Comp.TagForm.Msg | FormMsg Comp.TagForm.Msg
| LoadTags | LoadTags
| TagResp (Result Http.Error TagList) | TagResp String (Result Http.Error TagList)
| SetViewMode ViewMode | SetViewMode ViewMode
| InitNewTag | InitNewTag
| Submit | Submit
@ -116,9 +116,9 @@ update flags msg model =
( { model | tagFormModel = m2 }, Cmd.map FormMsg c2 ) ( { model | tagFormModel = m2 }, Cmd.map FormMsg c2 )
LoadTags -> LoadTags ->
( { model | loading = True }, Api.getTags flags model.query TagResp ) ( { model | loading = True }, Api.getTags flags model.query (TagResp model.query) )
TagResp (Ok tags) -> TagResp query (Ok tags) ->
let let
m2 = m2 =
{ model | viewMode = Table, loading = False } { model | viewMode = Table, loading = False }
@ -128,11 +128,15 @@ update flags msg model =
in in
Util.Update.andThen1 Util.Update.andThen1
[ update flags (TableMsg (Comp.TagTable.SetTags tags.items)) [ update flags (TableMsg (Comp.TagTable.SetTags tags.items))
, update flags (FormMsg (Comp.TagForm.SetCategoryOptions cats)) , if query == "" then
update flags (FormMsg (Comp.TagForm.SetCategoryOptions cats))
else
\m -> ( m, Cmd.none )
] ]
m2 m2
TagResp (Err _) -> TagResp _ (Err _) ->
( { model | loading = False }, Cmd.none ) ( { model | loading = False }, Cmd.none )
SetViewMode m -> SetViewMode m ->
@ -213,7 +217,7 @@ update flags msg model =
m = m =
{ model | query = str } { model | query = str }
in in
( m, Api.getTags flags str TagResp ) ( m, Api.getTags flags str (TagResp str) )