remove :chat-properties sub
This commit is contained in:
parent
1a056d0256
commit
29ccf9546f
|
@ -13,15 +13,6 @@
|
|||
[taoensso.timbre :as log]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(reg-sub
|
||||
:chat-properties
|
||||
(fn [db [_ properties]]
|
||||
(->> properties
|
||||
(map (fn [k]
|
||||
[k (get-in db[:chats (:current-chat-id db) k])
|
||||
]))
|
||||
(into {}))))
|
||||
|
||||
(reg-sub
|
||||
:chat-ui-props
|
||||
(fn [db [_ ui-element chat-id]]
|
||||
|
@ -34,10 +25,17 @@
|
|||
(fn [kb-height]
|
||||
(if ios? kb-height 0)))
|
||||
|
||||
(reg-sub
|
||||
:chats
|
||||
(fn [db ]
|
||||
(:chats db)))
|
||||
|
||||
(reg-sub
|
||||
:chat
|
||||
(fn [db [_ k chat-id]]
|
||||
(get-in db [:chats (or chat-id (:current-chat-id db)) k])))
|
||||
:<- [:chats]
|
||||
:<- [:get-current-chat-id]
|
||||
(fn [[chats id] [_ k chat-id]]
|
||||
(get-in chats [(or chat-id id) k])))
|
||||
|
||||
(reg-sub
|
||||
:get-current-chat-id
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.chat.views.actions
|
||||
(:require-macros [status-im.utils.views :refer [defview]])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :refer [subscribe dispatch]]
|
||||
[clojure.string :as s]
|
||||
[status-im.components.react :refer [view
|
||||
|
@ -113,23 +113,23 @@
|
|||
:font :default}
|
||||
subtitle])]]])
|
||||
|
||||
(defn actions-list-view []
|
||||
(let [{:keys [group-chat chat-id public?]}
|
||||
@(subscribe [:chat-properties [:group-chat :chat-id :public?]])
|
||||
members (subscribe [:current-chat-contacts])
|
||||
status-bar-height (get-in platform-specific [:component-styles :status-bar :default :height])]
|
||||
(fn []
|
||||
(when-let [actions (if group-chat
|
||||
(group-chat-items @members public?)
|
||||
(user-chat-items chat-id))]
|
||||
[view (merge
|
||||
(st/actions-wrapper status-bar-height)
|
||||
(get-in platform-specific [:component-styles :actions-list-view]))
|
||||
[view st/actions-separator]
|
||||
[view st/actions-view
|
||||
(for [action actions]
|
||||
(if action
|
||||
^{:key action} [action-view action]))]]))))
|
||||
(defview actions-list-view []
|
||||
(letsubs [group-chat [:chat :group-chat]
|
||||
chat-id [:chat :chat-id]
|
||||
public? [:chat :public?]
|
||||
members [:current-chat-contacts]
|
||||
status-bar-height (get-in platform-specific [:component-styles :status-bar :default :height])]
|
||||
(when-let [actions (if group-chat
|
||||
(group-chat-items members public?)
|
||||
(user-chat-items chat-id))]
|
||||
[view (merge
|
||||
(st/actions-wrapper status-bar-height)
|
||||
(get-in platform-specific [:component-styles :actions-list-view]))
|
||||
[view st/actions-separator]
|
||||
[view st/actions-view
|
||||
(for [action actions]
|
||||
(if action
|
||||
^{:key action} [action-view action]))]])))
|
||||
|
||||
(defn actions-view []
|
||||
[overlay {:on-click-outside #(dispatch [:set-chat-ui-props {:show-actions? false}])}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.chat.views.message.message
|
||||
(:require-macros [status-im.utils.views :refer [defview]])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :refer [subscribe dispatch]]
|
||||
[clojure.walk :as walk]
|
||||
[reagent.core :as r]
|
||||
|
@ -52,32 +52,35 @@
|
|||
(or incoming-name "Unknown contact"))]
|
||||
[text {:style st/author} name]))
|
||||
|
||||
(defn message-content-status [_]
|
||||
(let [{:keys [chat-id group-chat name color]} @(subscribe [:chat-properties [:chat-id :group-chat :name :color]])
|
||||
members (subscribe [:current-chat-contacts])]
|
||||
(fn [{:keys [messages-count content datemark]}]
|
||||
(let [{:keys [status]} (if group-chat
|
||||
{:photo-path nil
|
||||
:status nil
|
||||
:last-online 0}
|
||||
(first @members))]
|
||||
[view st/status-container
|
||||
[chat-icon-message-status chat-id group-chat name color false]
|
||||
[text {:style st/status-from
|
||||
:font :default
|
||||
:number-of-lines 1}
|
||||
(if (str/blank? name)
|
||||
(generate-gfy)
|
||||
(or (get-contact-translated chat-id :name name)
|
||||
(label :t/chat-name)))]
|
||||
(when (or status content)
|
||||
[text {:style st/status-text
|
||||
:font :default}
|
||||
(or status content)])
|
||||
(if (> messages-count 1)
|
||||
[view st/message-datemark
|
||||
[chat-datemark datemark]]
|
||||
[view st/message-empty-spacing])]))))
|
||||
(defview message-content-status
|
||||
[{:keys [messages-count content datemark]}]
|
||||
(letsubs [chat-id [:chat :chat-id]
|
||||
group-chat [:chat :group-id]
|
||||
name [:chat :name]
|
||||
color [:chat :color]
|
||||
members [:current-chat-contacts]]
|
||||
(let [{:keys [status]} (if group-chat
|
||||
{:photo-path nil
|
||||
:status nil
|
||||
:last-online 0}
|
||||
(first members))]
|
||||
[view st/status-container
|
||||
[chat-icon-message-status chat-id group-chat name color false]
|
||||
[text {:style st/status-from
|
||||
:font :default
|
||||
:number-of-lines 1}
|
||||
(if (str/blank? name)
|
||||
(generate-gfy)
|
||||
(or (get-contact-translated chat-id :name name)
|
||||
(label :t/chat-name)))]
|
||||
(when (or status content)
|
||||
[text {:style st/status-text
|
||||
:font :default}
|
||||
(or status content)])
|
||||
(if (> messages-count 1)
|
||||
[view st/message-datemark
|
||||
[chat-datemark datemark]]
|
||||
[view st/message-empty-spacing])])))
|
||||
|
||||
(defn message-content-audio [_]
|
||||
[view st/audio-container
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.chat.views.toolbar-content
|
||||
(:require-macros [status-im.utils.views :refer [defview]])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :refer [subscribe dispatch]]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.core :as t]
|
||||
|
@ -61,35 +61,33 @@
|
|||
(let [cnt (inc (count contacts))]
|
||||
(label-pluralize cnt :t/members-active)))]])))
|
||||
|
||||
(defn toolbar-content-view []
|
||||
(let [{:keys [group-chat
|
||||
name
|
||||
contacts
|
||||
chat-id
|
||||
public?]}
|
||||
@(subscribe [:chat-properties [:group-chat :name :contacts :chat-id :public?]])
|
||||
show-actions? (subscribe [:chat-ui-props :show-actions?])
|
||||
accounts (subscribe [:get :accounts])
|
||||
contact (subscribe [:get-in [:contacts chat-id]])
|
||||
sync-state (subscribe [:get :sync-state])
|
||||
creating? (subscribe [:get :creating-account?])]
|
||||
(fn []
|
||||
[view (st/chat-name-view (or (empty? @accounts)
|
||||
@show-actions?
|
||||
@creating?))
|
||||
(let [chat-name (if (str/blank? name)
|
||||
(generate-gfy)
|
||||
(or (get-contact-translated chat-id :name name)
|
||||
(label :t/chat-name)))]
|
||||
[text {:style st/chat-name-text
|
||||
:number-of-lines 1
|
||||
:font :toolbar-title}
|
||||
(if public?
|
||||
(str "#" chat-name)
|
||||
chat-name)])
|
||||
(if group-chat
|
||||
[group-last-activity {:contacts contacts
|
||||
:public? public?
|
||||
:sync-state @sync-state}]
|
||||
[last-activity {:online-text (online-text @contact chat-id)
|
||||
:sync-state @sync-state}])])))
|
||||
(defview toolbar-content-view []
|
||||
(letsubs [group-chat [:chat :group-chat]
|
||||
name [:chat :name]
|
||||
chat-id [:chat :chat-id]
|
||||
contacts [:chat :contacts]
|
||||
public? [:chat :public?]
|
||||
show-actions? [:chat-ui-props :show-actions?]
|
||||
accounts [:get :accounts]
|
||||
contact [:get-in [:contacts @chat-id]]
|
||||
sync-state [:get :sync-state]
|
||||
creating? [:get :creating-account?]]
|
||||
[view (st/chat-name-view (or (empty? accounts)
|
||||
show-actions?
|
||||
creating?))
|
||||
(let [chat-name (if (str/blank? name)
|
||||
(generate-gfy)
|
||||
(or (get-contact-translated chat-id :name name)
|
||||
(label :t/chat-name)))]
|
||||
[text {:style st/chat-name-text
|
||||
:number-of-lines 1
|
||||
:font :toolbar-title}
|
||||
(if public?
|
||||
(str "#" chat-name)
|
||||
chat-name)])
|
||||
(if group-chat
|
||||
[group-last-activity {:contacts contacts
|
||||
:public? public?
|
||||
:sync-state sync-state}]
|
||||
[last-activity {:online-text (online-text contact chat-id)
|
||||
:sync-state sync-state}])]))
|
||||
|
|
|
@ -62,4 +62,3 @@
|
|||
(fn ~params
|
||||
(let [~@vars-bindings]
|
||||
~body))}))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue