handlers+subs for dashboard banner

This commit is contained in:
Martin Klepsch 2018-04-17 12:44:58 +02:00 committed by Tetiana Churikova
parent f826cf16d7
commit 6e84fa0f49
2 changed files with 26 additions and 1 deletions

View File

@ -59,7 +59,7 @@
:initialize-db
[(inject-cofx :store)]
(fn [{:keys [db store]} [_]]
{:db (merge db/default-db store)}))
{:db (merge db/default-db store)}))
(reg-event-fx
@ -223,6 +223,13 @@
:owner-bounties issues
:owner-bounties-loading? false)))
(reg-event-fx
:dashboard/mark-banner-as-seen
[(inject-cofx :store)]
(fn [{:keys [db store]} [_ banner-id]]
{:db (update-in db [:dashboard/seen-banners] (fnil conj #{}) banner-id)
:store (update-in store [:dashboard/seen-banners] (fnil conj #{}) banner-id)}))
(defn get-ls-token [db token]
(let [login (get-in db [:user :login])]
(get-in db [:tokens login token])))

View File

@ -96,6 +96,24 @@
:unpaid {:count (count unpaid)
:combined-usd-value (sum-dollars unpaid)}})))
(reg-sub
:dashboard/seen-banners
(fn [db _] (:dashboard/seen-banners db)))
(reg-sub
:dashboard/banner-msg
:<- [:user]
:<- [:dashboard/seen-banners]
(fn [[user seen-banners] _]
(cond
(not (contains? seen-banners "bounty-issuer-salute"))
{:name (or (some-> (:name user) (string/split #"\s") first)
(:login user))
:banner-id "bounty-issuer-salute"}
#_(not (contains? seen-banners "new-dashboard-info"))
#_{:banner-id "new-dashboard-info"})))
(reg-sub
:pagination
(fn [db [_ table]]