checking pending messages when user appears online (#210)

Former-commit-id: 7f21ab2d3c
This commit is contained in:
alwxndr 2016-09-08 08:52:34 +03:00 committed by Roman Volosovskyi
parent fc03bab3d3
commit 9a1593f0ef
3 changed files with 7 additions and 4 deletions

View File

@ -8,8 +8,9 @@
[reagent "0.5.1" :exclusions [cljsjs/react]] [reagent "0.5.1" :exclusions [cljsjs/react]]
[re-frame "0.7.0"] [re-frame "0.7.0"]
[prismatic/schema "1.0.4"] [prismatic/schema "1.0.4"]
^{:voom {:repo "git@github.com:status-im/status-lib.git" :branch "master"}} ^{:voom {:repo "git@github.com:status-im/status-lib.git"
[status-im/protocol "0.2.1-20160908_061908-geefb360"] :branch "master"}}
[status-im/protocol "0.2.2-20160909_082306-gcfbb92b"]
[natal-shell "0.3.0"] [natal-shell "0.3.0"]
[com.andrewmcveigh/cljs-time "0.4.0"] [com.andrewmcveigh/cljs-time "0.4.0"]
[tailrecursion/cljs-priority-map "1.2.0"] [tailrecursion/cljs-priority-map "1.2.0"]

View File

@ -179,7 +179,8 @@
(u/side-effect! (u/side-effect!
(fn [db [_ from {last-online :at :as payload}]] (fn [db [_ from {last-online :at :as payload}]]
(let [prev-last-online (get-in db [:contacts from :last-online])] (let [prev-last-online (get-in db [:contacts from :last-online])]
(if (< prev-last-online last-online) (when (< prev-last-online last-online)
(api/resend-pending-messages from)
(dispatch [:update-contact! {:whisper-identity from (dispatch [:update-contact! {:whisper-identity from
:last-online last-online}])))))) :last-online last-online}]))))))

View File

@ -12,7 +12,8 @@
(defn get-pending-messages [] (defn get-pending-messages []
(let [collection (-> (r/get-by-fields :account :pending-message :or [[:status :sending] (let [collection (-> (r/get-by-fields :account :pending-message :or [[:status :sending]
[:status :sent]]) [:status :sent]
[:status :failed]])
(r/sorted :timestamp :desc) (r/sorted :timestamp :desc)
(r/collection->map))] (r/collection->map))]
(->> collection (->> collection