diff --git a/src/status_im/app/events.cljs b/src/status_im/app/events.cljs index be6ea64d70..812ff8daea 100644 --- a/src/status_im/app/events.cljs +++ b/src/status_im/app/events.cljs @@ -5,42 +5,15 @@ [utils.re-frame :as rf])) - +;; whenever we need to publish notification we override the old and increment id (rf/reg-event-fx :app/notify-user (fn [{:keys [db]} [message]] - {:db (assoc-in db [:app :last-user-notification] message)})) - -(rf/reg-event-fx - :app/set-view-id - (fn [{:keys [db]} [value]] - (let [new-db (assoc db :view-id value)] - (tap> {:in :set-view-id - :value value}) - - {:db new-db}))) - -(rf/reg-event-fx - :app/inc-toast - (fn [{:keys [db]} [opts]] - (let [{:keys [ordered toasts]} (:toasts db) - next-toast-number (get-in db [:toasts :next-toast-number] 1) - id (or (:id opts) - (str "toast-" next-toast-number)) - update? (some #(= % id) ordered) - ordered (if (not update?) - (conj ordered id) - ordered) - toasts (assoc toasts id (dissoc opts :id))] - (cond-> {:db (-> db - (update :toasts assoc :ordered ordered :toasts toasts) - (update :toasts dissoc :hide-toasts-timer-set))} - - #_(and (not update?) (= (count ordered) 1)) - #_(assoc :show-toasts [(:view-id db) (or (:theme opts) (:theme db))]) - - #_(not (:id opts)) - #_(update-in [:db :toasts :next-toast-number] inc))))) + (let [last-message-id (get-in db [:app :last-user-notification] 0)] + {:db (assoc-in db + [:app :last-user-notification] + (merge message + {:id (inc last-message-id)}))}))) (comment (rf/dispatch [:app/notify-user @@ -50,8 +23,6 @@ {:type :negative :text "This is a test notification2"}]) - (rf/dispatch [:app/set-view-id :test1]) - (rf/dispatch [:app/set-view-id :test2]) @@ -59,16 +30,5 @@ {:type :positive :text "This is a test notification3"}]) - (rf/dispatch [:app/inc-toast - {:type :positive - :text "This is a test notification4"}]) - - (rf/dispatch [:app/inc-toast - {:type :positive - :text "This is a test notification5"}]) - - (rf/dispatch [:app/inc-toast - 1]) - - (rf/sub [:app/last-user-notification])) +) diff --git a/src/status_im/common/toasts/events.cljs b/src/status_im/common/toasts/events.cljs index 746321ed3f..d805e2f595 100644 --- a/src/status_im/common/toasts/events.cljs +++ b/src/status_im/common/toasts/events.cljs @@ -44,8 +44,8 @@ effect {:db db}] (if empty-ordered? (-> effect - (update-in [:db :toasts] assoc :hide-toasts-timer-set true) - (assoc :dispatch-later [{:ms 500 :dispatch [:toasts/hide-with-check]}])) + #_(update-in [:db :toasts] assoc :hide-toasts-timer-set true) + #_(assoc :dispatch-later [{:ms 500 :dispatch [:toasts/hide-with-check]}])) effect)))) (rf/defn close-all-toasts diff --git a/src/status_im/common/toasts/style.cljs b/src/status_im/common/toasts/style.cljs index d81934d6cf..704edadf25 100644 --- a/src/status_im/common/toasts/style.cljs +++ b/src/status_im/common/toasts/style.cljs @@ -3,12 +3,13 @@ (defn outmost-transparent-container [] - {:elevation 2 - :pointer-events :box-none - :padding-top (+ (safe-area/get-top) 6) - :flex-direction :column - :justify-content :center - :align-items :center}) + {:elevation 2 + :pointer-events :box-none + :padding-top (+ (safe-area/get-top) 6) + :flex-direction :column + :justify-content :center + :align-items :center + :background-color :yellow}) (def each-toast-container {:width "100%" diff --git a/src/status_im/common/toasts/view.cljs b/src/status_im/common/toasts/view.cljs index 6fa8d7dff5..559d0b53c8 100644 --- a/src/status_im/common/toasts/view.cljs +++ b/src/status_im/common/toasts/view.cljs @@ -58,9 +58,15 @@ (defn toasts [] - (tap> {:in :toasts - :data (rf/sub [:view-id])}) + (tap> {:in :toasts + :data (rf/sub [:view-id]) + :notification (rf/sub [:app/last-user-notification])}) + (rf/sub [:app/last-user-notification]) + (rf/dispatch [:toasts/upsert + {:type :positive + :text "This is a test notification3"}]) (->> (rf/sub [:toasts]) + #_(rf/sub [:app/last-user-notification]) :ordered (into [rn/view {:style (style/outmost-transparent-container)}] (map #(with-meta [f-container %] {:key %})))))