Only update category options if the query selected all tags

The tag category is a bit special (sadly). The options are retrieved
by going through the tags. It must not update these, if a query
selects only a subset of tags.
This commit is contained in:
eikek 2021-06-16 00:14:35 +02:00
parent 31c4e14e76
commit 4a9ab2c1be

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) )