[#12918] Show history gaps only in public chats and communities

This commit is contained in:
Roman Volosovskyi 2021-12-24 13:39:51 +02:00
parent de3c08ba18
commit 29a7e4dc1c
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 25 additions and 21 deletions

View File

@ -12,28 +12,29 @@
(re-frame/dispatch [:chat.ui/fill-gaps chat-id gap-ids]))) (re-frame/dispatch [:chat.ui/fill-gaps chat-id gap-ids])))
(views/defview gap (views/defview gap
[{:keys [gap-ids chat-id gap-parameters]}] [{:keys [gap-ids chat-id gap-parameters public? community?]}]
(views/letsubs [in-progress? [:chats/fetching-gap-in-progress? (views/letsubs [in-progress? [:chats/fetching-gap-in-progress?
gap-ids gap-ids
chat-id] chat-id]
connected? [:mailserver/connected?] connected? [:mailserver/connected?]
first-gap? (= gap-ids #{:first-gap})] first-gap? (= gap-ids #{:first-gap})]
[react/view {:style (style/gap-container)} (when (or (not first-gap?) public? community?)
[react/touchable-highlight [react/view {:style (style/gap-container)}
{:on-press (when (and connected? (not in-progress?)) [react/touchable-highlight
(on-press chat-id gap-ids)) {:on-press (when (and connected? (not in-progress?))
:style style/touchable} (on-press chat-id gap-ids))
[react/view {:style style/label-container} :style style/touchable}
(if in-progress? [react/view {:style style/label-container}
[react/activity-indicator] (if in-progress?
[react/nested-text [react/activity-indicator]
{:style (style/gap-text connected?)} [react/nested-text
(i18n/label (if first-gap? :t/load-more-messages :t/fetch-messages)) {:style (style/gap-text connected?)}
(when first-gap? (i18n/label (if first-gap? :t/load-more-messages :t/fetch-messages))
[{:style style/date} (when first-gap?
(let [date (datetime/timestamp->long-date [{:style style/date}
(* 1000 (:from gap-parameters)))] (let [date (datetime/timestamp->long-date
(str (* 1000 (:from gap-parameters)))]
"\n" (str
(i18n/label :t/load-messages-before "\n"
{:date date})))])])]]])) (i18n/label :t/load-messages-before
{:date date})))])])]]])))

View File

@ -243,7 +243,8 @@
(defn render-fn [{:keys [outgoing type] :as message} (defn render-fn [{:keys [outgoing type] :as message}
idx idx
_ _
{:keys [group-chat public? current-public-key space-keeper chat-id show-input? message-pin-enabled edit-enabled in-pinned-view?]}] {:keys [group-chat public? community? current-public-key space-keeper
chat-id show-input? message-pin-enabled edit-enabled in-pinned-view?]}]
[react/view {:style (when (and platform/android? (not in-pinned-view?)) {:scaleY -1})} [react/view {:style (when (and platform/android? (not in-pinned-view?)) {:scaleY -1})}
(if (= type :datemark) (if (= type :datemark)
[message-datemark/chat-datemark (:value message)] [message-datemark/chat-datemark (:value message)]
@ -255,6 +256,7 @@
:incoming-group (and group-chat (not outgoing)) :incoming-group (and group-chat (not outgoing))
:group-chat group-chat :group-chat group-chat
:public? public? :public? public?
:community? community?
:current-public-key current-public-key :current-public-key current-public-key
:show-input? show-input? :show-input? show-input?
:message-pin-enabled message-pin-enabled :message-pin-enabled message-pin-enabled
@ -285,6 +287,7 @@
community-admin?))))] community-admin?))))]
{:group-chat group-chat {:group-chat group-chat
:public? public? :public? public?
:community? (not (nil? community-id))
:current-public-key current-public-key :current-public-key current-public-key
:space-keeper space-keeper :space-keeper space-keeper
:chat-id chat-id :chat-id chat-id