share image message to selected contacts
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
[status-im.data-store.messages :as data-store.messages]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.chat.models.mentions :as mentions]
|
||||
@@ -181,6 +182,14 @@
|
||||
:on-error #(log/error "failed to re-send message" %)}]}
|
||||
(update-message-status chat-id message-id :sending)))
|
||||
|
||||
(fx/defn share-to-contacts-pressed
|
||||
{:events [::share-to-contacts-pressed]}
|
||||
[{:keys [db] :as cofx}
|
||||
{:keys [message-id] :as message}]
|
||||
(fx/merge cofx
|
||||
(navigation/open-modal
|
||||
:share-to-contacts {:message-id message-id})))
|
||||
|
||||
(fx/defn delete-message
|
||||
"Deletes chat message, rebuild message-list"
|
||||
{:events [:chat.ui/delete-message]}
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
"wakuext_createGroupChatWithMembers" {}
|
||||
"wakuext_createGroupChatFromInvitation" {}
|
||||
"wakuext_reSendChatMessage" {}
|
||||
"wakuext_shareImageMessage" {}
|
||||
"wakuext_getOurInstallations" {}
|
||||
"wakuext_setInstallationMetadata" {}
|
||||
"wakuext_loadFilters" {}
|
||||
|
||||
@@ -26,6 +26,22 @@
|
||||
:sticker sticker
|
||||
:contentType content-type})
|
||||
|
||||
(fx/defn share-image-to-contacts-pressed
|
||||
{:events [::share-image-to-contacts-pressed]}
|
||||
[cofx user-pk contacts message-id]
|
||||
(let [pks (if (seq user-pk)
|
||||
(conj contacts user-pk)
|
||||
contacts)]
|
||||
(when (seq pks)
|
||||
{::json-rpc/call [{:method "wakuext_shareImageMessage"
|
||||
:params [{:users pks
|
||||
:id message-id}]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:navigate-back])
|
||||
:on-error #(do
|
||||
(log/error "failed to share image message" %)
|
||||
(re-frame/dispatch [::failed-to-share-image %]))}]})))
|
||||
|
||||
(fx/defn send-chat-messages [_ messages]
|
||||
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendChatMessages")
|
||||
:params [(mapv build-message messages)]
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
[status-im.ui.screens.chat.components.reply :as components.reply]
|
||||
[status-im.ui.screens.chat.message.link-preview :as link-preview]
|
||||
[status-im.ui.screens.communities.icon :as communities.icon]
|
||||
[status-im.chat.models.message :as message]
|
||||
[status-im.utils.handlers :refer [>evt]]
|
||||
[status-im.ui.components.animation :as animation]
|
||||
[status-im.chat.models.pin-message :as models.pin-message])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||
@@ -583,6 +585,9 @@
|
||||
[{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message])
|
||||
:id :reply
|
||||
:label (i18n/label :t/message-reply)}
|
||||
{:on-press #(>evt [::message/share-to-contacts-pressed message])
|
||||
:id :share
|
||||
:label (i18n/label :t/share)}
|
||||
{:on-press #(re-frame/dispatch [:chat.ui/save-image-to-gallery (:image content)])
|
||||
:id :save
|
||||
:label (i18n/label :t/save)}]))}]
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
(ns status-im.ui.screens.chat.share
|
||||
(:require [reagent.core :as reagent]
|
||||
[quo.react-native :as rn]
|
||||
[quo.core :as quo]
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
[status-im.ui.components.toolbar :as toolbar]
|
||||
[status-im.utils.handlers :refer [<sub >evt-once]]
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.ui.components.topbar :as topbar]
|
||||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn contacts-list-item [{:keys [public-key active] :as contact} _ _ {:keys [selected]}]
|
||||
(let [[first-name second-name] (multiaccounts/contact-two-names contact true)]
|
||||
[quo/list-item
|
||||
{:title first-name
|
||||
:subtitle second-name
|
||||
:icon [chat-icon.screen/contact-icon-contacts-tab
|
||||
(multiaccounts/displayed-photo contact)]
|
||||
:accessory :checkbox
|
||||
:active active
|
||||
:on-press (fn []
|
||||
(if active
|
||||
(swap! selected disj public-key)
|
||||
(swap! selected conj public-key)))}]))
|
||||
|
||||
(defn share []
|
||||
(let [user-pk (reagent/atom "")
|
||||
contacts-selected (reagent/atom #{})
|
||||
{:keys [message-id]} (<sub [:get-screen-params])]
|
||||
(fn []
|
||||
(let [contacts-data (<sub [:contacts/active])
|
||||
selected @contacts-selected
|
||||
contacts (map (fn [{:keys [public-key] :as contact}]
|
||||
(assoc contact :active (contains? selected public-key)))
|
||||
contacts-data)]
|
||||
[:<>
|
||||
[topbar/topbar {:modal? true}]
|
||||
[rn/flat-list {:style {:flex 1}
|
||||
:content-container-style {:padding-vertical 16}
|
||||
:render-data {:selected contacts-selected}
|
||||
:render-fn contacts-list-item
|
||||
:key-fn (fn [{:keys [active public-key]}]
|
||||
(str public-key active))
|
||||
:data contacts}]
|
||||
[toolbar/toolbar
|
||||
{:show-border? true
|
||||
:center
|
||||
[quo/button {:disabled (and (str/blank? @user-pk)
|
||||
(zero? (count selected)))
|
||||
:type :secondary
|
||||
:on-press #(>evt-once [::protocol/share-image-to-contacts-pressed
|
||||
@user-pk selected message-id])}
|
||||
(i18n/label :t/share)]}]]))))
|
||||
@@ -23,6 +23,7 @@
|
||||
[status-im.ui.screens.bug-report :as bug-report]
|
||||
[status-im.ui.screens.chat.pinned-messages :as pin-messages]
|
||||
[status-im.ui.screens.chat.views :as chat]
|
||||
[status-im.ui.screens.chat.share :as chat.share]
|
||||
[status-im.ui.screens.communities.channel-details :as communities.channel-details]
|
||||
[status-im.ui.screens.communities.community :as community]
|
||||
[status-im.ui.screens.communities.community-emoji-thumbnail-picker :as community-emoji-thumbnail-picker]
|
||||
@@ -611,6 +612,13 @@
|
||||
:options {:topBar {:title {:text (i18n/label :t/new-public-group-chat)}}}
|
||||
:component new-public-chat/new-public-chat}
|
||||
|
||||
;[Chat] Share Images message
|
||||
{:name :share-to-contacts
|
||||
:options {:topBar {:visible false
|
||||
:title (i18n/label :t/community-share-title)}}
|
||||
:component chat.share/share
|
||||
:insets {:bottom true}}
|
||||
|
||||
;[Chat] Link preview settings
|
||||
{:name :link-preview-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/chat-link-previews)}}}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.94.7",
|
||||
"commit-sha1": "b559c561d80a3b8b131b81d82e2bfda3ae387824",
|
||||
"src-sha256": "0ak0zb3bq3jwlrvqcvf8fycdxvgls61qi2bmp8xi81952andk27w"
|
||||
"version": "v0.94.8",
|
||||
"commit-sha1": "7d956bef9436e89f39e7ce500b3ea1251426af8e",
|
||||
"src-sha256": "0zggxvbgv5zpinb1833wy9imxc409hy9q8s18f4m111649fs4ml6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user