remove group-chat-local-version
This commit is contained in:
parent
ee042bd1c4
commit
47bae76c73
|
@ -197,10 +197,7 @@
|
||||||
(cond
|
(cond
|
||||||
(and (= :group-user-message message-type)
|
(and (= :group-user-message message-type)
|
||||||
(and (get-in cofx [:db :chats chat-id :contacts from])
|
(and (get-in cofx [:db :chats chat-id :contacts from])
|
||||||
;; Version 0 does not have a concept of joining, so any message is ok
|
(get-in cofx [:db :chats chat-id :members-joined (multiaccounts.model/current-public-key cofx)]))) chat-id
|
||||||
;; 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
|
|
||||||
(and (= :public-group-user-message message-type)
|
(and (= :public-group-user-message message-type)
|
||||||
(get-in cofx [:db :chats chat-id :public?])) chat-id
|
(get-in cofx [:db :chats chat-id :public?])) chat-id
|
||||||
(and (= :user-message message-type)
|
(and (= :user-message message-type)
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
(dissoc :referenced-messages :message-groups :gaps-loaded? :pagination-info
|
(dissoc :referenced-messages :message-groups :gaps-loaded? :pagination-info
|
||||||
:public? :group-chat :messages
|
:public? :group-chat :messages
|
||||||
:might-have-join-time-messages?
|
:might-have-join-time-messages?
|
||||||
:group-chat-local-version :loaded-unviewed-messages-ids
|
:loaded-unviewed-messages-ids
|
||||||
:messages-initialized? :contacts :admins :members-joined)))
|
:messages-initialized? :contacts :admins :members-joined)))
|
||||||
|
|
||||||
(defn <-rpc [chat]
|
(defn <-rpc [chat]
|
||||||
|
@ -143,7 +143,6 @@
|
||||||
(update :membership-updates (partial unmarshal-membership-updates (:id chat)))
|
(update :membership-updates (partial unmarshal-membership-updates (:id chat)))
|
||||||
(update :last-message-content utils/safe-read-message-content)
|
(update :last-message-content utils/safe-read-message-content)
|
||||||
(update :last-clock-value utils.clocks/safe-timestamp)
|
(update :last-clock-value utils.clocks/safe-timestamp)
|
||||||
(assoc :group-chat-local-version 1) ;; TODO(cammellos): this can be removed
|
|
||||||
(dissoc :chatType :members)))
|
(dissoc :chatType :members)))
|
||||||
|
|
||||||
(fx/defn save-chat [cofx {:keys [chat-id] :as chat}]
|
(fx/defn save-chat [cofx {:keys [chat-id] :as chat}]
|
||||||
|
|
|
@ -483,7 +483,6 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(models.chat/upsert-chat {:chat-id chat-id
|
(models.chat/upsert-chat {:chat-id chat-id
|
||||||
:name (:name new-group)
|
:name (:name new-group)
|
||||||
:group-chat-local-version (get previous-chat :group-chat-local-version 1)
|
|
||||||
:is-active (or member?
|
:is-active (or member?
|
||||||
(get previous-chat :is-active true))
|
(get previous-chat :is-active true))
|
||||||
:group-chat true
|
:group-chat true
|
||||||
|
|
|
@ -10,16 +10,10 @@
|
||||||
(map #(assoc % :from from) events))
|
(map #(assoc % :from from) events))
|
||||||
all-updates))
|
all-updates))
|
||||||
|
|
||||||
(defn joined-event?
|
(defn joined?
|
||||||
[public-key {:keys [members-joined] :as chat}]
|
[public-key {:keys [members-joined] :as chat}]
|
||||||
(contains? members-joined public-key))
|
(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?
|
(defn invited?
|
||||||
[my-public-key {:keys [contacts]}]
|
[my-public-key {:keys [contacts]}]
|
||||||
(contains? contacts my-public-key))
|
(contains? contacts my-public-key))
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
:pagination-info {}
|
:pagination-info {}
|
||||||
:last-message-content "content"
|
:last-message-content "content"
|
||||||
:last-message-content-type "type"
|
:last-message-content-type "type"
|
||||||
:group-chat-local-version 1
|
|
||||||
:chat-id "chat-id"
|
:chat-id "chat-id"
|
||||||
:loaded-unviewed-messages-ids []
|
:loaded-unviewed-messages-ids []
|
||||||
:timestamp 2
|
:timestamp 2
|
||||||
|
@ -132,7 +131,6 @@
|
||||||
:members #{"a" "b"}}]}}
|
:members #{"a" "b"}}]}}
|
||||||
:unviewed-messages-count 2
|
:unviewed-messages-count 2
|
||||||
:is-active true
|
:is-active true
|
||||||
:group-chat-local-version 1
|
|
||||||
:chat-id "chat-id"
|
:chat-id "chat-id"
|
||||||
:timestamp 2}]
|
:timestamp 2}]
|
||||||
(testing "from-rpc"
|
(testing "from-rpc"
|
||||||
|
|
Loading…
Reference in New Issue