From 47bae76c7320362cca8ec8ee0065d87b4d4677e8 Mon Sep 17 00:00:00 2001 From: yenda Date: Sun, 15 Sep 2019 20:25:34 +0200 Subject: [PATCH] remove group-chat-local-version --- src/status_im/chat/models/message.cljs | 5 +---- src/status_im/data_store/chats.cljs | 3 +-- src/status_im/group_chats/core.cljs | 1 - src/status_im/group_chats/db.cljs | 8 +------- test/cljs/status_im/test/data_store/chats.cljs | 2 -- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/status_im/chat/models/message.cljs b/src/status_im/chat/models/message.cljs index c9ea125196..3e26ea2690 100644 --- a/src/status_im/chat/models/message.cljs +++ b/src/status_im/chat/models/message.cljs @@ -197,10 +197,7 @@ (cond (and (= :group-user-message message-type) (and (get-in cofx [:db :chats chat-id :contacts from]) - ;; Version 0 does not have a concept of joining, so any message is ok - ;; otherwise check we joined - (or (= 0 (get-in cofx [:db :chats chat-id :group-chat-local-version])) - (get-in cofx [:db :chats chat-id :members-joined (multiaccounts.model/current-public-key cofx)])))) chat-id + (get-in cofx [:db :chats chat-id :members-joined (multiaccounts.model/current-public-key cofx)]))) chat-id (and (= :public-group-user-message message-type) (get-in cofx [:db :chats chat-id :public?])) chat-id (and (= :user-message message-type) diff --git a/src/status_im/data_store/chats.cljs b/src/status_im/data_store/chats.cljs index 3033996e31..e22325ae9c 100644 --- a/src/status_im/data_store/chats.cljs +++ b/src/status_im/data_store/chats.cljs @@ -124,7 +124,7 @@ (dissoc :referenced-messages :message-groups :gaps-loaded? :pagination-info :public? :group-chat :messages :might-have-join-time-messages? - :group-chat-local-version :loaded-unviewed-messages-ids + :loaded-unviewed-messages-ids :messages-initialized? :contacts :admins :members-joined))) (defn <-rpc [chat] @@ -143,7 +143,6 @@ (update :membership-updates (partial unmarshal-membership-updates (:id chat))) (update :last-message-content utils/safe-read-message-content) (update :last-clock-value utils.clocks/safe-timestamp) - (assoc :group-chat-local-version 1) ;; TODO(cammellos): this can be removed (dissoc :chatType :members))) (fx/defn save-chat [cofx {:keys [chat-id] :as chat}] diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index a7ba3b628b..1943a64f8e 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -483,7 +483,6 @@ (fx/merge cofx (models.chat/upsert-chat {:chat-id chat-id :name (:name new-group) - :group-chat-local-version (get previous-chat :group-chat-local-version 1) :is-active (or member? (get previous-chat :is-active true)) :group-chat true diff --git a/src/status_im/group_chats/db.cljs b/src/status_im/group_chats/db.cljs index e62b9a651a..7e33b4ce7f 100644 --- a/src/status_im/group_chats/db.cljs +++ b/src/status_im/group_chats/db.cljs @@ -10,16 +10,10 @@ (map #(assoc % :from from) events)) all-updates)) -(defn joined-event? +(defn joined? [public-key {:keys [members-joined] :as chat}] (contains? members-joined public-key)) -(defn joined? - [public-key {:keys [group-chat-local-version] :as chat}] - ;; We consider group chats with local version of 0 as joined for local events - (or (zero? group-chat-local-version) - (joined-event? public-key chat))) - (defn invited? [my-public-key {:keys [contacts]}] (contains? contacts my-public-key)) diff --git a/test/cljs/status_im/test/data_store/chats.cljs b/test/cljs/status_im/test/data_store/chats.cljs index 5d81f6ccb8..30e7e467c1 100644 --- a/test/cljs/status_im/test/data_store/chats.cljs +++ b/test/cljs/status_im/test/data_store/chats.cljs @@ -30,7 +30,6 @@ :pagination-info {} :last-message-content "content" :last-message-content-type "type" - :group-chat-local-version 1 :chat-id "chat-id" :loaded-unviewed-messages-ids [] :timestamp 2 @@ -132,7 +131,6 @@ :members #{"a" "b"}}]}} :unviewed-messages-count 2 :is-active true - :group-chat-local-version 1 :chat-id "chat-id" :timestamp 2}] (testing "from-rpc"