revert preload chats

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-08-26 07:48:29 +02:00
parent 3942528cc1
commit 5f1f129d59
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
5 changed files with 8 additions and 32 deletions

View File

@ -29,24 +29,14 @@
new-chats) new-chats)
chats (merge old-chats chats)] chats (merge old-chats chats)]
{:db (assoc db :chats chats {:db (assoc db :chats chats
:chats/all-chats-loading? false
:chats/loading? false)})) :chats/loading? false)}))
(fx/defn initialize-chats (fx/defn initialize-chats
"Initialize persisted chats on startup" "Initialize persisted chats on startup"
[cofx] [cofx]
(data-store.chats/fetch-some-chats-rpc cofx {:num 60 (data-store.chats/fetch-chats-rpc cofx {:on-success
:on-success #(re-frame/dispatch
#(re-frame/dispatch [:chats-list/load-success %])}))
[:chats-list/load-success %])}))
(fx/defn load-all-chats
"Initialize persisted chats on startup"
{:events [:load-all-chats]}
[{:keys [db]}]
(when-not (:chats/all-chats-loaded? db)
(fx/merge {:db (assoc db :chats/all-chats-loaded? true :chats/all-chats-loading? true)}
(data-store.chats/fetch-chats-rpc {:on-success #(re-frame/dispatch [:chats-list/load-success %])}))))
(fx/defn handle-failed-loading-messages (fx/defn handle-failed-loading-messages
{:events [::failed-loading-messages]} {:events [::failed-loading-messages]}

View File

@ -70,14 +70,8 @@
(update :last-message #(when % (messages/<-rpc %))) (update :last-message #(when % (messages/<-rpc %)))
(dissoc :members))) (dissoc :members)))
(fx/defn fetch-chats-rpc [_ {:keys [on-success]}] (fx/defn fetch-chats-rpc [cofx {:keys [on-success]}]
{::json-rpc/call [{:method (json-rpc/call-ext-method "chats") {::json-rpc/call [{:method (json-rpc/call-ext-method "chats")
:params [] :params []
:on-success #(on-success (map <-rpc %)) :on-success #(on-success (map <-rpc %))
:on-failure #(log/error "failed to fetch chats" 0 -1 %)}]}) :on-failure #(log/error "failed to fetch chats" 0 -1 %)}]})
(fx/defn fetch-some-chats-rpc [_ {:keys [on-success num]}]
{::json-rpc/call [{:method (json-rpc/call-ext-method "latestActiveNChats")
:params [num]
:on-success #(on-success (map <-rpc %))
:on-failure #(log/error "failed to fetch chats" 0 -1 %)}]})

View File

@ -73,7 +73,6 @@
"wakuext_sendContactUpdate" {} "wakuext_sendContactUpdate" {}
"wakuext_sendContactUpdates" {} "wakuext_sendContactUpdates" {}
"wakuext_chats" {} "wakuext_chats" {}
"wakuext_latestActiveNChats" {}
"wakuext_activeChats" {} "wakuext_activeChats" {}
"wakuext_addSystemMessages" {} "wakuext_addSystemMessages" {}
"wakuext_deleteMessagesFrom" {} "wakuext_deleteMessagesFrom" {}

View File

@ -121,8 +121,6 @@
(reg-root-key-sub :group-chat/invitations :group-chat/invitations) (reg-root-key-sub :group-chat/invitations :group-chat/invitations)
(reg-root-key-sub :chats/mention-suggestions :chats/mention-suggestions) (reg-root-key-sub :chats/mention-suggestions :chats/mention-suggestions)
(reg-root-key-sub :chat/inputs-with-mentions :chat/inputs-with-mentions) (reg-root-key-sub :chat/inputs-with-mentions :chat/inputs-with-mentions)
(reg-root-key-sub :chats/all-chats-loading? :chats/all-chats-loading?)
;;browser ;;browser
(reg-root-key-sub :browsers :browser/browsers) (reg-root-key-sub :browsers :browser/browsers)
(reg-root-key-sub :browser/options :browser/options) (reg-root-key-sub :browser/options :browser/options)

View File

@ -141,8 +141,7 @@
(views/defview communities-and-chats [] (views/defview communities-and-chats []
(views/letsubs [{:keys [items search-filter]} [:home-items] (views/letsubs [{:keys [items search-filter]} [:home-items]
hide-home-tooltip? [:hide-home-tooltip?] hide-home-tooltip? [:hide-home-tooltip?]]
all-chats-loading? [:chats/all-chats-loading?]]
(if (and (empty? items) (if (and (empty? items)
(empty? search-filter) (empty? search-filter)
hide-home-tooltip? hide-home-tooltip?
@ -155,7 +154,6 @@
:keyboard-should-persist-taps :always :keyboard-should-persist-taps :always
:data items :data items
:render-fn render-fn :render-fn render-fn
:on-end-reached #(re-frame/dispatch [:load-all-chats])
:header [:<> :header [:<>
(when (or (seq items) @search-active? (seq search-filter)) (when (or (seq items) @search-active? (seq search-filter))
[search-input-wrapper search-filter (empty? items)]) [search-input-wrapper search-filter (empty? items)])
@ -163,12 +161,9 @@
(when (and (empty? items) (when (and (empty? items)
(or @search-active? (seq search-filter))) (or @search-active? (seq search-filter)))
[start-suggestion search-filter])] [start-suggestion search-filter])]
:footer [:<> :footer (if (and (not hide-home-tooltip?) (not @search-active?))
(when all-chats-loading? [home-tooltip-view]
[react/activity-indicator]) [react/view {:height 68}])}])))
(if (and (not hide-home-tooltip?) (not @search-active?))
[home-tooltip-view]
[react/view {:height 68}])]}])))
(views/defview chats-list [] (views/defview chats-list []
(views/letsubs [loading? [:chats/loading?]] (views/letsubs [loading? [:chats/loading?]]