[#13181] Cannot delete images or audio messages

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2022-03-24 13:04:56 +01:00
parent d086b86fd0
commit c4036aee09
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
1 changed files with 34 additions and 20 deletions

View File

@ -572,31 +572,45 @@
:source {:uri (contenthash/url (-> content :sticker :hash))}}]] :source {:uri (contenthash/url (-> content :sticker :hash))}}]]
reaction-picker])) reaction-picker]))
(defmethod ->message constants/content-type-image [{:keys [content in-popover?] :as message} {:keys [on-long-press modal] (defmethod ->message constants/content-type-image
:as reaction-picker}] [{:keys [content in-popover? outgoing] :as message}
{:keys [on-long-press modal]
:as reaction-picker}]
[message-content-wrapper message [message-content-wrapper message
[message-content-image message {:modal modal [message-content-image message
:disabled in-popover? {:modal modal
:delay-long-press 100 :disabled in-popover?
:on-long-press (fn [] :delay-long-press 100
(on-long-press :on-long-press (fn []
[{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message]) (on-long-press
:id :reply (concat [{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message])
:label (i18n/label :t/message-reply)} :id :reply
{:on-press #(re-frame/dispatch [:chat.ui/save-image-to-gallery (:image content)]) :label (i18n/label :t/message-reply)}
:id :save {:on-press #(re-frame/dispatch [:chat.ui/save-image-to-gallery (:image content)])
:label (i18n/label :t/save)}]))}] :id :save
:label (i18n/label :t/save)}]
(when (and outgoing config/delete-message-enabled?)
[{:on-press #(re-frame/dispatch [:chat.ui/soft-delete-message message])
:label (i18n/label :t/delete)
:id :delete}]))))}]
reaction-picker]) reaction-picker])
(defmethod ->message constants/content-type-audio [message {:keys [on-long-press modal] (defmethod ->message constants/content-type-audio
:as reaction-picker}] [{:keys [outgoing] :as message}
{:keys [on-long-press modal]
:as reaction-picker}]
(let [show-timestamp? (reagent/atom false)] (let [show-timestamp? (reagent/atom false)]
(fn [] [message-content-wrapper message (fn [] [message-content-wrapper message
[react/touchable-highlight (when-not modal [react/touchable-highlight
{:on-long-press (when-not modal
(fn [] (on-long-press [])) {:on-long-press
:on-press (fn [] (fn [] (on-long-press (if (and outgoing config/delete-message-enabled?)
(reset! show-timestamp? true))}) [{:on-press #(re-frame/dispatch [:chat.ui/soft-delete-message message])
:label (i18n/label :t/delete)
:id :delete}]
[])))
:on-press (fn []
(reset! show-timestamp? true))})
[react/view (style/message-view-wrapper (:outgoing message)) [react/view (style/message-view-wrapper (:outgoing message))
[message-timestamp message show-timestamp?] [message-timestamp message show-timestamp?]
[react/view {:style (style/message-view message) :accessibility-label :audio-message} [react/view {:style (style/message-view message) :accessibility-label :audio-message}