Use new endpoint

This commit is contained in:
Icaro Motta 2024-11-18 16:39:28 -03:00
parent c66c954df3
commit 29cebe5132
No known key found for this signature in database
GPG Key ID: 009557D9D014DF07
4 changed files with 33 additions and 25 deletions

View File

@ -18,9 +18,8 @@
clock-value
"0x0000000000000000000000000000000000000000000000000000000000000000"))
(rf/defn update-chats-in-app-db
{:events [:chats-list/load-success]}
[{:keys [db]} ^js new-chats-js]
(rf/reg-event-fx :chats-list/load-success
(fn [{:keys [db]} [^js new-chats-js]]
(let [{:keys [all-chats chats-home-list]}
(reduce (fn [acc ^js chat-js]
(let [{:keys [chat-id profile-public-key timeline? community-id active] :as chat}
@ -33,10 +32,10 @@
{:all-chats {}
:chats-home-list #{}}
new-chats-js)]
{:db (assoc db
:chats all-chats
:chats-home-list chats-home-list
:chats/loading? false)}))
{:db (-> db
(update :chats merge all-chats)
(update :chats-home-list into chats-home-list)
(assoc :chats/loading? false))})))
(rf/defn load-chat-success
{:events [:chats-list/load-chat-success]}

View File

@ -134,9 +134,9 @@
unmarshal-members))
(re-frame/reg-fx :fetch-chats-preview
(fn [{:keys [on-success]}]
(fn [{:keys [on-success chat-preview-type]}]
(json-rpc/call {:method "wakuext_chatsPreview"
:params []
:params [chat-preview-type]
:js-response true
:on-success #(on-success ^js %)
:on-error #(log/error "failed to fetch chats" 0 -1 %)})))

View File

@ -76,6 +76,9 @@
(def ^:const timeline-chat-type 5)
(def ^:const community-chat-type 6)
(def ^:const chat-preview-type-community 0)
(def ^:const chat-preview-type-non-community 1)
(def ^:const contact-request-message-state-none 0)
(def ^:const contact-request-message-state-pending 1)
(def ^:const contact-request-message-state-accepted 2)

View File

@ -4,6 +4,7 @@
[native-module.core :as native-module]
[status-im.common.keychain.events :as keychain]
[status-im.config :as config]
[status-im.constants :as constants]
status-im.contexts.profile.login.effects
[status-im.contexts.profile.rpc :as profile.rpc]
[taoensso.timbre :as log]
@ -131,10 +132,15 @@
(let [new-account? (get db :onboarding/new-account?)]
{:db (assoc db :messenger/started? true)
:fx [[:fetch-chats-preview
{:on-success (fn [result]
{:chat-preview-type constants/chat-preview-type-non-community
:on-success (fn [result]
(rf/dispatch [:chats-list/load-success result])
(rf/dispatch [:communities/get-user-requests-to-join])
(rf/dispatch [:profile.login/get-chats-callback]))}]
[:fetch-chats-preview
{:chat-preview-type constants/chat-preview-type-community
:on-success (fn [result]
(rf/dispatch [:chats-list/load-success result])
(rf/dispatch [:communities/get-user-requests-to-join]))}]
(when (and (:syncing/fallback-flow? db) (:syncing/installation-id db))
[:dispatch [:pairing/finish-seed-phrase-fallback-syncing]])
(when-not new-account?