[front/perf] load more show question title

This commit is contained in:
SouthFox 2023-09-20 23:38:36 +08:00
parent 5d2191dad3
commit 4c05a47117

View file

@ -97,6 +97,18 @@
(remove select-item db) (remove select-item db)
(merge (first (filter select-item db)) history-item)))}))) (merge (first (filter select-item db)) history-item)))})))
(reg-event-fx
:get-question-by-history
(fn [{:keys [db]} [_ {:keys [id type]}]]
(let [history (get db :history)
select-history (fn [x]
(and (= (:id x) id)
(= (:type x) type)))
question-history (first (filter select-history history))]
{:db (-> db
(assoc-in [:post :question :title] (:title question-history))
(assoc-in [:post :question :detail] (:detail question-history)))})))
(reg-event-fx (reg-event-fx
:get-question-success :get-question-success
(fn [{:keys [db]} [_ {body :body}]] (fn [{:keys [db]} [_ {body :body}]]
@ -113,7 +125,9 @@
{:db (-> db {:db (-> db
(assoc-in [:loading :question] false) (assoc-in [:loading :question] false)
(assoc-in [:post] body)) (assoc-in [:post] body))
:dispatch [:set-history params]}))) :dispatch-n [(when (nil? question)
[:get-question-by-history params])
[:set-history params]]})))
(reg-event-db (reg-event-db
:get-question-failure :get-question-failure