Compare commits

...
Author SHA1 Message Date
Omar Basem 1e372522d2 updates 2023-01-10 14:33:08 +04:00
Omar Basem dc73f9ef00 updates 2023-01-10 14:17:32 +04:00
Omar Basem 2b0f2e6629 updates 2023-01-10 14:17:32 +04:00
Omar Basem 8dfc9e1ea7 updates 2023-01-10 14:17:32 +04:00
Omar Basem 98b309cf48 updates 2023-01-10 14:17:31 +04:00
Omar Basem 091c00ae17 updates 2023-01-10 14:17:31 +04:00
Omar Basem 143ebf0194 updates 2023-01-10 14:17:31 +04:00
Omar Basem a789902657 updates 2023-01-10 14:17:30 +04:00
22 changed files with 572 additions and 384 deletions
+1 -1
View File
@@ -131,7 +131,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<false/>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A00000080400010101</string>
+1 -1
View File
@@ -135,7 +135,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<false/>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A00000080400010101</string>
+5
View File
@@ -17,6 +17,7 @@
(def image (reagent/adapt-react-class (.-Image ^js react-native)))
(def text (reagent/adapt-react-class (.-Text ^js react-native)))
(def text-input (reagent/adapt-react-class (.-TextInput ^js react-native)))
(def safe-area-view (reagent/adapt-react-class (.-SafeAreaView ^js react-native)))
(def touchable-opacity (reagent/adapt-react-class (.-TouchableOpacity ^js react-native)))
(def touchable-highlight (reagent/adapt-react-class (.-TouchableHighlight ^js react-native)))
@@ -67,6 +68,10 @@
(def status-bar (.-StatusBar ^js react-native))
(defn set-status-bar-style
[style]
(.setBarStyle (.-StatusBar ^js react-native) style))
(def style-sheet (.-StyleSheet ^js react-native))
(defn status-bar-height
+10
View File
@@ -319,6 +319,16 @@
[cofx chat-id]
(navigation/navigate-to cofx :chat-pinned-messages {:chat-id chat-id}))
(rf/defn navigate-to-horizontal-images
{:events [:chat.ui/navigate-to-horizontal-images]}
[cofx messages dimensions]
(navigation/navigate-to cofx :images-horizontal {:messages messages :dimensions dimensions}))
(rf/defn update-shared-element-id
{:events [:chat.ui/update-shared-element-id]}
[{:keys [db]} shared-element-id]
{:db (assoc db :shared-element-id shared-element-id)})
(rf/defn start-chat
"Start a chat, making sure it exists"
{:events [:chat.ui/start-chat]}
+13 -10
View File
@@ -98,10 +98,10 @@
(re-frame/reg-fx
::image-selected
(fn [[uri chat-id]]
(fn [[image chat-id]]
(resize-and-call
uri
#(re-frame/dispatch [:chat.ui/image-selected chat-id uri %]))))
(:uri image)
#(re-frame/dispatch [:chat.ui/image-selected chat-id image %]))))
(re-frame/reg-fx
::camera-roll-get-photos
@@ -151,7 +151,7 @@
[{:keys [db] :as cofx} photos page-info end-cursor]
(let [photos_x (when end-cursor (:camera-roll/photos db))]
{:db (-> db
(assoc :camera-roll/photos (concat photos_x (map #(get-in % [:node :image :uri]) photos)))
(assoc :camera-roll/photos (concat photos_x (map #(get-in % [:node :image]) photos)))
(assoc :camera-roll/end-cursor (:end_cursor page-info))
(assoc :camera-roll/has-next-page (:has_next_page page-info))
(assoc :camera-roll/loading-more false))}))
@@ -175,13 +175,13 @@
(rf/defn image-selected
{:events [:chat.ui/image-selected]}
[{:keys [db]} current-chat-id original uri]
{:db (update-in db [:chat/inputs current-chat-id :metadata :sending-image original] merge {:uri uri})})
{:db (update-in db [:chat/inputs current-chat-id :metadata :sending-image uri] merge original {:uri uri})})
(rf/defn image-unselected
{:events [:chat.ui/image-unselected]}
[{:keys [db]} original]
(let [current-chat-id (:current-chat-id db)]
{:db (update-in db [:chat/inputs current-chat-id :metadata :sending-image] dissoc original)}))
{:db (update-in db [:chat/inputs current-chat-id :metadata :sending-image] dissoc (:uri original))}))
(rf/defn chat-open-image-picker
{:events [:chat.ui/open-image-picker]}
@@ -211,15 +211,18 @@
(rf/defn camera-roll-pick
{:events [:chat.ui/camera-roll-pick]}
[{:keys [db]} uri chat-id]
[{:keys [db]} image chat-id]
(let [current-chat-id (or chat-id (:current-chat-id db))
images (get-in db [:chat/inputs current-chat-id :metadata :sending-image])]
(if (get-in db [:chats current-chat-id :timeline?])
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :sending-image] {})
::image-selected [uri current-chat-id]}
::image-selected [image current-chat-id]}
(when (and (< (count images) config/max-images-batch)
(not (get images uri)))
{::image-selected [uri current-chat-id]}))))
(not (some #(= (:uri image) (:uri %)) images)))
{::image-selected [image current-chat-id]}
)
)
))
(rf/defn camera-roll-pick-timeline
{:events [:chat.ui/camera-roll-pick-timeline]}
+247 -243
View File
@@ -26,154 +26,154 @@
original))))
(rf/defn set-chat-input-text
"Set input text for current-chat. Takes db and input text and cofx
as arguments and returns new fx. Always clear all validation messages."
{:events [:chat.ui/set-chat-input-text]}
[{db :db} new-input chat-id]
(let [current-chat-id (or chat-id (:current-chat-id db))]
{:db (assoc-in db [:chat/inputs current-chat-id :input-text] (text->emoji new-input))}))
"Set input text for current-chat. Takes db and input text and cofx
as arguments and returns new fx. Always clear all validation messages."
{:events [:chat.ui/set-chat-input-text]}
[{db :db} new-input chat-id]
(let [current-chat-id (or chat-id (:current-chat-id db))]
{:db (assoc-in db [:chat/inputs current-chat-id :input-text] (text->emoji new-input))}))
(rf/defn set-timeline-input-text
{:events [:chat.ui/set-timeline-input-text]}
[{db :db} new-input]
{:db (assoc-in db
[:chat/inputs (chat/my-profile-chat-topic db) :input-text]
(text->emoji new-input))})
{:events [:chat.ui/set-timeline-input-text]}
[{db :db} new-input]
{:db (assoc-in db
[:chat/inputs (chat/my-profile-chat-topic db) :input-text]
(text->emoji new-input))})
(rf/defn select-mention
{:events [:chat.ui/select-mention]}
[{:keys [db] :as cofx} text-input-ref {:keys [alias name searched-text match] :as user}]
(let [chat-id (:current-chat-id db)
new-text (mentions/new-input-text-with-mention cofx user)
at-sign-idx (get-in db [:chats/mentions chat-id :mentions :at-sign-idx])
cursor (+ at-sign-idx (count name) 2)]
(rf/merge
cofx
{:db (-> db
(assoc-in [:chats/cursor chat-id] cursor)
(assoc-in [:chats/mention-suggestions chat-id] nil))
:set-text-input-value [chat-id new-text text-input-ref]}
(set-chat-input-text new-text chat-id)
;; NOTE(rasom): Some keyboards do not react on selection property passed to
;; text input (specifically Samsung keyboard with predictive text set on).
;; In this case, if the user continues typing after the programmatic change,
;; the new text is added to the last known cursor position before
;; programmatic change. By calling `reset-text-input-cursor` we force the
;; keyboard's cursor position to be changed before the next input.
(mentions/reset-text-input-cursor text-input-ref cursor)
;; NOTE(roman): on-text-input event is not dispatched when we change input
;; programmatically, so we have to call `on-text-input` manually
(mentions/on-text-input
(let [match-len (count match)
searched-text-len (count searched-text)
start (inc at-sign-idx)
end (+ start match-len)]
{:new-text match
:previous-text searched-text
:start start
:end end}))
(mentions/recheck-at-idxs {alias user}))))
{:events [:chat.ui/select-mention]}
[{:keys [db] :as cofx} text-input-ref {:keys [alias name searched-text match] :as user}]
(let [chat-id (:current-chat-id db)
new-text (mentions/new-input-text-with-mention cofx user)
at-sign-idx (get-in db [:chats/mentions chat-id :mentions :at-sign-idx])
cursor (+ at-sign-idx (count name) 2)]
(rf/merge
cofx
{:db (-> db
(assoc-in [:chats/cursor chat-id] cursor)
(assoc-in [:chats/mention-suggestions chat-id] nil))
:set-text-input-value [chat-id new-text text-input-ref]}
(set-chat-input-text new-text chat-id)
;; NOTE(rasom): Some keyboards do not react on selection property passed to
;; text input (specifically Samsung keyboard with predictive text set on).
;; In this case, if the user continues typing after the programmatic change,
;; the new text is added to the last known cursor position before
;; programmatic change. By calling `reset-text-input-cursor` we force the
;; keyboard's cursor position to be changed before the next input.
(mentions/reset-text-input-cursor text-input-ref cursor)
;; NOTE(roman): on-text-input event is not dispatched when we change input
;; programmatically, so we have to call `on-text-input` manually
(mentions/on-text-input
(let [match-len (count match)
searched-text-len (count searched-text)
start (inc at-sign-idx)
end (+ start match-len)]
{:new-text match
:previous-text searched-text
:start start
:end end}))
(mentions/recheck-at-idxs {alias user}))))
(defn- start-cooldown
[{:keys [db]} cooldowns]
{:dispatch-later [{:dispatch [:chat/disable-cooldown]
:ms (chat.constants/cooldown-periods-ms
cooldowns
chat.constants/default-cooldown-period-ms)}]
cooldowns
chat.constants/default-cooldown-period-ms)}]
:show-cooldown-warning nil
:db (assoc db
:chat/cooldowns (if
(=
chat.constants/cooldown-reset-threshold
cooldowns)
0
cooldowns)
:chat/spam-messages-frequency 0
:chat/cooldown-enabled? true)})
:chat/cooldowns (if
(=
chat.constants/cooldown-reset-threshold
cooldowns)
0
cooldowns)
:chat/spam-messages-frequency 0
:chat/cooldown-enabled? true)})
(rf/defn process-cooldown
"Process cooldown to protect against message spammers"
[{{:keys [chat/last-outgoing-message-sent-at
chat/cooldowns
chat/spam-messages-frequency
current-chat-id]
:as db}
:db
:as cofx}]
(when (chat/public-chat? cofx current-chat-id)
(let [spamming-fast? (< (- (datetime/timestamp) last-outgoing-message-sent-at)
(+ chat.constants/spam-interval-ms (* 1000 cooldowns)))
spamming-frequently? (= chat.constants/spam-message-frequency-threshold
spam-messages-frequency)]
(cond-> {:db (assoc db
:chat/last-outgoing-message-sent-at (datetime/timestamp)
:chat/spam-messages-frequency (if spamming-fast?
(inc spam-messages-frequency)
0))}
"Process cooldown to protect against message spammers"
[{{:keys [chat/last-outgoing-message-sent-at
chat/cooldowns
chat/spam-messages-frequency
current-chat-id]
:as db}
:db
:as cofx}]
(when (chat/public-chat? cofx current-chat-id)
(let [spamming-fast? (< (- (datetime/timestamp) last-outgoing-message-sent-at)
(+ chat.constants/spam-interval-ms (* 1000 cooldowns)))
spamming-frequently? (= chat.constants/spam-message-frequency-threshold
spam-messages-frequency)]
(cond-> {:db (assoc db
:chat/last-outgoing-message-sent-at (datetime/timestamp)
:chat/spam-messages-frequency (if spamming-fast?
(inc spam-messages-frequency)
0))}
(and spamming-fast? spamming-frequently?)
(start-cooldown (inc cooldowns))))))
(and spamming-fast? spamming-frequently?)
(start-cooldown (inc cooldowns))))))
(rf/defn reply-to-message
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/reply-to-message]}
[{:keys [db] :as cofx} message]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
message)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))})))
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/reply-to-message]}
[{:keys [db] :as cofx} message]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
message)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))})))
(rf/defn edit-message
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/edit-message]}
[{:keys [db] :as cofx} message]
(let [current-chat-id (:current-chat-id db)
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/edit-message]}
[{:keys [db] :as cofx} message]
(let [current-chat-id (:current-chat-id db)
text (get-in message [:content :text])]
{:dispatch [:chat.ui.input/set-chat-input-text text current-chat-id]
:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message]
message)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))}))
text (get-in message [:content :text])]
{:dispatch [:chat.ui.input/set-chat-input-text text current-chat-id]
:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message]
message)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))}))
(rf/defn show-contact-request-input
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/send-contact-request]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request]
current-chat-id)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))}))
"Sets reference to previous chat message and focuses on input"
{:events [:chat.ui/send-contact-request]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request]
current-chat-id)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc
:sending-image))}))
(rf/defn cancel-message-reply
"Cancels stage message reply"
{:events [:chat.ui/cancel-message-reply]}
[{:keys [db]}]
(let [current-chat-id (:current-chat-id db)]
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)}))
"Cancels stage message reply"
{:events [:chat.ui/cancel-message-reply]}
[{:keys [db]}]
(let [current-chat-id (:current-chat-id db)]
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)}))
(defn build-text-message
[{:keys [db]} input-text current-chat-id]
(when-not (string/blank? input-text)
(let [{:keys [message-id]}
(get-in db [:chat/inputs current-chat-id :metadata :responding-to-message])
preferred-name (get-in db [:multiaccount :preferred-name])
emoji? (message-content/emoji-only-content? {:text input-text
:response-to message-id})]
preferred-name (get-in db [:multiaccount :preferred-name])
emoji? (message-content/emoji-only-content? {:text input-text
:response-to message-id})]
{:chat-id current-chat-id
:content-type (if emoji?
constants/content-type-emoji
@@ -183,158 +183,162 @@
:ens-name preferred-name})))
(defn build-image-messages
[{db :db} chat-id]
[{db :db} chat-id input-text]
(let [images (get-in db [:chat/inputs chat-id :metadata :sending-image])
album-id (str (random-uuid))]
(mapv (fn [[_ {:keys [uri]}]]
(mapv (fn [[_ {:keys [uri width height]}]]
{:chat-id chat-id
:album-id album-id
:content-type constants/content-type-image
:image-path (utils/safe-replace uri #"file://" "")
:text (i18n/label :t/update-to-see-image {"locale" "en"})})
:text input-text
;:image-width width
;:image-height height
})
images)))
(rf/defn clean-input
[{:keys [db] :as cofx} current-chat-id]
(rf/merge cofx
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :sending-image] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message] nil))}
(set-chat-input-text nil current-chat-id)))
[{:keys [db] :as cofx} current-chat-id]
(rf/merge cofx
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :sending-image] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message] nil))}
(set-chat-input-text nil current-chat-id)))
(rf/defn cancel-message-edit
"Cancels stage message edit"
{:events [:chat.ui/cancel-message-edit]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:set-text-input-value [current-chat-id ""]}
(clean-input current-chat-id)
(mentions/clear-mentions)
(mentions/clear-cursor))))
"Cancels stage message edit"
{:events [:chat.ui/cancel-message-edit]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:set-text-input-value [current-chat-id ""]}
(clean-input current-chat-id)
(mentions/clear-mentions)
(mentions/clear-cursor))))
(rf/defn send-messages
[{:keys [db] :as cofx} input-text current-chat-id]
(let [image-messages (build-image-messages cofx current-chat-id)
text-message (build-text-message cofx input-text current-chat-id)
messages (keep identity (conj image-messages text-message))]
(when (seq messages)
(rf/merge cofx
(clean-input (:current-chat-id db))
(process-cooldown)
(chat.message/send-messages messages)))))
[{:keys [db] :as cofx} input-text current-chat-id]
(let [image-messages (build-image-messages cofx current-chat-id input-text)
text-message (when-not (seq image-messages) (build-text-message cofx input-text current-chat-id))
messages (keep identity (conj image-messages text-message))]
(println "iii" image-messages)
(when (seq messages)
(rf/merge cofx
(clean-input (:current-chat-id db))
(process-cooldown)
(chat.message/send-messages messages)))))
(rf/defn send-my-status-message
"when not empty, proceed by sending text message with public key topic"
{:events [:profile.ui/send-my-status-message]}
[{db :db :as cofx}]
(let [current-chat-id (chat/my-profile-chat-topic db)
{:keys [input-text]} (get-in db [:chat/inputs current-chat-id])
image-messages (build-image-messages cofx current-chat-id)
text-message (build-text-message cofx input-text current-chat-id)
messages (keep identity (conj image-messages text-message))]
(when (seq messages)
(rf/merge cofx
(clean-input current-chat-id)
(chat.message/send-messages messages)))))
"when not empty, proceed by sending text message with public key topic"
{:events [:profile.ui/send-my-status-message]}
[{db :db :as cofx}]
(let [current-chat-id (chat/my-profile-chat-topic db)
{:keys [input-text]} (get-in db [:chat/inputs current-chat-id])
image-messages (build-image-messages cofx current-chat-id input-text)
text-message (when-not (seq image-messages) (build-text-message cofx input-text current-chat-id))
messages (keep identity (conj image-messages text-message))]
(when (seq messages)
(rf/merge cofx
(clean-input current-chat-id)
(chat.message/send-messages messages)))))
(rf/defn send-audio-message
[cofx audio-path duration current-chat-id]
(when-not (string/blank? audio-path)
(chat.message/send-message
cofx
{:chat-id current-chat-id
:content-type constants/content-type-audio
:audio-path audio-path
:audio-duration-ms duration
:text (i18n/label :t/update-to-listen-audio {"locale" "en"})})))
[cofx audio-path duration current-chat-id]
(when-not (string/blank? audio-path)
(chat.message/send-message
cofx
{:chat-id current-chat-id
:content-type constants/content-type-audio
:audio-path audio-path
:audio-duration-ms duration
:text (i18n/label :t/update-to-listen-audio {"locale" "en"})})))
(rf/defn send-sticker-message
[cofx {:keys [hash packID pack]} current-chat-id]
(when-not (or (string/blank? hash) (and (string/blank? packID) (string/blank? pack)))
(chat.message/send-message cofx
{:chat-id current-chat-id
:content-type constants/content-type-sticker
:sticker {:hash hash
:pack (int (if (string/blank? packID) pack packID))}
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
[cofx {:keys [hash packID pack]} current-chat-id]
(when-not (or (string/blank? hash) (and (string/blank? packID) (string/blank? pack)))
(chat.message/send-message cofx
{:chat-id current-chat-id
:content-type constants/content-type-sticker
:sticker {:hash hash
:pack (int (if (string/blank? packID) pack packID))}
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
(rf/defn send-edited-message
[{:keys [db] :as cofx} text {:keys [message-id quoted-message]}]
(rf/merge
cofx
{:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id
:text text
:content-type (if (message-content/emoji-only-content?
{:text text :response-to quoted-message})
constants/content-type-emoji
constants/content-type-text)}]
:js-response true
:on-error #(log/error "failed to edit message " %)
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}
(cancel-message-edit)
(process-cooldown)))
[{:keys [db] :as cofx} text {:keys [message-id quoted-message]}]
(rf/merge
cofx
{:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id
:text text
:content-type (if (message-content/emoji-only-content?
{:text text :response-to quoted-message})
constants/content-type-emoji
constants/content-type-text)}]
:js-response true
:on-error #(log/error "failed to edit message " %)
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}
(cancel-message-edit)
(process-cooldown)))
(rf/defn send-current-message
"Sends message from current chat input"
{:events [:chat.ui/send-current-message]}
[{{:keys [current-chat-id] :as db} :db :as cofx}]
(let [{:keys [input-text metadata]} (get-in db [:chat/inputs current-chat-id])
editing-message (:editing-message metadata)
input-text-with-mentions (mentions/check-mentions cofx input-text)]
(rf/merge cofx
(if editing-message
(send-edited-message input-text-with-mentions editing-message)
(send-messages input-text-with-mentions current-chat-id))
(mentions/clear-mentions)
(mentions/clear-cursor))))
"Sends message from current chat input"
{:events [:chat.ui/send-current-message]}
[{{:keys [current-chat-id] :as db} :db :as cofx}]
(let [{:keys [input-text metadata]} (get-in db [:chat/inputs current-chat-id])
editing-message (:editing-message metadata)
input-text-with-mentions (mentions/check-mentions cofx input-text)]
(rf/merge cofx
(if editing-message
(send-edited-message input-text-with-mentions editing-message)
(send-messages input-text-with-mentions current-chat-id))
(mentions/clear-mentions)
(mentions/clear-cursor))))
(rf/defn send-contact-request
{:events [:contacts/send-contact-request]}
[{:keys [db] :as cofx} public-key message]
(rf/merge cofx
{:chat.ui/clear-inputs nil
:chat.ui/clear-inputs-old nil
:json-rpc/call [{:method "wakuext_sendContactRequest"
:js-response true
:params [{:id public-key :message message}]
:on-error #(log/warn "failed to send a contact request" %)
:on-success #(re-frame/dispatch [:transport/message-sent %])}]}
(mentions/clear-mentions)
(mentions/clear-cursor)
(clean-input (:current-chat-id db))
(process-cooldown)))
{:events [:contacts/send-contact-request]}
[{:keys [db] :as cofx} public-key message]
(rf/merge cofx
{:chat.ui/clear-inputs nil
:chat.ui/clear-inputs-old nil
:json-rpc/call [{:method "wakuext_sendContactRequest"
:js-response true
:params [{:id public-key :message message}]
:on-error #(log/warn "failed to send a contact request" %)
:on-success #(re-frame/dispatch [:transport/message-sent %])}]}
(mentions/clear-mentions)
(mentions/clear-cursor)
(clean-input (:current-chat-id db))
(process-cooldown)))
(rf/defn cancel-contact-request
"Cancels contact request"
{:events [:chat.ui/cancel-contact-request]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :sending-contact-request] nil)}
(mentions/clear-mentions)
(mentions/clear-cursor)
(clean-input (:current-chat-id db))
(process-cooldown))))
"Cancels contact request"
{:events [:chat.ui/cancel-contact-request]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
(rf/merge cofx
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :sending-contact-request] nil)}
(mentions/clear-mentions)
(mentions/clear-cursor)
(clean-input (:current-chat-id db))
(process-cooldown))))
(rf/defn chat-send-sticker
{:events [:chat/send-sticker]}
[{{:keys [current-chat-id] :as db} :db :as cofx} {:keys [hash packID pack] :as sticker}]
(rf/merge
cofx
{:db (update db
:stickers/recent-stickers
(fn [recent]
(conj (remove #(= hash (:hash %)) recent) sticker)))
:json-rpc/call [{:method "stickers_addRecent"
:params [(int (if (string/blank? packID) pack packID)) hash]
:on-success #()}]}
(send-sticker-message sticker current-chat-id)))
{:events [:chat/send-sticker]}
[{{:keys [current-chat-id] :as db} :db :as cofx} {:keys [hash packID pack] :as sticker}]
(rf/merge
cofx
{:db (update db
:stickers/recent-stickers
(fn [recent]
(conj (remove #(= hash (:hash %)) recent) sticker)))
:json-rpc/call [{:method "stickers_addRecent"
:params [(int (if (string/blank? packID) pack packID)) hash]
:on-success #()}]}
(send-sticker-message sticker current-chat-id)))
(rf/defn chat-send-audio
{:events [:chat/send-audio]}
[{{:keys [current-chat-id]} :db :as cofx} audio-path duration]
(send-audio-message cofx audio-path duration current-chat-id))
{:events [:chat/send-audio]}
[{{:keys [current-chat-id]} :db :as cofx} audio-path duration]
(send-audio-message cofx audio-path duration current-chat-id))
+2
View File
@@ -36,6 +36,8 @@
:deleted :deleted?
:deletedForMe :deleted-for-me?
:albumId :album-id
;:imageWidth :image-width
;:imageHeight :image-height
:new :new?})
(update :quoted-message
@@ -6,6 +6,8 @@
(defn build-message
[{:keys [chat-id
album-id
;image-width
;image-height
text
response-to
ens-name
@@ -17,6 +19,8 @@
content-type]}]
{:chatId chat-id
:albumId album-id
;:imageWidth image-width
;:imageHeight image-height
:text text
:responseTo response-to
:ensName ens-name
@@ -32,7 +36,8 @@
{:json-rpc/call [{:method "wakuext_sendChatMessages"
:params [(mapv build-message messages)]
:js-response true
:on-success #(re-frame/dispatch [:transport/message-sent %])
:on-success #(do
(re-frame/dispatch [:transport/message-sent %]))
:on-error #(do
(log/warn "failed to send a message" %)
(js/alert (str "failed to send a message: " %)))}]})
+111 -110
View File
@@ -1,114 +1,116 @@
(ns status-im.ui.screens.screens
(:require
[quo.design-system.colors :as colors]
[status-im.add-new.core :as new-chat.events]
[i18n.i18n :as i18n]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.screens.about-app.views :as about-app]
[status-im.ui.screens.add-new.new-chat.views :as new-chat]
[status-im.ui.screens.add-new.new-public-chat.view :as new-public-chat]
[status-im.ui.screens.advanced-settings.views :as advanced-settings]
[status-im.ui.screens.appearance.views :as appearance]
[status-im.ui.screens.backup-settings.view :as backup-settings]
[status-im.ui.screens.bootnodes-settings.edit-bootnode.views :as edit-bootnode]
[status-im.ui.screens.bootnodes-settings.views :as bootnodes-settings]
[status-im.ui.screens.browser.bookmarks.views :as bookmarks]
[status-im.ui.screens.browser.empty-tab.views :as empty-tab]
[status-im.ui.screens.browser.tabs.views :as browser.tabs]
[status-im.ui.screens.browser.views :as browser]
[status-im.ui.screens.bug-report :as bug-report]
[status-im.ui.screens.chat.pinned-messages :as pin-messages]
[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]
[status-im.ui.screens.communities.create :as communities.create]
[status-im.ui.screens.communities.create-category :as create-category]
[status-im.ui.screens.communities.create-channel :as create-channel]
[status-im.ui.screens.communities.edit :as community.edit]
[status-im.ui.screens.communities.edit-channel :as edit-channel]
[status-im.ui.screens.communities.import :as communities.import]
[status-im.ui.screens.communities.invite :as communities.invite]
[status-im.ui.screens.communities.members :as members]
[status-im.ui.screens.communities.membership :as membership]
[status-im.ui.screens.communities.profile :as community.profile]
[status-im.ui.screens.communities.reorder-categories :as reorder-categories]
[status-im.ui.screens.communities.requests-to-join :as requests-to-join]
[status-im.ui.screens.communities.select-category :as select-category]
[status-im.ui.screens.communities.views :as communities]
[status-im.ui.screens.contacts-list.views :as contacts-list]
[status-im.ui.screens.currency-settings.views :as currency-settings]
[status-im.ui.screens.dapps-permissions.views :as dapps-permissions]
[status-im.ui.screens.default-sync-period-settings.view :as default-sync-period-settings]
[status-im.ui.screens.ens.views :as ens]
[status-im.ui.screens.fleet-settings.views :as fleet-settings]
[status-im.ui.screens.glossary.view :as glossary]
[status-im.ui.screens.group.views :as group-chat]
[status-im.ui.screens.help-center.views :as help-center]
[status-im.ui.screens.keycard.authentication-method.views :as keycard.authentication]
[status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding]
[status-im.ui.screens.keycard.pairing.views :as keycard.pairing]
[status-im.ui.screens.keycard.pin.views :as keycard.pin]
[status-im.ui.screens.keycard.recovery.views :as keycard.recovery]
[status-im.ui.screens.keycard.settings.views :as keycard.settings]
[status-im.ui.screens.keycard.views :as keycard]
[status-im.ui.screens.link-previews-settings.views :as link-previews-settings]
[status-im.ui.screens.log-level-settings.views :as log-level-settings]
[status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings]
[status-im.ui.screens.multiaccounts.key-storage.views :as key-storage.views]
[status-im.ui.screens.multiaccounts.login.views :as login]
[status-im.ui.screens.multiaccounts.views :as multiaccounts]
[status-im.ui.screens.network-info.views :as network-info]
[status-im.ui.screens.network.edit-network.views :as edit-network]
[status-im.ui.screens.network.network-details.views :as network-details]
[status-im.ui.screens.network.views :as network]
[status-im.ui.screens.notifications-settings.views :as notifications-settings]
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :as edit-mailserver]
[status-im.ui.screens.offline-messaging-settings.views :as offline-messaging-settings]
[status-im.ui.screens.onboarding.intro.views :as onboarding.intro]
[status-im.ui.screens.onboarding.keys.views :as onboarding.keys]
[status-im.ui.screens.onboarding.notifications.views :as onboarding.notifications]
[status-im.ui.screens.onboarding.password.views :as onboarding.password]
[status-im.ui.screens.onboarding.phrase.view :as onboarding.phrase]
[status-im.ui.screens.onboarding.storage.views :as onboarding.storage]
[status-im.ui.screens.onboarding.welcome.views :as onboarding.welcome]
[status-im.ui.screens.pairing.views :as pairing]
[status-im.ui.screens.peers-stats :as peers-stats]
[status-im.ui.screens.privacy-and-security-settings.delete-profile :as delete-profile]
[status-im.ui.screens.privacy-and-security-settings.messages-from-contacts-only :as
messages-from-contacts-only]
[status-im.ui.screens.privacy-and-security-settings.views :as privacy-and-security]
[status-im.ui.screens.profile.contact.views :as contact]
[status-im.ui.screens.profile.group-chat.views :as profile.group-chat]
[status-im.ui.screens.profile.seed.views :as profile.seed]
[status-im.ui.screens.profile.user.views :as profile.user]
[status-im.ui.screens.progress.views :as progress]
[status-im.ui.screens.qr-scanner.views :as qr-scanner]
[status-im.ui.screens.reset-password.views :as reset-password]
[status-im.ui.screens.rpc-usage-info :as rpc-usage-info]
[status-im.ui.screens.status.new.views :as status.new]
[status-im.ui.screens.status.views :as status.views]
[status-im.ui.screens.stickers.views :as stickers]
[status-im.ui.screens.sync-settings.views :as sync-settings]
[status-im.ui.screens.terms-of-service.views :as terms-of-service]
[status-im.ui.screens.wakuv2-settings.edit-node.views :as edit-wakuv2-node]
[status-im.ui.screens.wakuv2-settings.views :as wakuv2-settings]
[status-im.ui.screens.wallet.account-settings.views :as account-settings]
[status-im.ui.screens.wallet.account.views :as wallet.account]
[status-im.ui.screens.wallet.accounts-manage.views :as accounts-manage]
[status-im.ui.screens.wallet.accounts.views :as wallet.accounts]
[status-im.ui.screens.wallet.add-new.views :as add-account]
[status-im.ui.screens.wallet.buy-crypto.views :as wallet.buy-crypto]
[status-im.ui.screens.wallet.collectibles.views :as wallet.collectibles]
[status-im.ui.screens.wallet.custom-tokens.views :as custom-tokens]
[status-im.ui.screens.wallet.manage-connections.views :as manage-all-connections]
[status-im.ui.screens.wallet.recipient.views :as recipient]
[status-im.ui.screens.wallet.send.views :as wallet.send]
[status-im.ui.screens.wallet.settings.views :as wallet-settings]
[status-im.ui.screens.wallet.swap.views :as wallet.swap]
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
[status-im2.contexts.chat.group-details.view :as group-details]
[status-im.ui2.screens.chat.components.new-chat.view :as new-chat-aio]))
[quo.design-system.colors :as colors]
[status-im.add-new.core :as new-chat.events]
[i18n.i18n :as i18n]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.screens.about-app.views :as about-app]
[status-im.ui.screens.add-new.new-chat.views :as new-chat]
[status-im.ui.screens.add-new.new-public-chat.view :as new-public-chat]
[status-im.ui.screens.advanced-settings.views :as advanced-settings]
[status-im.ui.screens.appearance.views :as appearance]
[status-im.ui.screens.backup-settings.view :as backup-settings]
[status-im.ui.screens.bootnodes-settings.edit-bootnode.views :as edit-bootnode]
[status-im.ui.screens.bootnodes-settings.views :as bootnodes-settings]
[status-im.ui.screens.browser.bookmarks.views :as bookmarks]
[status-im.ui.screens.browser.empty-tab.views :as empty-tab]
[status-im.ui.screens.browser.tabs.views :as browser.tabs]
[status-im.ui.screens.browser.views :as browser]
[status-im.ui.screens.bug-report :as bug-report]
[status-im.ui.screens.chat.pinned-messages :as pin-messages]
[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]
[status-im.ui.screens.communities.create :as communities.create]
[status-im.ui.screens.communities.create-category :as create-category]
[status-im.ui.screens.communities.create-channel :as create-channel]
[status-im.ui.screens.communities.edit :as community.edit]
[status-im.ui.screens.communities.edit-channel :as edit-channel]
[status-im.ui.screens.communities.import :as communities.import]
[status-im.ui.screens.communities.invite :as communities.invite]
[status-im.ui.screens.communities.members :as members]
[status-im.ui.screens.communities.membership :as membership]
[status-im.ui.screens.communities.profile :as community.profile]
[status-im.ui.screens.communities.reorder-categories :as reorder-categories]
[status-im.ui.screens.communities.requests-to-join :as requests-to-join]
[status-im.ui.screens.communities.select-category :as select-category]
[status-im.ui.screens.communities.views :as communities]
[status-im.ui.screens.contacts-list.views :as contacts-list]
[status-im.ui.screens.currency-settings.views :as currency-settings]
[status-im.ui.screens.dapps-permissions.views :as dapps-permissions]
[status-im.ui.screens.default-sync-period-settings.view :as default-sync-period-settings]
[status-im.ui.screens.ens.views :as ens]
[status-im.ui.screens.fleet-settings.views :as fleet-settings]
[status-im.ui.screens.glossary.view :as glossary]
[status-im.ui.screens.group.views :as group-chat]
[status-im.ui.screens.help-center.views :as help-center]
[status-im.ui.screens.keycard.authentication-method.views :as keycard.authentication]
[status-im.ui.screens.keycard.onboarding.views :as keycard.onboarding]
[status-im.ui.screens.keycard.pairing.views :as keycard.pairing]
[status-im.ui.screens.keycard.pin.views :as keycard.pin]
[status-im.ui.screens.keycard.recovery.views :as keycard.recovery]
[status-im.ui.screens.keycard.settings.views :as keycard.settings]
[status-im.ui.screens.keycard.views :as keycard]
[status-im.ui.screens.link-previews-settings.views :as link-previews-settings]
[status-im.ui.screens.log-level-settings.views :as log-level-settings]
[status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings]
[status-im.ui.screens.multiaccounts.key-storage.views :as key-storage.views]
[status-im.ui.screens.multiaccounts.login.views :as login]
[status-im.ui.screens.multiaccounts.views :as multiaccounts]
[status-im.ui.screens.network-info.views :as network-info]
[status-im.ui.screens.network.edit-network.views :as edit-network]
[status-im.ui.screens.network.network-details.views :as network-details]
[status-im.ui.screens.network.views :as network]
[status-im.ui.screens.notifications-settings.views :as notifications-settings]
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :as edit-mailserver]
[status-im.ui.screens.offline-messaging-settings.views :as offline-messaging-settings]
[status-im.ui.screens.onboarding.intro.views :as onboarding.intro]
[status-im.ui.screens.onboarding.keys.views :as onboarding.keys]
[status-im.ui.screens.onboarding.notifications.views :as onboarding.notifications]
[status-im.ui.screens.onboarding.password.views :as onboarding.password]
[status-im.ui.screens.onboarding.phrase.view :as onboarding.phrase]
[status-im.ui.screens.onboarding.storage.views :as onboarding.storage]
[status-im.ui.screens.onboarding.welcome.views :as onboarding.welcome]
[status-im.ui.screens.pairing.views :as pairing]
[status-im.ui.screens.peers-stats :as peers-stats]
[status-im.ui.screens.privacy-and-security-settings.delete-profile :as delete-profile]
[status-im.ui.screens.privacy-and-security-settings.messages-from-contacts-only :as
messages-from-contacts-only]
[status-im.ui.screens.privacy-and-security-settings.views :as privacy-and-security]
[status-im.ui.screens.profile.contact.views :as contact]
[status-im.ui.screens.profile.group-chat.views :as profile.group-chat]
[status-im.ui.screens.profile.seed.views :as profile.seed]
[status-im.ui.screens.profile.user.views :as profile.user]
[status-im.ui.screens.progress.views :as progress]
[status-im.ui.screens.qr-scanner.views :as qr-scanner]
[status-im.ui.screens.reset-password.views :as reset-password]
[status-im.ui.screens.rpc-usage-info :as rpc-usage-info]
[status-im.ui.screens.status.new.views :as status.new]
[status-im.ui.screens.status.views :as status.views]
[status-im.ui.screens.stickers.views :as stickers]
[status-im.ui.screens.sync-settings.views :as sync-settings]
[status-im.ui.screens.terms-of-service.views :as terms-of-service]
[status-im.ui.screens.wakuv2-settings.edit-node.views :as edit-wakuv2-node]
[status-im.ui.screens.wakuv2-settings.views :as wakuv2-settings]
[status-im.ui.screens.wallet.account-settings.views :as account-settings]
[status-im.ui.screens.wallet.account.views :as wallet.account]
[status-im.ui.screens.wallet.accounts-manage.views :as accounts-manage]
[status-im.ui.screens.wallet.accounts.views :as wallet.accounts]
[status-im.ui.screens.wallet.add-new.views :as add-account]
[status-im.ui.screens.wallet.buy-crypto.views :as wallet.buy-crypto]
[status-im.ui.screens.wallet.collectibles.views :as wallet.collectibles]
[status-im.ui.screens.wallet.custom-tokens.views :as custom-tokens]
[status-im.ui.screens.wallet.manage-connections.views :as manage-all-connections]
[status-im.ui.screens.wallet.recipient.views :as recipient]
[status-im.ui.screens.wallet.send.views :as wallet.send]
[status-im.ui.screens.wallet.settings.views :as wallet-settings]
[status-im.ui.screens.wallet.swap.views :as wallet.swap]
[status-im.ui.screens.wallet.transactions.views :as wallet-transactions]
[status-im2.contexts.chat.group-details.view :as group-details]
[status-im.ui2.screens.chat.components.new-chat.view :as new-chat-aio]
[status-im2.contexts.chat.images-horizontal.view :as images-horizontal]
[react-native.core :as rn]))
(defn right-button-options
[id icon]
@@ -207,7 +209,6 @@
:component pin-messages/pinned-messages}
{:name :group-chat-profile
;;TODO animated-header
:options {:topBar {:visible false}}
:component group-details/group-details}
{:name :group-chat-invite
@@ -9,10 +9,10 @@
[item]
[rn/view
[rn/image
{:source {:uri (first item)}
{:source {:uri (:uri (val item))}
:style style/small-image}]
[rn/touchable-opacity
{:on-press (fn [] (rf/dispatch [:chat.ui/image-unselected (first item)]))
{:on-press (fn [] (rf/dispatch [:chat.ui/image-unselected (val item)]))
:style style/remove-photo-container
:hit-slop {:right 5
:left 5
@@ -271,6 +271,7 @@
(reanimated/set-shared-value translate-y (reanimated/with-timing (- y)))
(reanimated/set-shared-value shared-height
(reanimated/with-timing (min y max-height))))))
(println "iiixx" images)
[reanimated/view
{:style (reanimated/apply-animations-to-style
{:height shared-height}
@@ -0,0 +1,73 @@
(ns status-im2.contexts.chat.images-horizontal.view
(:require [quo2.core :as quo]
[quo2.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.fast-image :as fast-image]
[status-im2.contexts.chat.messages.content.album.style :as style]
[status-im2.common.constants :as constants]
[reagent.core :as reagent]
[utils.re-frame :as rf]
[react-native.safe-area :as safe-area]))
(defn image-set-size
[dimensions]
(fn [evt]
(let [width (.-width (.-nativeEvent evt))
height (.-height (.-nativeEvent evt))
max-width (:width (rn/get-window))
max-height (* 1.25 (:width (rn/get-window)))]
(if (> height width)
(let [calculated-height (* height (/ max-width width))]
(reset! dimensions {:width max-width :height calculated-height :loaded true}))
(let [calculated-height (* height (/ max-width width))]
(reset! dimensions {:width max-width :height calculated-height :loaded true}))))))
(defn image [message index _ {:keys [dimensions-arr shared-element-id]}]
(let [dimensions (nth dimensions-arr index)]
[fast-image/fast-image
{:source {:uri (:image (:content message))}
:on-error #(swap! dimensions assoc :error true)
:style {:width (:width (rn/get-window))
:height (* (:height dimensions) (/ (:width (rn/get-window)) (:width dimensions)))
:border-radius 12}
:nativeID (when (= shared-element-id (:message-id message)) :shared-element)}]
))
(defn images-horizontal
[]
(let [{:keys [messages dimensions]} (rf/sub [:get-screen-params])
shared-element-id (rf/sub [:shared-element-id])]
(rn/set-status-bar-style "light-content")
[safe-area/consumer
(fn [insets]
[rn/view
{:style {:background-color "#000"
:flex 1
:padding-top (:top insets)}}
[rn/view {:style {:position :absolute
:left 20
:top (+ 12 (:top insets))
:z-index 1
}}
[rn/touchable-opacity {:active-opacity 1
:on-press #(rf/dispatch [:navigate-back])
:style {:width 32
:height 32
:border-radius 12
:justify-content :center
:align-items :center
:background-color colors/neutral-80-opa-40}}
[quo/icon :close {:size 20 :color colors/white}]]]
[rn/flat-list
{:key-fn :message-id
:data messages
:render-fn image
:render-data {:dimensions-arr dimensions
:shared-element-id shared-element-id}
:horizontal true
:content-container-style {:width "100%"
:height "100%"
:justify-content :center
:align-items :center}}]])]))
@@ -0,0 +1,47 @@
(ns status-im2.contexts.chat.messages.content.image.view
(:require [react-native.core :as rn]
[react-native.fast-image :as fast-image]
[reagent.core :as reagent]
[status-im2.navigation.events :as navigation]
[status-im2.navigation.state :as state]
[utils.re-frame :as rf]))
(defn image-set-size
[dimensions]
(fn [evt]
(let [width (.-width (.-nativeEvent evt))
height (.-height (.-nativeEvent evt))
max-width (if (> width height) 320 190)
max-height (if (> width height) 190 320)]
(if (> height width)
(let [calculated-height (* (min height max-height) (/ (max width max-width) width))
calculated-width (* (max width max-width) (/ (min height max-height) height))]
(reset! dimensions {:width calculated-width :height calculated-height :loaded true}))
(let [calculated-height (* (max height max-height) (/ (min width max-width) width))
calculated-width (* (min width max-width) (/ (max height max-height) height))]
(reset! dimensions {:width calculated-width :height calculated-height :loaded true}))))))
(defn image-message
[{:keys [content] :as message}]
(let [dimensions (reagent/atom {:width 320 :height 320 :loaded false})]
(fn []
(let [style-opts {:outgoing false
:opacity (if (:loaded @dimensions) 1 0)
:width (:width @dimensions)
:height (:height @dimensions)
:border-radius 12}
shared-element-id (rf/sub [:shared-element-id])]
[rn/touchable-opacity
{:active-opacity 1
:on-press (fn []
(rf/dispatch [:chat.ui/update-shared-element-id (:message-id message)])
(js/setTimeout #(rf/dispatch [:chat.ui/navigate-to-horizontal-images [message] [@dimensions]]) 0))
}
[fast-image/fast-image
{:source {:uri (:image content)}
:on-load (image-set-size dimensions)
:on-error #(swap! dimensions assoc :error true)
:style (dissoc style-opts :outgoing)
:nativeID (when (= shared-element-id (:message-id message)) :shared-element)}]]))))
@@ -11,6 +11,7 @@
[status-im2.contexts.chat.messages.content.status.view :as status]
[status-im2.contexts.chat.messages.content.system.text.view :as system.text]
[status-im2.contexts.chat.messages.content.album.view :as album]
[status-im2.contexts.chat.messages.content.image.view :as image]
[quo2.core :as quo]
[utils.re-frame :as rf]
[status-im.ui2.screens.chat.messages.message :as old-message]
@@ -89,8 +90,8 @@
constants/content-type-sticker [not-implemented/not-implemented
[old-message/sticker message-data]]
constants/content-type-image [not-implemented/not-implemented
[old-message/message-content-image message-data]]
;constants/content-type-image [old-message/message-content-image message-data]
constants/content-type-image [image/image-message message-data]
constants/content-type-audio [not-implemented/not-implemented
[old-message/audio message-data]]
@@ -18,9 +18,11 @@
[chat-id]
(rf/dispatch [:chat.ui/clear-sending-images chat-id])
(doseq [item @selected]
(rf/dispatch [:chat.ui/camera-roll-pick item]))
(rf/dispatch [:chat.ui/camera-roll-pick item])
)
(reset! selected [])
(rf/dispatch [:bottom-sheet/hide]))
(rf/dispatch [:bottom-sheet/hide])
)
(defn bottom-gradient
[chat-id selected-images]
@@ -63,7 +65,7 @@
(swap! selected conj item)))
:accessibility-label (str "image-" index)}
[rn/image
{:source {:uri item}
{:source {:uri (:uri item)}
:style (style/image window-width index)}]
(when (some #{item} @selected)
[rn/view {:style (style/overlay window-width)}])
@@ -77,10 +79,14 @@
[chat-id]
(rf/dispatch [:chat.ui/camera-roll-get-photos 20])
(let [selected-images (keys (rf/sub [:chats/sending-image]))]
(when selected-images
(reset! selected (vec selected-images)))
[:f>
(fn []
(rn/use-effect-once
#(do
(if selected-images
(reset! selected (vec selected-images))
(reset! selected []))
js/undefined))
(let [{window-height :height window-width :width} (rn/use-window-dimensions)
safe-area (safe-area/use-safe-area)
camera-roll-photos (rf/sub [:camera-roll/photos])
+19 -1
View File
@@ -8,7 +8,11 @@
[status-im2.contexts.quo-preview.main :as quo.preview]
[status-im2.contexts.shell.view :as shell]
[status-im2.contexts.syncing.view :as settings-syncing]
[status-im2.setup.config :as config]))
[status-im2.setup.config :as config]
[quo.design-system.colors :as colors]
[status-im2.contexts.chat.images-horizontal.view :as images-horizontal]
[status-im2.navigation.state :as state]
[utils.re-frame :as rf]))
(def components
[])
@@ -28,6 +32,20 @@
:options {:topBar {:visible false}}
:component chat/chat}
{:name :images-horizontal
:insets {:top false :bottom false}
:options {:topBar {:visible false}
:navigationBar {:backgroundColor colors/black-persist}
:statusBar {:backgroundColor colors/black-persist
:style :light}
:animations {:push {:sharedElementTransitions [{:fromId :shared-element
:toId :shared-element
:interpolation {:type :decelerate}}]}
:pop {:sharedElementTransitions [{:fromId :shared-element
:toId :shared-element
:interpolation {:type :decelerate}}]}}}
:component images-horizontal/images-horizontal}
{:name :discover-communities
:options {:topBar {:visible false}}
:component communities.discover/discover}
+1
View File
@@ -6,3 +6,4 @@
(defonce curr-modal (atom nil))
(defonce modals (atom []))
(defonce dissmissing (atom false))
(def shared-element (atom {:id "0xdb5bb2aa7a3711be379fce02c25cd33ec75c34304caafbf06d21d3f15679c1a6"}))
+7 -3
View File
@@ -15,7 +15,8 @@
[status-im2.common.toasts.view :as toasts]
[status-im2.navigation.screens :as screens]
[status-im2.setup.config :as config]
[status-im2.setup.hot-reload :as reloader]))
[status-im2.setup.hot-reload :as reloader]
[utils.re-frame :as rf]))
(defn get-screens
[]
@@ -39,9 +40,12 @@
(defn wrapped-screen-style
[{:keys [insets style]} insets-obj]
(let [view-id (rf/sub [:view-id])]
(merge
{:flex 1
:background-color (colors/theme-colors colors/white colors/neutral-100)}
;:background-color (if (= view-id :images-horizontal) "#000" (colors/theme-colors colors/white colors/neutral-100))
:background-color (colors/theme-colors colors/white colors/neutral-100)
}
style
(when (get insets :bottom)
{:padding-bottom (+ (oget insets-obj "bottom")
@@ -50,7 +54,7 @@
(when (get insets :top true)
{:padding-top (+ (oget insets-obj "top")
(get style :padding-top)
(get style :padding-vertical))})))
(get style :padding-vertical))}))))
(defn inactive
[]
+2 -2
View File
@@ -4,12 +4,12 @@
[utils.re-frame :as rf]))
;; Ignore all logs, because there are lots of temporary warnings when developing and hot reloading
(.ignoreAllLogs LogBox)
;(.ignoreAllLogs LogBox)
;; Only ignore warnings/errors that cannot be fixed for the time being.
;; When you add a warning to be ignored explain below why it is ignored and how it can be fixed.
;; When a warning is fixed make sure to remove it from here.
#_(.ignoreLogs ^js LogBox
(.ignoreLogs ^js LogBox
(clj->js ["undefined is not an object (evaluating 'e.message')"
"Cannot read property 'message' of undefined"
"InternalError Metro has encountered an error"
+6
View File
@@ -424,3 +424,9 @@
:<- [:chat/inputs-with-mentions]
(fn [[chat-id cursor]]
(get cursor chat-id)))
(re-frame/reg-sub
:shared-element-id
:<- [:shared-element-id]
(fn [shared-element-id]
shared-element-id))
+1
View File
@@ -111,6 +111,7 @@
(reg-root-key-sub :chats/mention-suggestions :chats/mention-suggestions)
(reg-root-key-sub :chat/inputs-with-mentions :chat/inputs-with-mentions)
(reg-root-key-sub :chats-home-list :chats-home-list)
(reg-root-key-sub :shared-element-id :shared-element-id)
;;messages
(reg-root-key-sub :messages/messages :messages)
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.117.3",
"commit-sha1": "d40290a649133eb7b7f450b5c5b74eec28ba232d",
"src-sha256": "140j0gbp8nxzncya9mcpvlxnax5ajfl8c32ih20b29n8j525gw66"
"version": "447187659e58d6cd1df1a453e57a1c84d49c5e57",
"commit-sha1": "447187659e58d6cd1df1a453e57a1c84d49c5e57",
"src-sha256": "1ilyr0125iwd1yhq28xvrklr43r5b41f7vz8hrmn1lwv8dqp5q92"
}