[fix 5738] unread counter disappears after app restart
`get-unviewed-messages` cofx was using the `current-public-key` field from app-db since it is not set at the point cofx are computed during the init phase this field is nil and therefore no unread messages were found the fix changes the cofx so that it returns a function as it is already done for many cofx that needs parameters that are not known at the time cofx are computed. Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
495f513de9
commit
6d84795b2a
|
@ -55,11 +55,8 @@
|
|||
(aget msg "message-id"))))))
|
||||
@chat-id->message-id))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:data-store/unviewed-messages
|
||||
(fn [{:keys [db] :as cofx} _]
|
||||
(assoc cofx
|
||||
:stored-unviewed-messages
|
||||
(defn- get-unviewed-messages
|
||||
[public-key]
|
||||
(into {}
|
||||
(map (fn [[chat-id user-statuses]]
|
||||
[chat-id (into #{} (map :message-id) user-statuses)]))
|
||||
|
@ -67,9 +64,16 @@
|
|||
(-> @core/account-realm
|
||||
(core/get-by-fields
|
||||
:user-status
|
||||
:and {:whisper-identity (:current-public-key db)
|
||||
:and {:whisper-identity public-key
|
||||
:status "received"})
|
||||
(core/all-clj :user-status)))))))
|
||||
(core/all-clj :user-status)))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:data-store/get-unviewed-messages
|
||||
(fn [cofx _]
|
||||
(assoc cofx
|
||||
:get-stored-unviewed-messages
|
||||
get-unviewed-messages)))
|
||||
|
||||
(defn- prepare-content [content]
|
||||
(if (string? content)
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
(re-frame/inject-cofx :data-store/all-chats)
|
||||
(re-frame/inject-cofx :data-store/get-messages)
|
||||
(re-frame/inject-cofx :data-store/get-user-statuses)
|
||||
(re-frame/inject-cofx :data-store/unviewed-messages)
|
||||
(re-frame/inject-cofx :data-store/get-unviewed-messages)
|
||||
(re-frame/inject-cofx :data-store/message-ids)
|
||||
(re-frame/inject-cofx :data-store/get-unanswered-requests)
|
||||
(re-frame/inject-cofx :data-store/get-local-storage-data)
|
||||
|
|
|
@ -46,12 +46,13 @@
|
|||
stored-unanswered-requests
|
||||
get-stored-messages
|
||||
get-stored-user-statuses
|
||||
stored-unviewed-messages
|
||||
get-stored-unviewed-messages
|
||||
stored-message-ids] :as cofx}]
|
||||
(let [chat->message-id->request (reduce (fn [acc {:keys [chat-id message-id] :as request}]
|
||||
(assoc-in acc [chat-id message-id] request))
|
||||
{}
|
||||
stored-unanswered-requests)
|
||||
stored-unviewed-messages (get-stored-unviewed-messages (:current-public-key db))
|
||||
chats (reduce (fn [acc {:keys [chat-id] :as chat}]
|
||||
(let [chat-messages (index-messages (get-stored-messages chat-id))
|
||||
message-ids (keys chat-messages)
|
||||
|
|
Loading…
Reference in New Issue