mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-09-30 00:28:23 +00:00
Use search stats to populate search menu
This commit is contained in:
@@ -9,6 +9,7 @@ module Page.Share.Data exposing (Mode(..), Model, Msg(..), PageError(..), init)
|
||||
|
||||
import Api
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Api.Model.SearchStats exposing (SearchStats)
|
||||
import Api.Model.ShareSecret exposing (ShareSecret)
|
||||
import Api.Model.ShareVerifyResult exposing (ShareVerifyResult)
|
||||
import Comp.ItemCardList
|
||||
@@ -41,7 +42,6 @@ type alias Model =
|
||||
, verifyResult : ShareVerifyResult
|
||||
, passwordModel : PasswordModel
|
||||
, pageError : PageError
|
||||
, items : ItemLightList
|
||||
, searchMenuModel : Comp.SearchMenu.Model
|
||||
, powerSearchInput : Comp.PowerSearchInput.Model
|
||||
, searchInProgress : Bool
|
||||
@@ -58,7 +58,6 @@ emptyModel flags =
|
||||
, passwordFailed = False
|
||||
}
|
||||
, pageError = PageErrorNone
|
||||
, items = Api.Model.ItemLightList.empty
|
||||
, searchMenuModel = Comp.SearchMenu.init flags
|
||||
, powerSearchInput = Comp.PowerSearchInput.init
|
||||
, searchInProgress = False
|
||||
@@ -79,6 +78,7 @@ init shareId flags =
|
||||
type Msg
|
||||
= VerifyResp (Result Http.Error ShareVerifyResult)
|
||||
| SearchResp (Result Http.Error ItemLightList)
|
||||
| StatsResp (Result Http.Error SearchStats)
|
||||
| SetPassword String
|
||||
| SubmitPassword
|
||||
| SearchMenuMsg Comp.SearchMenu.Msg
|
||||
|
@@ -91,6 +91,16 @@ update flags settings shareId msg model =
|
||||
SearchResp (Err err) ->
|
||||
noSub ( { model | pageError = PageErrorHttp err, searchInProgress = False }, Cmd.none )
|
||||
|
||||
StatsResp (Ok stats) ->
|
||||
update flags
|
||||
settings
|
||||
shareId
|
||||
(SearchMenuMsg (Comp.SearchMenu.setFromStats stats))
|
||||
model
|
||||
|
||||
StatsResp (Err err) ->
|
||||
noSub ( { model | pageError = PageErrorHttp err }, Cmd.none )
|
||||
|
||||
SetPassword pw ->
|
||||
let
|
||||
pm =
|
||||
@@ -191,8 +201,14 @@ makeSearchCmd flags model =
|
||||
, query = Q.renderMaybe mq
|
||||
, searchMode = Just (Data.SearchMode.asString Data.SearchMode.Normal)
|
||||
}
|
||||
|
||||
searchCmd =
|
||||
Api.searchShare flags model.verifyResult.token (request xq) SearchResp
|
||||
|
||||
statsCmd =
|
||||
Api.searchShareStats flags model.verifyResult.token (request xq) StatsResp
|
||||
in
|
||||
Api.searchShare flags model.verifyResult.token (request xq) SearchResp
|
||||
Cmd.batch [ searchCmd, statsCmd ]
|
||||
|
||||
|
||||
linkTargetMsg : LinkTarget -> Maybe Msg
|
||||
|
Reference in New Issue
Block a user