diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index 0057aa83dc..9e4a61ca8b 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -11,7 +11,6 @@ [status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.native-module.core :as status] [status-im.node.core :as node] - [status-im.transport.utils :as transport.utils] [status-im.ui.screens.mobile-network-settings.utils :as mobile-network-utils] @@ -21,6 +20,7 @@ [status-im.utils.handlers :as handlers] [status-im.utils.random :as rand] [status-im.utils.utils :as utils] + [status-im.mailserver.topics :as topics] [taoensso.timbre :as log])) ;; How do mailserver work ? @@ -362,12 +362,20 @@ (defn chats->never-synced-public-chats [chats] (into {} (filter (fn [[_ v]] (:might-have-join-time-messages? v)) chats))) +(defn- assoc-topic-chat [chat chats topic] + (assoc chats topic chat)) + +(defn- reduce-assoc-topic-chat [db chats-map chat-id chat] + (let [assoc-topic-chat (partial assoc-topic-chat chat) + topics (topics/topics-for-chat db chat-id)] + (reduce assoc-topic-chat chats-map topics))) + (fx/defn handle-request-success [{{:keys [chats] :as db} :db} {:keys [request-id topics]}] (when (:mailserver/current-request db) (let [by-topic-never-synced-chats (reduce-kv - #(assoc %1 (transport.utils/get-topic %2) %3) + (partial reduce-assoc-topic-chat db) {} (chats->never-synced-public-chats chats)) never-synced-chats-in-this-request diff --git a/src/status_im/transport/utils.cljs b/src/status_im/transport/utils.cljs index 3a1acc6b11..9a70c49c16 100644 --- a/src/status_im/transport/utils.cljs +++ b/src/status_im/transport/utils.cljs @@ -1,12 +1,6 @@ (ns ^{:doc "Utils for transport layer"} status-im.transport.utils - (:require [clojure.string :as string] - [status-im.ethereum.core :as ethereum])) - -(defn get-topic - "Get the topic of a group chat or public chat from the chat-id" - [chat-id] - (subs (ethereum/sha3 chat-id) 0 10)) + (:require [clojure.string :as string])) (defn extract-enode-id [enode] (-> enode