defaults to a single client if there is only one client.
This commit is contained in:
@@ -116,18 +116,26 @@
|
||||
(re-frame/reg-event-fx
|
||||
::received-initial
|
||||
(fn [{:keys [db]} [_ {clients :client}]]
|
||||
{:db (-> db
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :is-initial-loading? false)
|
||||
(assoc :client (or (when (= 1 (count clients)) (->> clients first :id ))
|
||||
(->> clients
|
||||
(map :id)
|
||||
(filter #(= % (:last-client-id db)))
|
||||
first))))
|
||||
:interval {:action :start
|
||||
:id :refresh-clients
|
||||
:frequency 600000
|
||||
:event [::refresh-clients]}}))
|
||||
(let [only-one-client (when (= 1 (count clients))
|
||||
(->> clients first :id ))]
|
||||
(when only-one-client
|
||||
(.setItem js/localStorage "last-client-id" only-one-client)
|
||||
(.setItem js/localStorage "last-selected-clients"
|
||||
(pr-str [(js/parseInt only-one-client)])))
|
||||
{:db (cond-> (-> db
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :is-initial-loading? false)
|
||||
(assoc :client (or only-one-client
|
||||
(->> clients
|
||||
(map :id)
|
||||
(filter #(= % (:last-client-id db)))
|
||||
first))))
|
||||
only-one-client (assoc :last-client-id only-one-client
|
||||
:selected-clients [only-one-client]))
|
||||
:interval {:action :start
|
||||
:id :refresh-clients
|
||||
:frequency 600000
|
||||
:event [::refresh-clients]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::refresh-clients
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
::client
|
||||
:<- [::selected-clients]
|
||||
(fn [selected-clients]
|
||||
(println "SELECTED CLIENTS ARE" selected-clients)
|
||||
(when (= 1 (count selected-clients))
|
||||
(first selected-clients))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user