Fix stale subscriptions

This commit is contained in:
janherich 2017-12-20 18:52:43 +01:00
parent bcc2b12036
commit f3519b975c
No known key found for this signature in database
GPG Key ID: C23B473AFBE94D13
2 changed files with 15 additions and 16 deletions

View File

@ -73,8 +73,8 @@
:group-chat group-chat :group-chat group-chat
:current-public-key current-public-key)])) :current-public-key current-public-key)]))
(defview messages-view [group-chat] (defview messages-view [chat-id group-chat]
(letsubs [messages [:get-current-chat-messages] (letsubs [messages [:get-chat-messages chat-id]
current-public-key [:get-current-public-key]] current-public-key [:get-current-public-key]]
[react/list-view {:renderRow (fn [row _ index] [react/list-view {:renderRow (fn [row _ index]
(message-row {:group-chat group-chat (message-row {:group-chat group-chat
@ -87,7 +87,7 @@
:dataSource (listview/to-datasource-inverted messages)}])) :dataSource (listview/to-datasource-inverted messages)}]))
(defview chat [] (defview chat []
(letsubs [{:keys [group-chat input-text]} [:get-current-chat] (letsubs [{:keys [chat-id group-chat input-text]} [:get-current-chat]
show-actions? [:get-current-chat-ui-prop :show-actions?] show-actions? [:get-current-chat-ui-prop :show-actions?]
show-bottom-info? [:get-current-chat-ui-prop :show-bottom-info?] show-bottom-info? [:get-current-chat-ui-prop :show-bottom-info?]
show-emoji? [:get-current-chat-ui-prop :show-emoji?] show-emoji? [:get-current-chat-ui-prop :show-emoji?]
@ -100,7 +100,7 @@
(when (not= height layout-height) (when (not= height layout-height)
(re-frame/dispatch [:set-layout-height height]))))} (re-frame/dispatch [:set-layout-height height]))))}
[chat-toolbar] [chat-toolbar]
[messages-view group-chat] [messages-view chat-id group-chat]
[input/container {:text-empty? (string/blank? input-text)}] [input/container {:text-empty? (string/blank? input-text)}]
(when show-actions? (when show-actions?
[actions/actions-view]) [actions/actions-view])

View File

@ -56,10 +56,10 @@
(reg-sub (reg-sub
:get-current-chat :get-current-chat
(fn [_] :<- [:chats]
(let [current-chat-id (subscribe [:get-current-chat-id])] :<- [:get-current-chat-id]
(subscribe [:get-chat @current-chat-id]))) (fn [[chats current-chat-id]]
identity) (get chats current-chat-id)))
(reg-sub (reg-sub
:chat :chat
@ -133,10 +133,9 @@
:value (i18n/label :t/datetime-today)}))) :value (i18n/label :t/datetime-today)})))
(reg-sub (reg-sub
:get-current-chat-messages :get-chat-messages
(fn [_] (fn [[_ chat-id]]
(let [current-chat-id (subscribe [:get-current-chat-id])] (subscribe [:get-chat-message-datemark-groups chat-id]))
(subscribe [:get-chat-message-datemark-groups @current-chat-id])))
(fn [message-datemark-groups] (fn [message-datemark-groups]
(messages-stream message-datemark-groups))) (messages-stream message-datemark-groups)))