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)
chats (merge old-chats chats)]
{:db (assoc db :chats chats
:chats/all-chats-loading? false
:chats/loading? false)}))
(fx/defn initialize-chats
"Initialize persisted chats on startup"
[cofx]
(data-store.chats/fetch-some-chats-rpc cofx {:num 60
:on-success
#(re-frame/dispatch
[: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 %])}))))
(data-store.chats/fetch-chats-rpc cofx {:on-success
#(re-frame/dispatch
[:chats-list/load-success %])}))
(fx/defn handle-failed-loading-messages
{:events [::failed-loading-messages]}

View File

@ -70,14 +70,8 @@
(update :last-message #(when % (messages/<-rpc %)))
(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")
:params []
:on-success #(on-success (map <-rpc %))
: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_sendContactUpdates" {}
"wakuext_chats" {}
"wakuext_latestActiveNChats" {}
"wakuext_activeChats" {}
"wakuext_addSystemMessages" {}
"wakuext_deleteMessagesFrom" {}

View File

@ -121,8 +121,6 @@
(reg-root-key-sub :group-chat/invitations :group-chat/invitations)
(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 :chats/all-chats-loading? :chats/all-chats-loading?)
;;browser
(reg-root-key-sub :browsers :browser/browsers)
(reg-root-key-sub :browser/options :browser/options)

View File

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