Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59553362d1 | ||
|
|
2f1ee972c2 | ||
|
|
3b3743d7a7 | ||
|
|
3a1737b65e | ||
|
|
2b78d323dc | ||
|
|
79ee136826 | ||
|
|
bf3886ea18 | ||
|
|
ff1068b53b | ||
|
|
622df31a12 | ||
|
|
ab8f65e6fa | ||
|
|
9674142fdc | ||
|
|
e18ca22ff7 | ||
|
|
31c226fcba | ||
|
|
292e3b7167 | ||
|
|
4c818ebaa6 | ||
|
|
a83fa4df87 | ||
|
|
3782cd5808 | ||
|
|
d1b094f986 | ||
|
|
6a8f061627 | ||
|
|
eef9f45834 | ||
|
|
865659552d | ||
|
|
656e545957 | ||
|
|
f9979a14c2 |
@@ -0,0 +1,35 @@
|
|||||||
|
(ns quo.components.status-link-previews.community.component-spec
|
||||||
|
(:require
|
||||||
|
[quo.components.status-link-previews.community.view :as view]
|
||||||
|
[test-helpers.component :as h]))
|
||||||
|
|
||||||
|
(def props
|
||||||
|
{:title "Some title"
|
||||||
|
:description "Some description"
|
||||||
|
:link "status.im"
|
||||||
|
:logo "data:image/png,logo-x"
|
||||||
|
:thumbnail "data:image/png,whatever"
|
||||||
|
:member-count 20
|
||||||
|
:active-members-count 20})
|
||||||
|
|
||||||
|
(h/describe "Status link previews - Community"
|
||||||
|
(h/test "default render"
|
||||||
|
(h/render [view/view])
|
||||||
|
(h/is-truthy (h/query-by-label-text :link-preview))
|
||||||
|
(h/is-null (h/query-by-label-text :button-enable-preview)))
|
||||||
|
|
||||||
|
(h/test "renders with most common props"
|
||||||
|
(h/render [view/view props])
|
||||||
|
(h/is-truthy (h/query-by-text (:title props)))
|
||||||
|
(h/is-truthy (h/query-by-text (:description props)))
|
||||||
|
(h/is-truthy (h/query-by-text (:link props)))
|
||||||
|
(h/is-truthy (h/query-by-label-text :logo))
|
||||||
|
(h/is-truthy (h/query-by-label-text :thumbnail)))
|
||||||
|
|
||||||
|
(h/test "does not render thumbnail if prop is not present"
|
||||||
|
(h/render [view/view (dissoc props :thumbnail)])
|
||||||
|
(h/is-null (h/query-by-label-text :thumbnail)))
|
||||||
|
|
||||||
|
(h/test "does not render logo if prop is not present"
|
||||||
|
(h/render [view/view (dissoc props :logo)])
|
||||||
|
(h/is-null (h/query-by-label-text :logo))))
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
(ns quo.components.status-link-previews.community.style
|
||||||
|
(:require [quo.foundations.colors :as colors]))
|
||||||
|
|
||||||
|
(defn loading-circle
|
||||||
|
[theme]
|
||||||
|
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||||
|
:margin-right 4
|
||||||
|
:width 16
|
||||||
|
:height 16
|
||||||
|
:border-radius 16})
|
||||||
|
|
||||||
|
(defn loading-stat
|
||||||
|
[theme]
|
||||||
|
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||||
|
:margin-right 4
|
||||||
|
:width 32
|
||||||
|
:height 8
|
||||||
|
:border-radius 16})
|
||||||
|
|
||||||
|
(def loading-stat-container {:flex-direction :row :align-items :center :margin-right 12})
|
||||||
|
|
||||||
|
(defn loading-first-line-bar
|
||||||
|
[theme]
|
||||||
|
{:style {:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||||
|
:width 145
|
||||||
|
:height 16
|
||||||
|
:border-radius 6}})
|
||||||
|
|
||||||
|
(defn loading-second-line-bar
|
||||||
|
[theme]
|
||||||
|
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||||
|
:width 112
|
||||||
|
:height 8
|
||||||
|
:border-radius 6
|
||||||
|
:margin-bottom 17})
|
||||||
|
|
||||||
|
(defn loading-thumbnail-box
|
||||||
|
[theme]
|
||||||
|
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||||
|
:margin-right 4
|
||||||
|
:width 271
|
||||||
|
:height 139
|
||||||
|
:border-radius 16})
|
||||||
|
|
||||||
|
(def thumbnail
|
||||||
|
{:width "100%"
|
||||||
|
:height 139
|
||||||
|
:margin-top 8
|
||||||
|
:border-radius 12})
|
||||||
|
|
||||||
|
(def row-spacing {:flex-direction :row :margin-bottom 12})
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
(ns quo.components.status-link-previews.community.view
|
||||||
|
(:require
|
||||||
|
[quo.components.community.community-stat.view :as community-stat]
|
||||||
|
[quo.components.links.link-preview.style :as style]
|
||||||
|
[quo.components.markdown.text :as text]
|
||||||
|
[quo.components.status-link-previews.community.style :as status-link-previews-style]
|
||||||
|
[quo.theme :as theme]
|
||||||
|
[react-native.core :as rn]))
|
||||||
|
|
||||||
|
(defn- description-comp
|
||||||
|
[description members-count active-members-count]
|
||||||
|
[rn/view
|
||||||
|
[text/text
|
||||||
|
{:size :paragraph-2
|
||||||
|
:number-of-lines 3
|
||||||
|
:accessibility-label :description} description]
|
||||||
|
[rn/view {:flex-direction :row :margin-top 12}
|
||||||
|
[community-stat/view
|
||||||
|
{:value members-count
|
||||||
|
:icon :i/members
|
||||||
|
:accessibility-label :members-count
|
||||||
|
:style {:margin-right 12}}]
|
||||||
|
[community-stat/view
|
||||||
|
{:value (or active-members-count 0)
|
||||||
|
:icon :i/active-members
|
||||||
|
:accessibility-label :active-members-count}]]])
|
||||||
|
|
||||||
|
(defn- title-comp
|
||||||
|
[title]
|
||||||
|
[text/text
|
||||||
|
{:size :paragraph-1
|
||||||
|
:number-of-lines 1
|
||||||
|
:weight :semi-bold
|
||||||
|
:style style/title
|
||||||
|
:accessibility-label :title}
|
||||||
|
title])
|
||||||
|
|
||||||
|
(defn- thumbnail-comp
|
||||||
|
[thumbnail]
|
||||||
|
[rn/image
|
||||||
|
{:style status-link-previews-style/thumbnail
|
||||||
|
:source (if (string? thumbnail)
|
||||||
|
{:uri thumbnail}
|
||||||
|
thumbnail)
|
||||||
|
:accessibility-label :thumbnail}])
|
||||||
|
|
||||||
|
(defn- logo-comp
|
||||||
|
[logo]
|
||||||
|
[rn/image
|
||||||
|
{:accessibility-label :logo
|
||||||
|
:source (if (string? logo)
|
||||||
|
{:uri logo}
|
||||||
|
logo)
|
||||||
|
:style style/logo}])
|
||||||
|
|
||||||
|
(defn- stat-loading
|
||||||
|
[theme]
|
||||||
|
[rn/view {:style status-link-previews-style/loading-stat-container}
|
||||||
|
[rn/view {:style (status-link-previews-style/loading-circle theme)}]
|
||||||
|
[rn/view {:style (status-link-previews-style/loading-stat theme)}]])
|
||||||
|
|
||||||
|
(defn- loading-view
|
||||||
|
[theme]
|
||||||
|
[rn/view
|
||||||
|
{:accessibility-label :loading}
|
||||||
|
[rn/view {:style status-link-previews-style/row-spacing}
|
||||||
|
[rn/view (status-link-previews-style/loading-circle theme)]
|
||||||
|
[rn/view (status-link-previews-style/loading-first-line-bar theme)]]
|
||||||
|
[rn/view {:style (status-link-previews-style/loading-second-line-bar theme)}]
|
||||||
|
[rn/view status-link-previews-style/row-spacing
|
||||||
|
[stat-loading theme]
|
||||||
|
[stat-loading theme]]
|
||||||
|
[rn/view {:style (status-link-previews-style/loading-thumbnail-box theme)}]])
|
||||||
|
|
||||||
|
(defn f-internal-view
|
||||||
|
[{:keys [title description loading? thumbnail-size icon banner members-count active-members-count
|
||||||
|
theme on-press]
|
||||||
|
:or {loading? false}}]
|
||||||
|
[rn/touchable-opacity
|
||||||
|
{:style (merge (style/container (not loading?))
|
||||||
|
{:width 295
|
||||||
|
:height 245})
|
||||||
|
:accessibility-label :link-preview
|
||||||
|
:on-press on-press}
|
||||||
|
(if loading?
|
||||||
|
[loading-view theme]
|
||||||
|
[:<>
|
||||||
|
[rn/view {:style style/header-container}
|
||||||
|
(when icon
|
||||||
|
[logo-comp icon])
|
||||||
|
[title-comp title]]
|
||||||
|
(when description
|
||||||
|
[description-comp description members-count active-members-count])
|
||||||
|
(when banner
|
||||||
|
[thumbnail-comp banner thumbnail-size])])])
|
||||||
|
|
||||||
|
(defn- internal-view
|
||||||
|
[props]
|
||||||
|
[:f> f-internal-view props])
|
||||||
|
|
||||||
|
(def view (theme/with-theme internal-view))
|
||||||
@@ -107,4 +107,3 @@
|
|||||||
[tag-resources size type resource icon-color label text-color labelled?]]]))
|
[tag-resources size type resource icon-color label text-color labelled?]]]))
|
||||||
|
|
||||||
(def tag (quo.theme/with-theme tag-internal))
|
(def tag (quo.theme/with-theme tag-internal))
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
quo.components.settings.settings-item.view
|
quo.components.settings.settings-item.view
|
||||||
quo.components.share.qr-code.view
|
quo.components.share.qr-code.view
|
||||||
quo.components.share.share-qr-code.view
|
quo.components.share.share-qr-code.view
|
||||||
|
quo.components.status-link-previews.community.view
|
||||||
quo.components.switchers.group-messaging-card.view
|
quo.components.switchers.group-messaging-card.view
|
||||||
quo.components.tabs.account-selector
|
quo.components.tabs.account-selector
|
||||||
quo.components.tabs.segmented-tab
|
quo.components.tabs.segmented-tab
|
||||||
@@ -281,6 +282,9 @@
|
|||||||
(def url-preview quo.components.links.url-preview.view/view)
|
(def url-preview quo.components.links.url-preview.view/view)
|
||||||
(def url-preview-list quo.components.links.url-preview-list.view/view)
|
(def url-preview-list quo.components.links.url-preview-list.view/view)
|
||||||
|
|
||||||
|
;;;; Status links
|
||||||
|
(def status-link-preview-community quo.components.status-link-previews.community.view/view)
|
||||||
|
|
||||||
;;;; List items
|
;;;; List items
|
||||||
(def account-item quo.components.list-items.account.view/view)
|
(def account-item quo.components.list-items.account.view/view)
|
||||||
(def account-list-card quo.components.list-items.account-list-card.view/view)
|
(def account-list-card quo.components.list-items.account-list-card.view/view)
|
||||||
|
|||||||
@@ -147,15 +147,48 @@
|
|||||||
preferred-name (get-in db [:profile/profile :preferred-name])
|
preferred-name (get-in db [:profile/profile :preferred-name])
|
||||||
emoji? (message-content/emoji-only-content? {:text input-text
|
emoji? (message-content/emoji-only-content? {:text input-text
|
||||||
:response-to message-id})]
|
:response-to message-id})]
|
||||||
{:chat-id current-chat-id
|
{:chat-id current-chat-id
|
||||||
:content-type (if emoji?
|
:content-type (if emoji?
|
||||||
constants/content-type-emoji
|
constants/content-type-emoji
|
||||||
constants/content-type-text)
|
constants/content-type-text)
|
||||||
:text input-text
|
:text input-text
|
||||||
:response-to message-id
|
:response-to message-id
|
||||||
:ens-name preferred-name
|
:ens-name preferred-name
|
||||||
:link-previews (map #(select-keys % [:url :title :description :thumbnail])
|
:link-previews (map #(select-keys % [:url :title :description :thumbnail])
|
||||||
(get-in db [:chat/link-previews :unfurled]))})))
|
(get-in db [:chat/link-previews :unfurled]))
|
||||||
|
:status-link-previews (map (fn [item]
|
||||||
|
{:url (:url item)
|
||||||
|
:community
|
||||||
|
{:community-id (get-in item [:community :community-id])
|
||||||
|
:color (get-in item
|
||||||
|
[:community :color])
|
||||||
|
:description (get-in item
|
||||||
|
[:community :description])
|
||||||
|
:display-name (get-in item
|
||||||
|
[:community :display-name])
|
||||||
|
:members-count (get-in item
|
||||||
|
[:community :members-count])
|
||||||
|
:active-members-count (get-in item
|
||||||
|
[:community :active-members-count])
|
||||||
|
:icon {:data-uri (get-in item
|
||||||
|
[:community :icon
|
||||||
|
:data-uri])
|
||||||
|
:width (get-in item
|
||||||
|
[:community :icon
|
||||||
|
:width])
|
||||||
|
:height (get-in item
|
||||||
|
[:community :icon
|
||||||
|
:height])}
|
||||||
|
:banner {:data-uri (get-in item
|
||||||
|
[:community :banner
|
||||||
|
:data-uri])
|
||||||
|
:width (get-in item
|
||||||
|
[:community :banner
|
||||||
|
:width])
|
||||||
|
:height (get-in item
|
||||||
|
[:community :banner
|
||||||
|
:height])}}})
|
||||||
|
(get-in db [:chat/status-link-previews :unfurled]))})))
|
||||||
|
|
||||||
(defn build-image-messages
|
(defn build-image-messages
|
||||||
[{db :db} chat-id input-text]
|
[{db :db} chat-id input-text]
|
||||||
@@ -193,6 +226,7 @@
|
|||||||
(rf/merge cofx
|
(rf/merge cofx
|
||||||
(clean-input current-chat-id)
|
(clean-input current-chat-id)
|
||||||
(link-preview/reset-unfurled)
|
(link-preview/reset-unfurled)
|
||||||
|
(link-preview/clear-status-link-previews)
|
||||||
(mentions/clear-mentions))))
|
(mentions/clear-mentions))))
|
||||||
|
|
||||||
(rf/defn send-messages
|
(rf/defn send-messages
|
||||||
@@ -205,6 +239,7 @@
|
|||||||
(rf/merge cofx
|
(rf/merge cofx
|
||||||
(clean-input (:current-chat-id db))
|
(clean-input (:current-chat-id db))
|
||||||
(link-preview/reset-unfurled)
|
(link-preview/reset-unfurled)
|
||||||
|
(link-preview/clear-status-link-previews)
|
||||||
(chat.message/send-messages messages)))))
|
(chat.message/send-messages messages)))))
|
||||||
|
|
||||||
(rf/defn send-audio-message
|
(rf/defn send-audio-message
|
||||||
@@ -239,25 +274,30 @@
|
|||||||
:as cofx} text {:keys [message-id quoted-message chat-id]}]
|
:as cofx} text {:keys [message-id quoted-message chat-id]}]
|
||||||
(rf/merge
|
(rf/merge
|
||||||
cofx
|
cofx
|
||||||
{:json-rpc/call [{:method "wakuext_editMessage"
|
{:json-rpc/call
|
||||||
:params [{:id message-id
|
[{:method "wakuext_editMessage"
|
||||||
:text text
|
:params [{:id message-id
|
||||||
:content-type (if (message-content/emoji-only-content?
|
:text text
|
||||||
{:text text
|
:content-type (if (message-content/emoji-only-content?
|
||||||
:response-to quoted-message})
|
{:text text
|
||||||
constants/content-type-emoji
|
:response-to quoted-message})
|
||||||
constants/content-type-text)
|
constants/content-type-emoji
|
||||||
:linkPreviews (map #(-> %
|
constants/content-type-text)
|
||||||
(select-keys [:url :title :description
|
:linkPreviews (map #(-> %
|
||||||
:thumbnail])
|
(select-keys [:url :title :description
|
||||||
data-store-messages/->link-preview-rpc)
|
:thumbnail])
|
||||||
(get-in db [:chat/link-previews :unfurled]))}]
|
data-store-messages/->link-preview-rpc)
|
||||||
:js-response true
|
(get-in db [:chat/link-previews :unfurled]))
|
||||||
:on-error #(log/error "failed to edit message " %)
|
:statusLinkPreviews (map
|
||||||
:on-success (fn [result]
|
data-store-messages/<-status-link-previews-rpc
|
||||||
(re-frame/dispatch [:sanitize-messages-and-process-response
|
(get-in db [:chat/status-link-previews :unfurled]))}]
|
||||||
result]))}]}
|
:js-response true
|
||||||
|
:on-error #(log/error "failed to edit message " %)
|
||||||
|
:on-success (fn [result]
|
||||||
|
(re-frame/dispatch [:sanitize-messages-and-process-response
|
||||||
|
result]))}]}
|
||||||
(link-preview/reset-unfurled)
|
(link-preview/reset-unfurled)
|
||||||
|
(link-preview/clear-status-link-previews)
|
||||||
(cancel-message-edit)))
|
(cancel-message-edit)))
|
||||||
|
|
||||||
(rf/defn send-current-message
|
(rf/defn send-current-message
|
||||||
|
|||||||
@@ -326,7 +326,7 @@
|
|||||||
(conj contacts user-pk)
|
(conj contacts user-pk)
|
||||||
contacts)]
|
contacts)]
|
||||||
(when (seq pks)
|
(when (seq pks)
|
||||||
{:json-rpc/call [{:method "wakuext_shareCommunity"
|
{:json-rpc/call [{:method "wakuext_shareCommunityV2"
|
||||||
:params [{:communityId community-id
|
:params [{:communityId community-id
|
||||||
:users pks}]
|
:users pks}]
|
||||||
:js-response true
|
:js-response true
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn ->rpc
|
(defn ->rpc
|
||||||
[{:keys [content] :as message}]
|
[{:keys [content]
|
||||||
|
:as message}]
|
||||||
(cond-> message
|
(cond-> message
|
||||||
content
|
content
|
||||||
(assoc :text (:text content)
|
(assoc :text (:text content)
|
||||||
@@ -16,6 +17,18 @@
|
|||||||
:community-id :communityId
|
:community-id :communityId
|
||||||
:clock-value :clock})))
|
:clock-value :clock})))
|
||||||
|
|
||||||
|
(defn- <-status-link-previews-rpc
|
||||||
|
[preview]
|
||||||
|
(-> preview
|
||||||
|
(update :community
|
||||||
|
set/rename-keys
|
||||||
|
{:communityId :community-id
|
||||||
|
:displayName :display-name
|
||||||
|
:membersCount :members-count
|
||||||
|
:activeMembersCount :active-members-count})
|
||||||
|
(update-in [:community :banner] set/rename-keys {:dataUri :data-uri})
|
||||||
|
(update-in [:community :icon] set/rename-keys {:dataUri :data-uri})))
|
||||||
|
|
||||||
(defn- <-link-preview-rpc
|
(defn- <-link-preview-rpc
|
||||||
[preview]
|
[preview]
|
||||||
(update preview :thumbnail set/rename-keys {:dataUri :data-uri}))
|
(update preview :thumbnail set/rename-keys {:dataUri :data-uri}))
|
||||||
@@ -53,8 +66,10 @@
|
|||||||
:new :new?
|
:new :new?
|
||||||
:albumImagesCount :album-images-count
|
:albumImagesCount :album-images-count
|
||||||
:displayName :display-name
|
:displayName :display-name
|
||||||
:linkPreviews :link-previews})
|
:linkPreviews :link-previews
|
||||||
|
:statusLinkPreviews :status-link-previews})
|
||||||
(update :link-previews #(map <-link-preview-rpc %))
|
(update :link-previews #(map <-link-preview-rpc %))
|
||||||
|
(update :status-link-previews #(map <-status-link-previews-rpc %))
|
||||||
(update :quoted-message
|
(update :quoted-message
|
||||||
set/rename-keys
|
set/rename-keys
|
||||||
{:parsedText :parsed-text
|
{:parsedText :parsed-text
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
;;; Link previews
|
;;; Link previews
|
||||||
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
|
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
|
||||||
(reg-root-key-sub :chat/link-previews :chat/link-previews)
|
(reg-root-key-sub :chat/link-previews :chat/link-previews)
|
||||||
|
(reg-root-key-sub :chat/status-link-previews :chat/status-link-previews)
|
||||||
|
|
||||||
;;commands
|
;;commands
|
||||||
(reg-root-key-sub :commands/select-account :commands/select-account)
|
(reg-root-key-sub :commands/select-account :commands/select-account)
|
||||||
|
|||||||
@@ -5,32 +5,49 @@
|
|||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn- image->rpc [image] (set/rename-keys image {:data-uri :dataUri}))
|
||||||
|
|
||||||
(defn- link-preview->rpc
|
(defn- link-preview->rpc
|
||||||
[preview]
|
[preview]
|
||||||
(update preview
|
(update preview
|
||||||
:thumbnail
|
:thumbnail
|
||||||
(fn [thumbnail]
|
(fn [thumbnail]
|
||||||
(set/rename-keys thumbnail {:data-uri :dataUri}))))
|
(image->rpc thumbnail))))
|
||||||
|
|
||||||
|
(defn- status-link-preview->rpc
|
||||||
|
[preview]
|
||||||
|
(update preview
|
||||||
|
:community
|
||||||
|
(fn [community]
|
||||||
|
(-> community
|
||||||
|
(set/rename-keys {:community-id :communityId
|
||||||
|
:display-name :displayName
|
||||||
|
:members-count :membersCount
|
||||||
|
:active-members-count :activeMembersCount})
|
||||||
|
(update :banner image->rpc)
|
||||||
|
(update :icon image->rpc)))))
|
||||||
|
|
||||||
(defn build-message
|
(defn build-message
|
||||||
[msg]
|
[msg]
|
||||||
(-> msg
|
(-> msg
|
||||||
(update :link-previews #(map link-preview->rpc %))
|
(update :link-previews #(map link-preview->rpc %))
|
||||||
|
(update :status-link-previews #(set (map status-link-preview->rpc %)))
|
||||||
(set/rename-keys
|
(set/rename-keys
|
||||||
{:album-id :albumId
|
{:album-id :albumId
|
||||||
:audio-duration-ms :audioDurationMs
|
:audio-duration-ms :audioDurationMs
|
||||||
:audio-path :audioPath
|
:audio-path :audioPath
|
||||||
:chat-id :chatId
|
:chat-id :chatId
|
||||||
:community-id :communityId
|
:community-id :communityId
|
||||||
:content-type :contentType
|
:content-type :contentType
|
||||||
:ens-name :ensName
|
:ens-name :ensName
|
||||||
:image-height :imageHeight
|
:image-height :imageHeight
|
||||||
:image-path :imagePath
|
:image-path :imagePath
|
||||||
:image-width :imageWidth
|
:image-width :imageWidth
|
||||||
:link-previews :linkPreviews
|
:link-previews :linkPreviews
|
||||||
:response-to :responseTo
|
:status-link-previews :statusLinkPreviews
|
||||||
:sticker :sticker
|
:response-to :responseTo
|
||||||
:text :text})))
|
:sticker :sticker
|
||||||
|
:text :text})))
|
||||||
|
|
||||||
(rf/defn send-chat-messages
|
(rf/defn send-chat-messages
|
||||||
[_ messages]
|
[_ messages]
|
||||||
|
|||||||
@@ -35,25 +35,29 @@
|
|||||||
(let [cleared (set (get-in db [:chat/link-previews :cleared]))]
|
(let [cleared (set (get-in db [:chat/link-previews :cleared]))]
|
||||||
(when (or (empty? urls)
|
(when (or (empty? urls)
|
||||||
(not= (set urls) cleared))
|
(not= (set urls) cleared))
|
||||||
(let [cache (get-in db [:chat/link-previews :cache])
|
(let [cache (get-in db [:chat/link-previews :cache])
|
||||||
previews (urls->previews cache urls)
|
previews (urls->previews cache urls)
|
||||||
new-urls (->> previews
|
new-urls (->> previews
|
||||||
(filter :loading?)
|
(filter :loading?)
|
||||||
(map :url))
|
(map :url))
|
||||||
|
status-link-preview? #(string/includes? % "status.app")
|
||||||
|
status-link-urls (->> urls
|
||||||
|
(filter status-link-preview?))
|
||||||
;; `request-id` is a must because we need to process only the last
|
;; `request-id` is a must because we need to process only the last
|
||||||
;; unfurling event, as well as avoid needlessly updating the app db
|
;; unfurling event, as well as avoid needlessly updating the app db
|
||||||
;; if the user changes the URLs in the input text when there are
|
;; if the user changes the URLs in the input text when there are
|
||||||
;; in-flight RPC requests.
|
;; in-flight RPC requests.
|
||||||
request-id (new-request-id)]
|
request-id
|
||||||
|
(new-request-id)]
|
||||||
(merge {:db (-> db
|
(merge {:db (-> db
|
||||||
(assoc-in [:chat/link-previews :unfurled] previews)
|
(assoc-in [:chat/link-previews :unfurled] previews)
|
||||||
(assoc-in [:chat/link-previews :request-id] request-id)
|
(assoc-in [:chat/link-previews :request-id] request-id)
|
||||||
(update :chat/link-previews dissoc :cleared))}
|
(update :chat/link-previews dissoc :cleared))}
|
||||||
(when (seq new-urls)
|
(when (or (seq status-link-urls) (seq new-urls))
|
||||||
(log/debug "Unfurling URLs" {:urls new-urls :request-id request-id})
|
(log/debug "Unfurling URLs" {:urls new-urls :request-id request-id})
|
||||||
{:json-rpc/call
|
{:json-rpc/call
|
||||||
[{:method "wakuext_unfurlURLs"
|
[{:method "wakuext_unfurlURLs"
|
||||||
:params [new-urls]
|
:params [(concat new-urls status-link-urls)]
|
||||||
:on-success #(rf/dispatch [:link-preview/unfurl-parsed-urls-success request-id %])
|
:on-success #(rf/dispatch [:link-preview/unfurl-parsed-urls-success request-id %])
|
||||||
:on-error #(rf/dispatch [:link-preview/unfurl-parsed-urls-error request-id
|
:on-error #(rf/dispatch [:link-preview/unfurl-parsed-urls-error request-id
|
||||||
%])}]}))))))
|
%])}]}))))))
|
||||||
@@ -82,17 +86,22 @@
|
|||||||
|
|
||||||
(rf/defn unfurl-parsed-urls-success
|
(rf/defn unfurl-parsed-urls-success
|
||||||
{:events [:link-preview/unfurl-parsed-urls-success]}
|
{:events [:link-preview/unfurl-parsed-urls-success]}
|
||||||
[{:keys [db]} request-id {new-previews :linkPreviews}]
|
[{:keys [db]} request-id {new-previews :linkPreviews status-link-previews :statusLinkPreviews}]
|
||||||
(when (= request-id (get-in db [:chat/link-previews :request-id]))
|
(when (or (seq status-link-previews) (= request-id (get-in db [:chat/link-previews :request-id])))
|
||||||
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
|
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
|
||||||
curr-previews (get-in db [:chat/link-previews :unfurled])
|
status-link-previews (map data-store.messages/<-status-link-previews-rpc
|
||||||
indexed-new-previews (utils.collection/index-by :url new-previews)]
|
status-link-previews)
|
||||||
|
curr-previews (get-in db [:chat/link-previews :unfurled])
|
||||||
|
indexed-new-previews (utils.collection/index-by :url new-previews)
|
||||||
|
indexed-status-link-previews (utils.collection/index-by :url status-link-previews)]
|
||||||
(log/debug "URLs unfurled"
|
(log/debug "URLs unfurled"
|
||||||
{:event :link-preview/unfurl-parsed-urls-success
|
{:event :link-preview/unfurl-parsed-urls-success
|
||||||
:previews (map #(update % :thumbnail dissoc :data-uri) new-previews)
|
:previews (map #(update % :thumbnail dissoc :data-uri) new-previews)
|
||||||
:request-id request-id})
|
:request-id request-id})
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(update-in [:chat/link-previews :unfurled] reconcile-unfurled indexed-new-previews)
|
(update-in [:chat/link-previews :unfurled] reconcile-unfurled indexed-new-previews)
|
||||||
|
(assoc-in [:chat/status-link-previews :unfurled]
|
||||||
|
status-link-previews)
|
||||||
(update-in [:chat/link-previews :cache]
|
(update-in [:chat/link-previews :cache]
|
||||||
merge
|
merge
|
||||||
indexed-new-previews
|
indexed-new-previews
|
||||||
@@ -130,3 +139,12 @@
|
|||||||
{:db (-> db
|
{:db (-> db
|
||||||
(update :chat/link-previews dissoc :unfurled :request-id)
|
(update :chat/link-previews dissoc :unfurled :request-id)
|
||||||
(assoc-in [:chat/link-previews :cleared] unfurled-urls))}))
|
(assoc-in [:chat/link-previews :cleared] unfurled-urls))}))
|
||||||
|
|
||||||
|
(rf/defn clear-status-link-previews
|
||||||
|
{:events [:status-link-preview/clear]}
|
||||||
|
[{:keys [db]}]
|
||||||
|
(let [unfurled-urls (set (map :url (get-in db [:chat/status-link-previews :unfurled])))]
|
||||||
|
{:db (-> db
|
||||||
|
(update :chat/status-link-previews dissoc :unfurled)
|
||||||
|
(assoc-in [:chat/status-link-previews :cleared] unfurled-urls))}))
|
||||||
|
|
||||||
|
|||||||
@@ -20,26 +20,37 @@
|
|||||||
|
|
||||||
(defn f-view
|
(defn f-view
|
||||||
[]
|
[]
|
||||||
(let [previews (rf/sub [:chats/link-previews-unfurled])
|
(let [previews (rf/sub [:chats/link-previews-unfurled])
|
||||||
height (use-animated-height (boolean (seq previews)))]
|
status-link-previews (rf/sub [:chats/status-link-previews-unfurled])
|
||||||
|
height (use-animated-height (boolean (or (seq status-link-previews)
|
||||||
|
(seq previews))))]
|
||||||
[reanimated/view
|
[reanimated/view
|
||||||
{:style (reanimated/apply-animations-to-style {:height height} {:z-index 1})}
|
{:style (reanimated/apply-animations-to-style {:height height} {:z-index 1})}
|
||||||
[quo/url-preview-list
|
[quo/url-preview-list
|
||||||
{:key-fn :url
|
{:key-fn :url
|
||||||
:preview-width (- (:width (rn/get-window))
|
:preview-width (- (:width (rn/get-window))
|
||||||
(* 2 style/padding-horizontal))
|
(* 2 style/padding-horizontal))
|
||||||
:container-style (when (seq previews) style/preview-list)
|
:container-style (when (or (seq status-link-previews) (seq previews)) style/preview-list)
|
||||||
:container-style-item {:height style/preview-height}
|
:container-style-item {:height style/preview-height}
|
||||||
:horizontal-spacing style/padding-horizontal
|
:horizontal-spacing style/padding-horizontal
|
||||||
:loading-message (i18n/label :t/link-preview-loading-message)
|
:loading-message (i18n/label :t/link-preview-loading-message)
|
||||||
:on-clear #(rf/dispatch [:link-preview/clear])
|
:on-clear #(do
|
||||||
:data (map (fn [{:keys [title thumbnail hostname loading? url]}]
|
(rf/dispatch [:status-link-preview/clear])
|
||||||
{:title title
|
(rf/dispatch [:link-preview/clear]))
|
||||||
:body hostname
|
:data (map (fn [{:keys [title thumbnail hostname loading? url community]}]
|
||||||
:loading? loading?
|
(if (seq community)
|
||||||
:thumbnail (:data-uri thumbnail)
|
(let [{:keys [display-name banner]} community]
|
||||||
:url url})
|
{:title display-name
|
||||||
previews)}]]))
|
:body "status.app"
|
||||||
|
:loading? loading?
|
||||||
|
:thumbnail (:data-uri banner)
|
||||||
|
:url url})
|
||||||
|
{:title title
|
||||||
|
:body hostname
|
||||||
|
:loading? loading?
|
||||||
|
:thumbnail (:data-uri thumbnail)
|
||||||
|
:url url}))
|
||||||
|
(set (concat previews status-link-previews)))}]]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
|
|||||||
@@ -13,15 +13,32 @@
|
|||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [chat-id message-id]}]
|
[{:keys [chat-id message-id]}]
|
||||||
(let [previews (rf/sub [:chats/message-link-previews chat-id message-id])]
|
(let [previews (rf/sub [:chats/message-link-previews chat-id message-id])
|
||||||
(when (seq previews)
|
status-link-previews (rf/sub [:chats/message-status-link-previews chat-id message-id])]
|
||||||
|
(when (or (seq status-link-previews)
|
||||||
|
(seq previews))
|
||||||
[:<>
|
[:<>
|
||||||
(for [{:keys [url title description thumbnail hostname]} previews]
|
(for [{:keys [url title description thumbnail hostname community]}
|
||||||
|
(concat status-link-previews previews)]
|
||||||
^{:key url}
|
^{:key url}
|
||||||
[quo/link-preview
|
(if community
|
||||||
{:title title
|
(let [{community-description :description
|
||||||
:description description
|
community-icon :icon
|
||||||
:link hostname
|
community-banner :banner
|
||||||
:thumbnail (:url thumbnail)
|
community-name :display-name
|
||||||
:thumbnail-size (when (nearly-square? thumbnail) :large)
|
members-count :members-count} community]
|
||||||
:container-style {:margin-top 8}}])])))
|
[quo/status-link-preview-community
|
||||||
|
{:description community-description
|
||||||
|
:members-count members-count
|
||||||
|
:title community-name
|
||||||
|
:banner (:url community-banner)
|
||||||
|
:icon (:url community-icon)
|
||||||
|
:link url
|
||||||
|
:on-press #(rf/dispatch [:universal-links/handle-url url])}])
|
||||||
|
[quo/link-preview
|
||||||
|
{:title title
|
||||||
|
:description description
|
||||||
|
:link hostname
|
||||||
|
:thumbnail (:url thumbnail)
|
||||||
|
:thumbnail-size (when (nearly-square? thumbnail) :large)
|
||||||
|
:container-style {:margin-top 8}}]))])))
|
||||||
|
|||||||
@@ -145,6 +145,7 @@
|
|||||||
[status-im2.contexts.quo-preview.settings.settings-item :as settings-item]
|
[status-im2.contexts.quo-preview.settings.settings-item :as settings-item]
|
||||||
[status-im2.contexts.quo-preview.share.qr-code :as qr-code]
|
[status-im2.contexts.quo-preview.share.qr-code :as qr-code]
|
||||||
[status-im2.contexts.quo-preview.share.share-qr-code :as share-qr-code]
|
[status-im2.contexts.quo-preview.share.share-qr-code :as share-qr-code]
|
||||||
|
[status-im2.contexts.quo-preview.status-link-preview.community :as status-preview-community]
|
||||||
[status-im2.contexts.quo-preview.style :as style]
|
[status-im2.contexts.quo-preview.style :as style]
|
||||||
[status-im2.contexts.quo-preview.switcher.group-messaging-card :as group-messaging-card]
|
[status-im2.contexts.quo-preview.switcher.group-messaging-card :as group-messaging-card]
|
||||||
[status-im2.contexts.quo-preview.switcher.switcher-cards :as switcher-cards]
|
[status-im2.contexts.quo-preview.switcher.switcher-cards :as switcher-cards]
|
||||||
@@ -324,7 +325,10 @@
|
|||||||
:component url-preview-list/view}
|
:component url-preview-list/view}
|
||||||
{:name :link-preview
|
{:name :link-preview
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}}
|
||||||
:component link-preview/view}]
|
:component link-preview/view}
|
||||||
|
{:name :status-preview-community
|
||||||
|
:options {:insets {:top true}}
|
||||||
|
:component status-preview-community/view}]
|
||||||
:list-items [{:name :account
|
:list-items [{:name :account
|
||||||
:component account-item/view}
|
:component account-item/view}
|
||||||
{:name :account-list-card
|
{:name :account-list-card
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
(ns status-im2.contexts.quo-preview.status-link-preview.community
|
||||||
|
(:require
|
||||||
|
[quo.core :as quo]
|
||||||
|
[reagent.core :as reagent]
|
||||||
|
[status-im2.common.resources :as resources]
|
||||||
|
[status-im2.contexts.quo-preview.preview :as preview]))
|
||||||
|
|
||||||
|
(def descriptor
|
||||||
|
[{:type :text :key :title}
|
||||||
|
{:type :text :key :description}
|
||||||
|
{:type :boolean :key :loading?}
|
||||||
|
{:type :text :key :members-count}
|
||||||
|
{:type :text :key :active-members-count}])
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[]
|
||||||
|
(let [state (reagent/atom
|
||||||
|
{:title "Doodles"
|
||||||
|
:description "Coloring the world with joy • ᴗ •"
|
||||||
|
:members-count 24
|
||||||
|
:active-members-count 12
|
||||||
|
:link "https://status.app/community-link"
|
||||||
|
:loading? false})]
|
||||||
|
(fn []
|
||||||
|
[preview/preview-container
|
||||||
|
{:state state
|
||||||
|
:descriptor descriptor}
|
||||||
|
[quo/status-link-preview-community
|
||||||
|
{:title (:title @state)
|
||||||
|
:description (:description @state)
|
||||||
|
:icon (resources/get-mock-image :status-logo)
|
||||||
|
:banner (resources/get-mock-image :status-logo)
|
||||||
|
:loading? (:loading? @state)
|
||||||
|
:members-count (int (:members-count @state))
|
||||||
|
:loading-message (:loading-message @state)
|
||||||
|
:active-members-count (int (:active-members-count @state))
|
||||||
|
:on-clear #(js/alert "Clear button pressed")}]])))
|
||||||
@@ -442,11 +442,19 @@
|
|||||||
(fn [previews]
|
(fn [previews]
|
||||||
(get previews :unfurled)))
|
(get previews :unfurled)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:chats/status-link-previews-unfurled
|
||||||
|
:<- [:chat/status-link-previews]
|
||||||
|
(fn [previews]
|
||||||
|
(get previews :unfurled)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chats/link-previews?
|
:chats/link-previews?
|
||||||
:<- [:chats/link-previews-unfurled]
|
:<- [:chats/link-previews-unfurled]
|
||||||
(fn [previews]
|
:<- [:chats/status-link-previews-unfurled]
|
||||||
(boolean (seq previews))))
|
(fn [previews status-link-previews]
|
||||||
|
(or (boolean (seq status-link-previews))
|
||||||
|
(boolean (seq previews)))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chat/check-channel-muted?
|
:chat/check-channel-muted?
|
||||||
|
|||||||
@@ -152,6 +152,12 @@
|
|||||||
(fn [messages [_ chat-id message-id]]
|
(fn [messages [_ chat-id message-id]]
|
||||||
(get-in messages [chat-id message-id :link-previews])))
|
(get-in messages [chat-id message-id :link-previews])))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:chats/message-status-link-previews
|
||||||
|
:<- [:messages/messages]
|
||||||
|
(fn [messages [_ chat-id message-id]]
|
||||||
|
(get-in messages [chat-id message-id :status-link-previews])))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chats/pinned
|
:chats/pinned
|
||||||
:<- [:messages/pin-messages]
|
:<- [:messages/pin-messages]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.171.27",
|
"version": "status-mobile-17116",
|
||||||
"commit-sha1": "76b6745666b945f8d6336e2a5fc6e5705985273d",
|
"commit-sha1": "cfd85f8b2c5f0c094ea7451acd4b2ed3232cb97e",
|
||||||
"src-sha256": "1amak99bpsx6j8grzm2kzwd3si34gg4r8kbxqmnkfsrkm2nzvbx1"
|
"src-sha256": "15x8ynbqx2sk19hkyy8x45hglf99c0x7vm3lpik0aw5d8i5zcgvm"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user