-
Notifications
You must be signed in to change notification settings - Fork 996
/
Copy pathview.cljs
122 lines (110 loc) · 5.77 KB
/
view.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
(ns status-im.contexts.shell.activity-center.notification.reply.view
(:require
[clojure.string :as string]
[quo.core :as quo]
[react-native.gesture :as gesture]
[status-im.common.not-implemented :as not-implemented]
[status-im.constants :as constants]
[status-im.contexts.chat.messenger.messages.content.sticker.view :as sticker]
[status-im.contexts.shell.activity-center.notification.common.view :as common]
[status-im.contexts.shell.activity-center.notification.reply.style :as style]
[utils.datetime :as datetime]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[utils.url :as url]))
;; NOTE: Replies support text, image and stickers only.
(defn- get-message-content
[{:keys [content-type] :as message} album-messages media-server-port]
(condp = content-type
constants/content-type-text
[quo/text {:style style/tag-text}
(get-in message [:content :text])]
constants/content-type-image
(let [images (or album-messages message)
image-urls (if album-messages
(map :image images)
[(get-in message [:content :image])])
image-local-urls (map (fn [url]
{:uri (url/replace-port url media-server-port)})
image-urls)]
[quo/activity-logs-photos
{:photos image-local-urls
:message-text (get-in message [:content :text])}])
constants/content-type-sticker
[sticker/sticker-message message]
constants/content-type-system-pinned-message
[not-implemented/not-implemented
[quo/text {:style style/tag-text}
(get-in message [:content :text])]]
;; NOTE: The following type (system-text) doesn't have a design yet.
;; https://github.com/status-im/status-mobile/issues/14915
constants/content-type-system-text
[not-implemented/not-implemented
[quo/text {:style style/tag-text}
(get-in message [:content :text])]]
nil))
(defn- swipeable
[{:keys [active-swipeable extra-fn]} child]
[common/swipeable
{:left-button common/swipe-button-read-or-unread
:left-on-press common/swipe-on-press-toggle-read
:right-button common/swipe-button-delete
:right-on-press common/swipe-on-press-delete
:active-swipeable active-swipeable
:extra-fn extra-fn}
child])
(defn view
[{:keys [notification set-swipeable-height customization-color] :as props}]
(let [{:keys [author chat-name community-id chat-id
message read timestamp album-messages]} notification
community-chat? (not (string/blank? community-id))
community (rf/sub [:communities/community community-id])
community-name (:name community)
community-image (get-in community [:images :thumbnail :uri])
media-server-port (rf/sub [:mediaserver/port])]
[swipeable props
[gesture/touchable-without-feedback
{:on-press (fn []
(rf/dispatch [:hide-popover])
(rf/dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]))}
[quo/activity-log
{:title (i18n/label :t/message-reply)
:customization-color customization-color
:on-layout set-swipeable-height
:icon :i/reply
:timestamp (datetime/timestamp->relative timestamp)
:unread? (not read)
:context [[common/user-avatar-tag author]
[quo/text {:style style/lowercase-text} (i18n/label :t/on)]
(if community-chat?
[quo/context-tag
{:type :channel
:blur? true
:size 24
:community-logo community-image
:community-name community-name
:channel-name chat-name}]
[quo/context-tag
{:type :group
:group-name chat-name
:blur? true
:size 24}])]
:message {:body-number-of-lines 1
:attachment (cond
(= (:content-type message)
constants/content-type-text)
:text
(= (:content-type message)
constants/content-type-image)
:photo
(= (:content-type message)
constants/content-type-sticker)
:sticker
(= (:content-type message)
constants/content-type-gif)
:gif
:else
nil)
:body (get-message-content message
album-messages
media-server-port)}}]]]))