move blob to rn, remove unused code, move images events to status-im2 (#18117)

This commit is contained in:
flexsurfer 2023-12-08 17:27:21 +01:00 committed by GitHub
parent 7a6f05a440
commit f79860fb97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 141 additions and 1628 deletions

View File

@ -368,17 +368,6 @@
:LineChart #js {} :LineChart #js {}
:LineChartBicolor #js {}}) :LineChartBicolor #js {}})
(def wallet-connect-client
#js
{:default #js {}
:CLIENT_EVENTS #js
{:session #js
{:request nil
:created nil
:deleted nil
:proposal nil
:updated nil}}})
(def worklet-factory (def worklet-factory
#js {:applyAnimationsToStyle (fn [])}) #js {:applyAnimationsToStyle (fn [])})
@ -447,7 +436,6 @@
"../src/js/worklets/parallax.js" #js {} "../src/js/worklets/parallax.js" #js {}
"../src/js/worklets/identifiers_highlighting.js" #js {} "../src/js/worklets/identifiers_highlighting.js" #js {}
"./fleets.js" default-fleets "./fleets.js" default-fleets
"@walletconnect/client" wallet-connect-client
"../translations/ar.json" (js/JSON.parse (slurp "./translations/ar.json")) "../translations/ar.json" (js/JSON.parse (slurp "./translations/ar.json"))
"../translations/de.json" (js/JSON.parse (slurp "./translations/de.json")) "../translations/de.json" (js/JSON.parse (slurp "./translations/de.json"))
"../translations/en.json" (js/JSON.parse (slurp "./translations/en.json")) "../translations/en.json" (js/JSON.parse (slurp "./translations/en.json"))

View File

@ -0,0 +1,10 @@
(ns react-native.blob
(:require ["react-native-blob-util" :default ReactNativeBlobUtil]
[taoensso.timbre :as log]))
(defn fetch
[base64-uri config on-success]
(-> (.config ReactNativeBlobUtil (clj->js config))
(.fetch "GET" base64-uri)
(.then #(on-success (.path %)))
(.catch #(log/error "could not download uri" {:error %}))))

View File

@ -1,64 +0,0 @@
(ns status-im.chat.models.gaps
(:require
[status-im.mailserver.core :as mailserver]
[status-im2.contexts.chat.messages.list.events :as message-list]
[taoensso.timbre :as log]
[utils.re-frame :as rf]))
(rf/defn gaps-filled
{:events [:gaps/filled]}
[{:keys [db] :as cofx} chat-id message-ids]
(rf/merge
cofx
{:db (-> db
(update-in [:messages chat-id] (fn [messages] (apply dissoc messages message-ids)))
(dissoc :mailserver/fetching-gaps-in-progress))}
(message-list/rebuild-message-list chat-id)))
(rf/defn gaps-failed
{:events [:gaps/failed]}
[{:keys [db]} chat-id gap-ids error]
(log/error "failed to fetch gaps" chat-id gap-ids error)
{:db (dissoc db :mailserver/fetching-gaps-in-progress)})
(rf/defn sync-chat-from-sync-from-failed
{:events [::sync-chat-from-sync-from-failed]}
[{:keys [db]} chat-id error]
(log/error "failed to sync chat" chat-id error)
{:db (dissoc db :mailserver/fetching-gaps-in-progress)})
(rf/defn sync-chat-from-sync-from-success
{:events [::sync-chat-from-sync-from-success]}
[{:keys [db] :as cofx} chat-id synced-from]
(log/debug "synced success" chat-id synced-from)
{:db
(-> db
(assoc-in [:chats chat-id :synced-from] synced-from)
(dissoc :mailserver/fetching-gaps-in-progress))})
(rf/defn fill-gaps
[_ chat-id gap-ids]
{:json-rpc/call [{:method "wakuext_fillGaps"
:params [chat-id gap-ids]
:on-success #(rf/dispatch [:gaps/filled chat-id gap-ids %])
:on-error #(rf/dispatch [:gaps/failed chat-id gap-ids %])}]})
(rf/defn sync-chat-from-sync-from
[_ chat-id]
(log/debug "syncing chat from sync from")
{:json-rpc/call [{:method "wakuext_syncChatFromSyncedFrom"
:params [chat-id]
:on-success #(rf/dispatch [::sync-chat-from-sync-from-success chat-id %])
:on-error #(rf/dispatch [::sync-chat-from-sync-from-failed chat-id %])}]})
(rf/defn chat-ui-fill-gaps
{:events [:chat.ui/fill-gaps]}
[{:keys [db] :as cofx} chat-id gap-ids]
(let [use-status-nodes? (mailserver/fetch-use-mailservers? {:db db})]
(log/info "filling gaps if use-status-nodes = true" chat-id gap-ids)
(when use-status-nodes?
(rf/merge cofx
{:db (assoc db :mailserver/fetching-gaps-in-progress gap-ids)}
(if (= gap-ids #{:first-gap})
(sync-chat-from-sync-from chat-id)
(fill-gaps chat-id gap-ids))))))

View File

@ -1,73 +0,0 @@
(ns status-im.chat.models.images
(:require
["react-native-blob-util" :default ReactNativeBlobUtil]
[re-frame.core :as re-frame]
[react-native.cameraroll :as cameraroll]
[react-native.fs :as fs]
[react-native.platform :as platform]
[react-native.share :as share]
[status-im.ui.components.react :as react]
[status-im2.constants :as constants]
[taoensso.timbre :as log]
[utils.re-frame :as rf]))
(def temp-image-url (str (fs/cache-dir) "/StatusIm_Image.jpeg"))
(defn download-image-http
[base64-uri on-success]
(-> (.config ReactNativeBlobUtil
(clj->js {:trusty platform/ios?
:path temp-image-url}))
(.fetch "GET" base64-uri)
(.then #(on-success (.path %)))
(.catch #(log/error "could not download image" {:error %}))))
(defn share-image
[uri]
(download-image-http uri
(fn [downloaded-url]
(share/open {:url (str (when platform/android? "file://") downloaded-url)
:isNewTask true}
#(fs/unlink downloaded-url)
#(fs/unlink downloaded-url)))))
(defn save-image-to-gallery
[base64-uri on-success]
(-> (download-image-http base64-uri cameraroll/save-image)
(.then on-success)
(.catch #(log/error (str "could not save image to gallery" %)))))
(re-frame/reg-fx
::chat-open-image-picker-camera
(fn [current-chat-id]
(react/show-image-picker-camera
#(re-frame/dispatch [:chat.ui/image-captured current-chat-id (.-path %)])
{})))
(rf/defn image-captured
{:events [:chat.ui/image-captured]}
[{:keys [db]} chat-id uri]
(let [current-chat-id (or chat-id (:current-chat-id db))
images (get-in db [:chat/inputs current-chat-id :metadata :sending-image])]
(when (and (< (count images) constants/max-album-photos)
(not (get images uri)))
{::image-selected [uri current-chat-id]})))
(rf/defn clear-sending-images
{:events [:chat.ui/clear-sending-images]}
[{:keys [db]}]
{:db (update-in db [:chat/inputs (:current-chat-id db) :metadata] assoc :sending-image {})})
(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 (:uri original))}))
(rf/defn chat-show-image-picker-camera
{:events [:chat.ui/show-image-picker-camera]}
[{:keys [db]} 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])]
(when (< (count images) constants/max-album-photos)
{::chat-open-image-picker-camera current-chat-id})))

View File

@ -5,7 +5,6 @@
[goog.object :as object] [goog.object :as object]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.chat.models.mentions :as mentions] [status-im.chat.models.mentions :as mentions]
[status-im.chat.models.message-content :as message-content]
[status-im.data-store.messages :as data-store-messages] [status-im.data-store.messages :as data-store-messages]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.composer.link-preview.events :as link-preview] [status-im2.contexts.chat.composer.link-preview.events :as link-preview]
@ -139,13 +138,20 @@
(let [current-chat-id (:current-chat-id db)] (let [current-chat-id (:current-chat-id db)]
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)})) {:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)}))
(defn emoji-only-content?
"Determines if text is just an emoji"
[{:keys [text response-to]}]
(and (not response-to)
(string? text)
(re-matches constants/regx-emoji text)))
(defn build-text-message (defn build-text-message
[{:keys [db]} input-text current-chat-id] [{:keys [db]} input-text current-chat-id]
(when-not (string/blank? input-text) (when-not (string/blank? input-text)
(let [{:keys [message-id]} (let [{:keys [message-id]}
(get-in db [:chat/inputs current-chat-id :metadata :responding-to-message]) (get-in db [:chat/inputs current-chat-id :metadata :responding-to-message])
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? (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?
@ -243,7 +249,7 @@
{:json-rpc/call [{:method "wakuext_editMessage" {:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id :params [{:id message-id
:text text :text text
:content-type (if (message-content/emoji-only-content? :content-type (if (emoji-only-content?
{:text text {:text text
:response-to quoted-message}) :response-to quoted-message})
constants/content-type-emoji constants/content-type-emoji

View File

@ -9,7 +9,6 @@
[status-im2.contexts.chat.messages.delete-message.events :as delete-message] [status-im2.contexts.chat.messages.delete-message.events :as delete-message]
[status-im2.contexts.chat.messages.list.events :as message-list] [status-im2.contexts.chat.messages.list.events :as message-list]
[status-im2.contexts.chat.messages.list.state :as view.state] [status-im2.contexts.chat.messages.list.state :as view.state]
[taoensso.timbre :as log]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn- message-loaded? (defn- message-loaded?
@ -116,30 +115,12 @@
(when (and (:current-chat-id db) (= "active" (:app-state db))) (when (and (:current-chat-id db) (= "active" (:app-state db)))
[{:ms 100 :dispatch [:chat/mark-all-as-read (:current-chat-id db)]}]))})) [{:ms 100 :dispatch [:chat/mark-all-as-read (:current-chat-id db)]}]))}))
(rf/defn update-db-message-status
[{:keys [db] :as cofx} chat-id message-id status]
(when (get-in db [:messages chat-id message-id])
(rf/merge cofx
{:db (assoc-in db
[:messages chat-id message-id :outgoing-status]
status)})))
(rf/defn update-message-status (rf/defn update-message-status
[{:keys [db] :as cofx} chat-id message-id status] [{:keys [db]} chat-id message-id status]
(rf/merge cofx (when (get-in db [:messages chat-id message-id])
(update-db-message-status chat-id message-id status))) {:db (assoc-in db [:messages chat-id message-id :outgoing-status] status)}))
(rf/defn resend-message
[{:keys [db] :as cofx} chat-id message-id]
(rf/merge cofx
{:json-rpc/call [{:method "wakuext_reSendChatMessage"
:params [message-id]
:on-success #(log/debug "re-sent message successfully")
:on-error #(log/error "failed to re-send message" %)}]}
(update-message-status chat-id message-id :sending)))
(rf/defn handle-removed-messages (rf/defn handle-removed-messages
{:events [::handle-removed-messages]}
[{:keys [db] :as cofx} removed-messages] [{:keys [db] :as cofx} removed-messages]
(let [mark-as-deleted-fx (->> removed-messages (let [mark-as-deleted-fx (->> removed-messages
(map #(assoc % (map #(assoc %
@ -166,14 +147,6 @@
(concat mark-as-seen-fx) (concat mark-as-seen-fx)
(conj remove-messages-fx))))) (conj remove-messages-fx)))))
(comment
(handle-removed-messages
{:db {:messages {:c1 {:m1 {:chat-id :c1 :message-id :m1}
:m2 {:chat-id :c1 :message-id :m2}}
:c2 {:m3 {:chat-id :c2 :message-id :m3}
:m4 {:chat-id :c2 :message-id :m4}}}}}
[:m1 :m3]))
(defn remove-cleared-message (defn remove-cleared-message
[messages cleared-at] [messages cleared-at]
(into {} (into {}
@ -182,7 +155,6 @@
messages))) messages)))
(rf/defn handle-cleared-histories-messages (rf/defn handle-cleared-histories-messages
{:events [::handle-cleared-hisotories-messages]}
[{:keys [db]} cleared-histories] [{:keys [db]} cleared-histories]
{:db (reduce (fn [acc current] {:db (reduce (fn [acc current]
(update-in acc (update-in acc

View File

@ -1,10 +0,0 @@
(ns status-im.chat.models.message-content
(:require
[status-im2.constants :as constants]))
(defn emoji-only-content?
"Determines if text is just an emoji"
[{:keys [text response-to]}]
(and (not response-to)
(string? text)
(re-matches constants/regx-emoji text)))

View File

@ -10,8 +10,6 @@
status-im.bootnodes.core status-im.bootnodes.core
status-im.browser.core status-im.browser.core
status-im.browser.permissions status-im.browser.permissions
status-im.chat.models.gaps
status-im.chat.models.images
status-im.chat.models.input status-im.chat.models.input
status-im.chat.models.loading status-im.chat.models.loading
status-im.contact.block status-im.contact.block

View File

@ -96,8 +96,6 @@
:contact (handle-view-profile cofx data) :contact (handle-view-profile cofx data)
:browser (handle-browse cofx data) :browser (handle-browse cofx data)
:eip681 (handle-eip681 cofx data) :eip681 (handle-eip681 cofx data)
;; Re-enable with https://github.com/status-im/status-mobile/issues/13429
;;:wallet-connect (handle-wallet-connect cofx data)
:localpairing (handle-local-pairing cofx data) :localpairing (handle-local-pairing cofx data)
(do (do
(log/info "Unable to find matcher for scanned value" (log/info "Unable to find matcher for scanned value"

View File

@ -121,14 +121,6 @@
(reg-root-key-sub :signing/tx :signing/tx) (reg-root-key-sub :signing/tx :signing/tx)
(reg-root-key-sub :signing/edit-fee :signing/edit-fee) (reg-root-key-sub :signing/edit-fee :signing/edit-fee)
;; wallet connect
(reg-root-key-sub :wallet-connect/proposal-metadata :wallet-connect/proposal-metadata)
(reg-root-key-sub :wallet-connect/enabled? :wallet-connect/enabled?)
(reg-root-key-sub :wallet-connect/session-connected :wallet-connect/session-connected)
(reg-root-key-sub :wallet-connect/showing-app-management-sheet?
:wallet-connect/showing-app-management-sheet?)
(reg-root-key-sub :wallet-connect/sessions :wallet-connect/sessions)
(reg-root-key-sub :wallet-connect/session-managed :wallet-connect/session-managed)
(reg-root-key-sub :contact-requests/pending :contact-requests/pending) (reg-root-key-sub :contact-requests/pending :contact-requests/pending)
(reg-root-key-sub :bug-report/description-error :bug-report/description-error) (reg-root-key-sub :bug-report/description-error :bug-report/description-error)

View File

@ -98,17 +98,6 @@
{:public-key chat-id {:public-key chat-id
:photo-container (:default-chat-icon styles)}])]) :photo-container (:default-chat-icon styles)}])])
(defn chat-icon-view-toolbar
[chat-id group-chat name color emoji size]
[emoji-chat-icon-view chat-id group-chat name emoji
{:container (styles/container-chat-toolbar size)
:size size
:chat-icon (styles/chat-icon-chat-toolbar size)
:default-chat-icon (styles/default-chat-icon-chat-toolbar color size)
:default-chat-icon-text (if (string/blank? emoji)
(styles/default-chat-icon-text size)
(styles/emoji-chat-icon-text size))}])
(defn chat-icon-view-chat-list (defn chat-icon-view-chat-list
[chat-id group-chat name color] [chat-id group-chat name color]
[chat-icon-view chat-id group-chat name [chat-icon-view chat-id group-chat name
@ -118,19 +107,6 @@
:default-chat-icon (styles/default-chat-icon-chat-list color) :default-chat-icon (styles/default-chat-icon-chat-list color)
:default-chat-icon-text (styles/default-chat-icon-text 40)}]) :default-chat-icon-text (styles/default-chat-icon-text 40)}])
(defn chat-icon-view-chat-list-redesign
[chat-id group-chat name color size]
[chat-icon-view chat-id group-chat name
{:container (if (= size 20)
(styles/token-icon-container-chat-list size)
(styles/community-icon-container-chat-list size))
:size size
:chat-icon (if (= size 20)
(styles/community-icon-chat-list-redesign size)
(styles/community-icon-chat-list size))
:default-chat-icon (styles/default-list-chat-icon-redesign color size)
:default-chat-icon-text (styles/default-chat-icon-text size)}])
(defn chat-icon-view-chat-sheet (defn chat-icon-view-chat-sheet
[chat-id group-chat name color] [chat-id group-chat name color]
[chat-icon-view chat-id group-chat name [chat-icon-view chat-id group-chat name
@ -140,17 +116,6 @@
:default-chat-icon (styles/default-chat-icon-chat-list color) :default-chat-icon (styles/default-chat-icon-chat-list color)
:default-chat-icon-text (styles/default-chat-icon-text 40)}]) :default-chat-icon-text (styles/default-chat-icon-text 40)}])
(defn emoji-chat-icon-view-chat-sheet
[chat-id group-chat name color emoji]
[emoji-chat-icon-view chat-id group-chat name emoji
{:container styles/container-chat-list
:size 40
:chat-icon styles/chat-icon-chat-list
:default-chat-icon (styles/default-chat-icon-chat-list color)
:default-chat-icon-text (if (string/blank? emoji)
(styles/default-chat-icon-text 40)
(styles/emoji-chat-icon-text 40))}])
(defn custom-icon-view-list (defn custom-icon-view-list
[name color & [size]] [name color & [size]]
[rn/view (styles/container-list-size (or size 40)) [rn/view (styles/container-list-size (or size 40))
@ -181,24 +146,6 @@
:default-chat-icon (styles/default-chat-icon-profile colors/default-chat-color size) :default-chat-icon (styles/default-chat-icon-profile colors/default-chat-color size)
:default-chat-icon-text (styles/default-chat-icon-text size)}]) :default-chat-icon-text (styles/default-chat-icon-text size)}])
(defn chat-intro-icon-view
[icon-text chat-id group-chat styles]
(if group-chat
[default-chat-icon icon-text styles]
(let [photo-path @(re-frame.core/subscribe [:chats/photo-path chat-id])]
(when-not (string/blank? photo-path)
[photos/photo photo-path styles]))))
(defn emoji-chat-intro-icon-view
[icon-text chat-id group-chat emoji styles]
(if group-chat
(if (string/blank? emoji)
[default-chat-icon icon-text styles]
[emoji-chat-icon emoji styles])
(let [photo-path @(re-frame.core/subscribe [:chats/photo-path chat-id])]
(when-not (string/blank? photo-path)
[photos/photo photo-path styles]))))
(defn profile-icon-view (defn profile-icon-view
[photo-path name color emoji edit? size override-styles public-key community?] [photo-path name color emoji edit? size override-styles public-key community?]
(let [styles (merge {:container {:width size :height size} (let [styles (merge {:container {:width size :height size}

View File

@ -6,19 +6,9 @@
[status-im.ui.components.core :as quo] [status-im.ui.components.core :as quo]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[utils.debounce :as debounce]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn decline-chat
[chat-id]
[quo/button
{:type :secondary
:accessibility-label :decline-chat-button
:on-press #(debounce/dispatch-and-chill [:group-chats.ui/leave-chat-confirmed chat-id]
2000)}
(i18n/label :t/group-chat-decline-invitation)])
(def message-max-length 100) (def message-max-length 100)
(defn request-membership (defn request-membership

View File

@ -1,42 +0,0 @@
(ns status-im.ui.screens.chat.message.gap
(:require-macros [status-im.utils.views :as views])
(:require
[quo.core :as quo]
[re-frame.core :as re-frame]
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.styles.input.gap :as style]
[utils.datetime :as datetime]
[utils.i18n :as i18n]))
(views/defview gap
[{:keys [gap-ids chat-id gap-parameters public? community?]}]
(views/letsubs [in-progress? [:chats/fetching-gap-in-progress?
gap-ids
chat-id]
connected? [:mailserver/connected?]
use-status-nodes? [:mailserver/use-status-nodes?]
first-gap? (= gap-ids #{:first-gap})
window-height [:dimensions/window-height]]
(when (or (not first-gap?) public? community?)
[react/view {:style (when-not in-progress? style/gap-container)}
[react/touchable-highlight
{:on-press (when (and (not in-progress?) use-status-nodes? connected?)
(re-frame/dispatch [:chat.ui/fill-gaps chat-id gap-ids]))
:style {:height (if in-progress? window-height 48)}}
[react/view {:style style/label-container}
(if in-progress?
[quo/skeleton-list
{:parent-height window-height
:animated true
:content :messages}]
[react/nested-text
{:style (style/gap-text (and connected? use-status-nodes?))}
(i18n/label (if first-gap? :t/load-more-messages :t/fetch-messages))
(when first-gap?
[{:style style/date}
(let [date (datetime/timestamp->long-date
(* 1000 (:from gap-parameters)))]
(str
"\n"
(i18n/label :t/load-messages-before
{:date date})))])])]]])))

View File

@ -1,4 +1,4 @@
(ns status-im.ui.screens.chat.styles.message.message (ns status-im.ui.screens.chat.message.legacy-style
(:require (:require
[quo.foundations.colors :as quo.colors] [quo.foundations.colors :as quo.colors]
[quo.foundations.typography :as typography] [quo.foundations.typography :as typography]
@ -10,50 +10,6 @@
[] []
{:color colors/text}) {:color colors/text})
(defn system-message-body
[_]
{:margin-top 4
:margin-left 8
:margin-right 8
:align-self :center
:align-items :center})
(defn message-body
[]
(let [align :flex-start
direction :row]
{:flex-direction direction
:margin-top 4
:align-self align
:align-items align}))
(def message-timestamp
{:font-size 10})
(defn message-status-placeholder
[]
(merge message-timestamp {:opacity 0 :color "rgba(0,0,0,0)"}))
(defn message-timestamp-text
[]
(merge message-timestamp
{:color colors/gray
:text-align :center}))
(defn message-status-text
[]
{:font-size 10
:line-height 10
:border-color :red
:border-width 1
:color :red})
(defn audio-message-timestamp-text
[]
(merge message-timestamp
{:line-height 10
:color colors/gray}))
(defn message-wrapper (defn message-wrapper
[{:keys [in-popover?]}] [{:keys [in-popover?]}]
(if (not in-popover?) (if (not in-popover?)
@ -61,67 +17,6 @@
:padding-right 5} :padding-right 5}
{:margin-right 10})) {:margin-right 10}))
(defn message-author-wrapper
[]
{:flex-direction :column
:flex-shrink 1
:align-items :flex-start
:margin-left 4})
(defn pin-indicator
[]
(merge {:flex-direction :row}))
(defn pin-indicator-container
[]
{:margin-top 4
:margin-left 54
:top 4
:justify-content :center
:align-self :flex-start
:align-items :flex-start})
(defn pinned-by-text-icon-container
[]
{:flex-direction :row
:align-items :flex-start
:top 5
:left 8
:position :absolute})
(defn pin-icon-container
[]
{:flex-direction :row
:margin-top 1})
(defn pinned-by-text
[]
{:margin-left 5})
(def message-author-touchable
{:margin-left 0
:flex-direction :row})
(def delivery-text
{:color colors/gray
:margin-top 2
:font-size 12})
(def not-sent-view
{:flex-direction :row
:margin-bottom 2
:padding-top 2})
(def not-sent-text
(assoc delivery-text
:color colors/red
:text-align :right
:padding-top 4))
(def not-sent-icon
{:padding-top 3
:padding-left 3})
(defn emoji-message (defn emoji-message
[{:keys [incoming-group]}] [{:keys [incoming-group]}]
{:font-size 28 {:font-size 28
@ -129,10 +24,6 @@
:margin-right 0 ;; Margin to display outgoing message status :margin-right 0 ;; Margin to display outgoing message status
:margin-top (if incoming-group 4 0)}) :margin-top (if incoming-group 4 0)})
(def message-view-wrapper
{:align-self :flex-end
:flex-direction :row-reverse})
(defn message-view (defn message-view
[{:keys [content-type]}] [{:keys [content-type]}]
(merge (merge
@ -154,40 +45,6 @@
:font-size 14 :font-size 14
:color colors/gray}) :color colors/gray})
(defn message-author-name
[chosen?]
{:font-size (if chosen? 13 12)
:font-weight (if chosen? "500" "400")
:padding-top 6
:padding-left 12
:text-align-vertical :center})
(defn quoted-message-container
[]
{:margin-bottom 6
:margin-top 5
:padding-horizontal 15})
(def quoted-message-author-container
{:flex-direction :row
:align-items :center
:justify-content :flex-start})
(defn quoted-message-author
[chosen?]
(assoc (message-author-name chosen?)
:padding-bottom 6
:padding-top 0
:padding-left 0
:line-height 18
:font-weight "500"
:color colors/gray))
(defn quoted-message-text
[]
{:font-size 14
:color colors/gray})
(defn message-default-style (defn message-default-style
[] []
{:font-family "Inter-Regular" {:font-family "Inter-Regular"
@ -197,19 +54,11 @@
:letter-spacing -0.135}) :letter-spacing -0.135})
;; Markdown styles ;; Markdown styles
(defn default-text-style (defn default-text-style
[] []
{:max-font-size-multiplier react/max-font-size-multiplier {:max-font-size-multiplier react/max-font-size-multiplier
:style (message-default-style)}) :style (message-default-style)})
(defn outgoing-text-style
[]
(update (default-text-style)
:style
assoc
:color colors/white-persist))
(defn system-text-style (defn system-text-style
[] []
(update (default-text-style) (update (default-text-style)
@ -284,21 +133,11 @@
:line-height 18.2 :line-height 18.2
:letter-spacing (typography/tracking 13)))) :letter-spacing (typography/tracking 13))))
(def code-block-background "#2E386B")
(defn inline-code-style
[]
{:color colors/white-persist
:background-color code-block-background})
(def codeblock-style (def codeblock-style
{:padding 10 {:padding 10
:background-color code-block-background :background-color "#2E386B"
:border-radius 4}) :border-radius 4})
(def codeblock-text-style
{:color colors/white-persist})
(defn default-blockquote-style (defn default-blockquote-style
[] []
{:style {:border-left-width 2 {:style {:border-left-width 2
@ -330,24 +169,6 @@
(outgoing-blockquote-text-style) (outgoing-blockquote-text-style)
(default-blockquote-text-style)) (default-blockquote-text-style))
(defn image-message
[{:keys [width height]}]
{:overflow :hidden
:border-radius 8
:width width
:height height})
(defn image-message-border
[opts]
(merge (image-message opts)
{:opacity (:opacity opts)
:border-width 1
:top 0
:left 0
:position :absolute
:background-color :transparent
:border-color colors/black-transparent}))
(defn community-verified (defn community-verified
[] []
{:border-right-width 1 {:border-right-width 1

View File

@ -7,9 +7,7 @@
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.ui.components.colors :as quo.colors] [status-im.ui.components.colors :as quo.colors]
[status-im.ui.components.fast-image :as fast-image] [status-im.ui.components.fast-image :as fast-image]
[status-im.ui.screens.chat.message.gap :as message.gap] [status-im.ui.screens.chat.message.legacy-style :as style]
[status-im.ui.screens.chat.styles.message.message :as style]
[status-im.ui.screens.chat.utils :as chat.utils]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.messages.delete-message-for-me.events] [status-im2.contexts.chat.messages.delete-message-for-me.events]
[status-im2.contexts.chat.messages.delete-message.events] [status-im2.contexts.chat.messages.delete-message.events]
@ -131,16 +129,11 @@
[:<>] [:<>]
(:parsed-text content)))) (:parsed-text content))))
(defview message-author-name
[from opts max-length]
(letsubs [contact-with-names [:contacts/contact-by-identity from]]
(chat.utils/format-author contact-with-names opts max-length)))
(defmulti ->message :content-type) (defmulti ->message :content-type)
(defmethod ->message constants/content-type-gap (defmethod ->message constants/content-type-gap
[message] [_]
[message.gap/gap message]) [rn/view])
;; STATUS ? whats that ? ;; STATUS ? whats that ?
(defmethod ->message constants/content-type-status (defmethod ->message constants/content-type-status

View File

@ -2,18 +2,41 @@
(:require (:require
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.fast-image :as fast-image] [status-im.ui.components.fast-image :as fast-image]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]))
[status-im.ui.screens.chat.styles.photos :as style]))
(defn radius [size] (/ size 2))
(defn photo-container
[size]
{:position :relative
:border-radius (radius size)})
(defn photo-border
([size] (photo-border size :absolute))
([size position]
{:position position
:width size
:height size
:border-color colors/black-transparent
:border-width 1
:border-radius (radius size)}))
(defn photo-style
[size]
{:border-radius (radius size)
:width size
:height size
:background-color colors/white})
(def memo-photo-rend (def memo-photo-rend
(memoize (memoize
(fn [photo-path size accessibility-label _] (fn [photo-path size accessibility-label _]
[react/view {:style (style/photo-container size)} [react/view {:style (photo-container size)}
[fast-image/fast-image [fast-image/fast-image
{:source photo-path {:source photo-path
:style (style/photo size) :style (photo-style size)
:accessibility-label (or accessibility-label :chat-icon)}] :accessibility-label (or accessibility-label :chat-icon)}]
[react/view {:style (style/photo-border size)}]]))) [react/view {:style (photo-border size)}]])))
;; "(colors/dark?)" is passed to memoized function to avoid previous themes cache ;; "(colors/dark?)" is passed to memoized function to avoid previous themes cache
;; TODO: it's only used for old code, `quo/user-avatar` should be used instead for all the new one ;; TODO: it's only used for old code, `quo/user-avatar` should be used instead for all the new one

View File

@ -1,125 +0,0 @@
(ns status-im.ui.screens.chat.sheets
(:require
[re-frame.core :as re-frame]
[status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.ui.components.list.item :as list.item]
[status-im.ui.components.react :as react]
[status-im2.constants :as constants]
[utils.i18n :as i18n]))
(defn hide-sheet-and-dispatch
[event]
(re-frame/dispatch [:bottom-sheet/hide-old])
(re-frame/dispatch event))
(defn one-to-one-chat-accents
[chat-id]
(let [{:keys [primary-name] :as contact} @(re-frame/subscribe [:contacts/contact-by-identity chat-id])]
[react/view
[list.item/list-item
{:theme :accent
:icon [chat-icon/contact-icon-contacts-tab contact]
:title primary-name
:subtitle (i18n/label :t/view-profile)
:accessibility-label :view-chat-details-button
:chevron true
:on-press #(do
(hide-sheet-and-dispatch [:chat.ui/show-profile chat-id])
(re-frame/dispatch [:pin-message/load-pin-messages chat-id]))}]
[list.item/list-item
{:theme :accent
:title (i18n/label :t/mark-all-read)
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]
[list.item/list-item
{:theme :negative
:title (i18n/label :t/delete-chat)
:accessibility-label :delete-chat-button
:icon :main-icons/delete
:on-press #(re-frame/dispatch [:chat.ui/show-remove-confirmation chat-id])}]]))
(defn community-chat-accents
[]
(fn [{:keys [chat-id group-chat chat-name color emoji]}]
[react/view
[list.item/list-item
{:theme :accent
:title chat-name
:icon [chat-icon/emoji-chat-icon-view-chat-sheet
chat-id group-chat chat-name color emoji]
:subtitle (i18n/label :t/view-details)
:chevron true
:accessibility-label :view-community-channel-details
:on-press #(do
(hide-sheet-and-dispatch [:navigate-to :community-channel-details
{:chat-id chat-id}])
(re-frame/dispatch [:pin-message/load-pin-messages chat-id]))}]
[list.item/list-item
{:theme :accent
:title (i18n/label :t/mark-all-read)
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]]))
(defn group-chat-accents
[]
(fn [{:keys [chat-id group-chat chat-name color invitation-admin]}]
(let [{:keys [member?]} @(re-frame/subscribe [:group-chat/inviter-info chat-id])
removed? @(re-frame/subscribe [:group-chat/removed-from-current-chat?])]
(if invitation-admin
[list.item/list-item
{:theme :accent
:title (i18n/label :t/remove)
:accessibility-label :remove-group-chat
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:group-chats.ui/remove-chat-confirmed
chat-id])}]
[react/view
[list.item/list-item
{:theme :accent
:title chat-name
:subtitle (i18n/label :t/group-info)
:icon [chat-icon/chat-icon-view-chat-sheet
chat-id group-chat chat-name color]
:chevron true
:on-press #(do
(hide-sheet-and-dispatch [:show-group-chat-profile chat-id])
(re-frame/dispatch [:pin-message/load-pin-messages chat-id]))}]
[list.item/list-item
{:theme :accent
:title (i18n/label :t/mark-all-read)
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]
(when member?
[list.item/list-item
{:theme :negative
:title (i18n/label :t/leave-chat)
:accessibility-label :leave-chat-button
:icon :main-icons/arrow-left
:on-press #(re-frame/dispatch [:group-chats.ui/leave-chat-pressed chat-id])}])
(when removed?
[list.item/list-item
{:theme :accent
:title (i18n/label :t/remove)
:accessibility-label :remove-group-chat
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:group-chats.ui/remove-chat-confirmed
chat-id])}])]))))
(defn actions
[{:keys [chat-type chat-id]
:as current-chat}]
(cond
(= chat-type constants/community-chat-type)
[community-chat-accents current-chat]
(= chat-type constants/private-group-chat-type)
[group-chat-accents current-chat]
:else [one-to-one-chat-accents chat-id]))

View File

@ -1,15 +0,0 @@
(ns status-im.ui.screens.chat.stickers.styles)
(def stickers-panel
{:flex 1 :margin 5 :flex-direction :row :justify-content :space-between :flex-wrap :wrap})
(defn pack-icon
[background-color icon-size icon-horizontal-margin]
{:background-color background-color
:margin-vertical 5
:margin-horizontal icon-horizontal-margin
:height icon-size
:width icon-size
:border-radius (/ icon-size 2)
:align-items :center
:justify-content :center})

View File

@ -1,169 +0,0 @@
(ns status-im.ui.screens.chat.stickers.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.core :as quo]
[status-im.ui.components.fast-image :as fast-image]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.stickers.styles :as styles]
[utils.debounce :as debounce]
[utils.i18n :as i18n]))
(def icon-size 28)
(def icon-horizontal-margin 8)
(def indicator-width 16)
(def dx (- (+ icon-horizontal-margin (/ icon-size 2)) (/ indicator-width 2)))
(def icon-container (+ (* icon-horizontal-margin 2) icon-size))
(def scroll-x (reagent/atom 0))
(defn- no-stickers-yet-panel
[]
[react/view {:style {:flex 1 :align-items :center :justify-content :center}}
[icons/icon :stickers-icons/stickers-big
{:color colors/gray
:width 64
:height 64}]
[react/text {:style {:margin-vertical 8 :font-size 17}} (i18n/label :t/you-dont-have-stickers)]
[quo/button
{:type :secondary
:on-press #(re-frame/dispatch [:navigate-to :stickers])}
(i18n/label :t/get-stickers)]])
(defn- stickers-panel
[stickers window-width]
[react/view {:width window-width :flex 1}
[react/scroll-view
[react/view {:style styles/stickers-panel}
(for [{:keys [url] :as sticker} stickers]
^{:key (str url)}
[react/touchable-highlight
{:style {:height 75 :width 75 :margin 5}
:on-press #(debounce/dispatch-and-chill [:chat/send-sticker sticker] 1000)}
[fast-image/fast-image
{:style {:width "100%" :height "100%"}
:accessibility-label :sticker-icon
:source {:uri (str url "&download=true")}}]])]]])
(defview recent-stickers-panel
[window-width]
(letsubs [stickers [:stickers/recent-stickers]]
(if (seq stickers)
[stickers-panel stickers window-width]
[react/view
{:style {:flex 1
:align-items :center
:justify-content :center
:width window-width}}
[icons/icon :stickers-icons/sticker-history
{:width 64
:height 64
:color colors/gray}]
[react/text
{:style {:margin-top 12
:font-size 17}}
(i18n/label :t/recently-used-stickers)]])))
(defn update-scroll-position
[^js ref installed-packs selected-pack window-width animated?]
(when ref
;; bug on Android https://github.com/facebook/react-native/issues/24531
(js/setTimeout
(fn []
(let [x (if (= selected-pack :recent)
0
(* (inc (some #(when (= selected-pack (:id (second %))) (first %))
(map-indexed vector installed-packs)))
window-width))]
(.scrollTo ref #js {:x x :animated animated?})))
1)))
(defn on-scroll
[^js e installed-packs window-width]
(let [num (/ (.-nativeEvent.contentOffset.x e) window-width)
pack-id (if (zero? num)
:recent
(get-in (vec installed-packs) [(dec num) :id]))]
(when pack-id
(re-frame/dispatch [:stickers/select-pack pack-id]))))
(defview stickers-paging-panel
[installed-packs selected-pack]
(letsubs [ref (atom nil)
width [:dimensions/window-width]]
{:UNSAFE_componentWillUpdate
(fn [_ [_ installed-packs selected-pack]]
(update-scroll-position @ref installed-packs selected-pack width true))
:component-did-mount #(update-scroll-position @ref installed-packs selected-pack width false)}
[react/scroll-view
{:style {:flex 1}
:horizontal true
:paging-enabled true
:ref #(reset! ref %)
:shows-horizontal-scroll-indicator false
:on-momentum-scroll-end #(on-scroll % installed-packs width)
:scroll-event-throttle 8
:scroll-to-overflow-enabled true
:on-scroll #(reset! scroll-x (.-nativeEvent.contentOffset.x ^js %))}
^{:key "recent"}
[recent-stickers-panel width]
(for [{:keys [stickers id]} installed-packs]
^{:key (str "sticker" id)}
[stickers-panel (map #(assoc % :pack id) stickers) width])]))
(defn pack-icon
[{:keys [id on-press background-color]
:or {on-press #(re-frame/dispatch [:stickers/select-pack id])}}
icon]
[react/touchable-highlight {:on-press on-press}
[react/view {:style {:align-items :center}}
[react/view {:style (styles/pack-icon background-color icon-size icon-horizontal-margin)}
icon]]])
(defview scroll-indicator
[]
(letsubs [window-width [:dimensions/window-width]]
[react/view
{:style {:height 2
:width indicator-width
:border-radius 1
:margin-left (+ dx (* icon-container (/ @scroll-x window-width)))
:background-color colors/blue}}]))
(defview stickers-view
[]
(letsubs [selected-pack [:stickers/selected-pack]
installed-packs [:stickers/installed-packs]]
[react/view
{:style {:background-color colors/white
:flex 1}}
(cond
(= selected-pack :recent) [stickers-paging-panel installed-packs selected-pack]
(not (seq installed-packs)) [no-stickers-yet-panel]
:else [stickers-paging-panel installed-packs selected-pack])
[react/view {:style {:flex-direction :row :padding-horizontal 4}}
[pack-icon
{:on-press #(re-frame/dispatch [:navigate-to :stickers])
:selected? false
:background-color colors/blue}
[icons/icon :main-icons/add {:width 20 :height 20 :color colors/white-persist}]]
[react/view {:width 2}]
[react/scroll-view {:horizontal true :style {:padding-left 2}}
[react/view
[react/view {:style {:flex-direction :row}}
[pack-icon {:id :recent :background-color colors/white}
[icons/icon :stickers-icons/recent
{:color colors/gray
:width 44
:height 44}]]
(for [{:keys [id thumbnail]} installed-packs]
^{:key (str "pack-icon" id)}
[pack-icon
{:id id
:background-color colors/white}
[fast-image/fast-image
{:style {:width icon-size :height icon-size :border-radius (/ icon-size 2)}
:source {:uri (str thumbnail "&download=true")}}]])]
[scroll-indicator]]]]]))

View File

@ -1,35 +0,0 @@
(ns status-im.ui.screens.chat.styles.input.gap
(:require
[status-im.ui.components.colors :as colors]))
(defn gap-container
[]
{:align-self :stretch
:margin-top 24
:margin-bottom 24
:height 48
:align-items :center
:justify-content :center
:border-color colors/gray-lighter
:border-top-width 1
:border-bottom-width 1})
(def label-container
{:flex 1
:align-items :center
:justify-content :center
:text-align :center})
(defn gap-text
[connected?]
{:text-align :center
:color (if connected?
colors/blue
colors/gray)})
(def touchable
{:height 48})
(def date
{:typography :caption
:color colors/gray})

View File

@ -1,59 +0,0 @@
(ns status-im.ui.screens.chat.styles.main
(:require
[status-im.ui.components.colors :as colors]))
(def toolbar-container
{:flex 1
:align-items :center
:flex-direction :row})
(def chat-name-view
{:flex 1
:justify-content :center})
(def chat-name-text
{:typography :main-medium
:font-size 15
:line-height 22})
(def toolbar-subtitle
{:typography :caption
:line-height 16
:color colors/text-gray})
;; this map looks a bit strange
;; but this way of setting elevation seems to be the only way to set z-index (in RN 0.30)
(defn add-contact
[]
{:flex-direction :row
:align-items :center
:justify-content :center
:padding-vertical 6
:border-bottom-width 1
:border-color colors/gray-lighter})
(def add-contact-text
{:margin-left 4
:color colors/blue})
(def empty-chat-container
{:flex 1
:justify-content :center
:align-items :center
:padding-vertical 50
:margin-right 6})
(def loading-text
{:color colors/gray
:font-size 15
:line-height 22
:letter-spacing -0.2
:margin-right 4
:text-align :center})
(def contact-request
{:width "100%"
:justify-content :center
:align-items :center
:border-top-width 1
:border-color colors/gray-transparent-10})

View File

@ -1,9 +0,0 @@
(ns status-im.ui.screens.chat.styles.message.sheets
(:require
[status-im.ui.components.colors :as colors]))
(def sheet-text
{:color colors/gray
:padding 24
:line-height 22
:font-size 15})

View File

@ -1,29 +0,0 @@
(ns status-im.ui.screens.chat.styles.photos
(:require
[status-im.ui.components.colors :as colors]))
(def default-size 36)
(defn radius [size] (/ size 2))
(defn photo-container
[size]
{:position :relative
:border-radius (radius size)})
(defn photo-border
([size] (photo-border size :absolute))
([size position]
{:position position
:width size
:height size
:border-color colors/black-transparent
:border-width 1
:border-radius (radius size)}))
(defn photo
[size]
{:border-radius (radius size)
:width size
:height size
:background-color colors/white})

View File

@ -28,32 +28,3 @@
:line-height (if profile? 22 18) :line-height (if profile? 22 18)
:font-weight "400"}} :font-weight "400"}}
primary-name]))) primary-name])))
(defn format-author
([contact] (format-author contact nil nil))
([contact {:keys [modal profile? you?]} max-length]
(let [{:keys [primary-name secondary-name]} contact]
(if secondary-name
[react/nested-text
{:number-of-lines 2
:style {:color (if modal colors/white-persist colors/black)
:font-size (if profile? 15 13)
:line-height (if profile? 22 18)
:letter-spacing -0.2
:font-weight "600"}}
(subs primary-name 0 81)
(when you?
[{:style {:color colors/black-light :font-weight "500" :font-size 13}}
(str " " (i18n/label :t/You))])
[{:style {:color colors/black-light :font-weight "500"}}
(str " " (subs secondary-name 0 81))]]
[react/text
{:style {:color (if modal colors/white-persist colors/black)
:font-size (if profile? 15 13)
:line-height (if profile? 22 18)
:font-weight "600"
:letter-spacing -0.2}
:number-of-lines 1}
(if (and max-length (> (count primary-name) max-length))
(str (subs primary-name 0 max-length) "...")
primary-name)]))))

View File

@ -11,7 +11,6 @@
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im.ui.components.topbar :as topbar] [status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.chat.photos :as photos] [status-im.ui.screens.chat.photos :as photos]
[status-im.ui.screens.chat.sheets :as chat.sheets]
[status-im.ui.screens.chat.utils :as chat.utils] [status-im.ui.screens.chat.utils :as chat.utils]
[status-im.ui.screens.profile.components.styles :as profile.components.styles] [status-im.ui.screens.profile.components.styles :as profile.components.styles]
[status-im2.constants :as constants] [status-im2.constants :as constants]
@ -20,6 +19,11 @@
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn hide-sheet-and-dispatch
[event]
(re-frame/dispatch [:bottom-sheet/hide-old])
(re-frame/dispatch event))
(defn member-sheet (defn member-sheet
[chat-id member us-admin?] [chat-id member us-admin?]
[react/view [react/view
@ -30,7 +34,7 @@
:subtitle (i18n/label :t/view-profile) :subtitle (i18n/label :t/view-profile)
:accessibility-label :view-chat-details-button :accessibility-label :view-chat-details-button
:chevron true :chevron true
:on-press #(chat.sheets/hide-sheet-and-dispatch :on-press #(hide-sheet-and-dispatch
[:chat.ui/show-profile [:chat.ui/show-profile
(:public-key member)])}] (:public-key member)])}]
(when (and us-admin? (not (:admin? member))) (when (and us-admin? (not (:admin? member)))
@ -39,7 +43,7 @@
:title (i18n/label :t/make-admin) :title (i18n/label :t/make-admin)
:accessibility-label :make-admin :accessibility-label :make-admin
:icon :main-icons/make-admin :icon :main-icons/make-admin
:on-press #(chat.sheets/hide-sheet-and-dispatch [:group-chats.ui/make-admin-pressed :on-press #(hide-sheet-and-dispatch [:group-chats.ui/make-admin-pressed
chat-id (:public-key member)])}]) chat-id (:public-key member)])}])
(when-not (:admin? member) (when-not (:admin? member)
[list.item/list-item [list.item/list-item
@ -47,7 +51,7 @@
:title (i18n/label :t/remove-from-chat) :title (i18n/label :t/remove-from-chat)
:accessibility-label :remove-from-chat :accessibility-label :remove-from-chat
:icon :main-icons/remove-contact :icon :main-icons/remove-contact
:on-press #(chat.sheets/hide-sheet-and-dispatch :on-press #(hide-sheet-and-dispatch
[:group-chats.ui/remove-member-pressed chat-id [:group-chats.ui/remove-member-pressed chat-id
(:public-key member)])}])]) (:public-key member)])}])])
@ -102,7 +106,7 @@
:on-press #(re-frame/dispatch [:open-modal :add-participants-toggle-list])}]) :on-press #(re-frame/dispatch [:open-modal :add-participants-toggle-list])}])
[chat-group-members-view chat-id admin? current-pk]]) [chat-group-members-view chat-id admin? current-pk]])
(defn hide-sheet-and-dispatch (defn hide-sheet-and-dispatch-old
[event] [event]
(re-frame/dispatch [:bottom-sheet/hide-old]) (re-frame/dispatch [:bottom-sheet/hide-old])
(debounce/dispatch-and-chill event 2000)) (debounce/dispatch-and-chill event 2000))
@ -125,14 +129,15 @@
:subtitle (when-not allow-adding-members? (i18n/label :t/members-limit-reached)) :subtitle (when-not allow-adding-members? (i18n/label :t/members-limit-reached))
:accessibility-label :accept-invitation-button :accessibility-label :accept-invitation-button
:icon :main-icons/checkmark-circle :icon :main-icons/checkmark-circle
:on-press #(hide-sheet-and-dispatch :on-press #(hide-sheet-and-dispatch-old
[:group-chats.ui/add-members-from-invitation id (:public-key contact)])}] [:group-chats.ui/add-members-from-invitation id (:public-key contact)])}]
[list.item/list-item [list.item/list-item
{:theme :negative {:theme :negative
:title (i18n/label :t/decline) :title (i18n/label :t/decline)
:accessibility-label :decline-invitation-button :accessibility-label :decline-invitation-button
:icon :main-icons/cancel :icon :main-icons/cancel
:on-press #(hide-sheet-and-dispatch [:send-group-chat-membership-rejection id])}]])) :on-press #(hide-sheet-and-dispatch-old [:send-group-chat-membership-rejection
id])}]]))
(defn contacts-list-item (defn contacts-list-item
[{:keys [from] :as invitation}] [{:keys [from] :as invitation}]

View File

@ -67,7 +67,6 @@
[status-im.ui.screens.wallet.buy-crypto.views :as wallet.buy-crypto] [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.collectibles.views :as wallet.collectibles]
[status-im.ui.screens.wallet.custom-tokens.views :as custom-tokens] [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.recipient.views :as recipient]
[status-im.ui.screens.wallet.send.views :as wallet.send] [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.settings.views :as wallet-settings]
@ -647,12 +646,6 @@
:insets {:bottom? true} :insets {:bottom? true}
:component keycard.pairing/change-pairing-code} :component keycard.pairing/change-pairing-code}
{:name :show-all-connections
:options {:topBar {:title {:text (i18n/label :t/all-connections)}}
:insets {:bottom? true
:top? true}}
:component manage-all-connections/views}
;; BUG REPORT ;; BUG REPORT
{:name :bug-report {:name :bug-report
:options {:insets {:top? true}} :options {:insets {:top? true}}

View File

@ -28,13 +28,6 @@
:accessibility-label :wallet-manage-assets :accessibility-label :wallet-manage-assets
:on-press #(hide-sheet-and-dispatch :on-press #(hide-sheet-and-dispatch
[:navigate-to :wallet-settings-assets])}] [:navigate-to :wallet-settings-assets])}]
[list.item/list-item
{:theme :accent
:title (i18n/label :t/wallet-manage-app-connections)
:icon :main-icons/manage-connections
:accessibility-label :wallet-manage-app-connections
:on-press #(hide-sheet-and-dispatch
[:navigate-to :show-all-connections])}]
[list.item/list-item [list.item/list-item
{:theme :accent {:theme :accent
:title (i18n/label :t/scan-tokens) :title (i18n/label :t/scan-tokens)

View File

@ -1,46 +0,0 @@
(ns status-im.ui.screens.wallet.manage-connections.styles
(:require
[status-im.ui.components.colors :as colors]))
(def dapp-icon
{:width 30
:height 30
:resize-mode :cover
:margin 10
:border-radius 15
:border-width 2
:padding 10})
(def app-row
{:flex-direction :row
:margin-vertical 8
:align-items :center})
(def app-column
{:flex-direction :column
:max-width 160
:justify-content :center})
(def dapp-name
{:font-size 15})
(def dapp-url
{:font-size 15
:opacity 0.5})
(def selected-account
{:font-size 13
:color colors/white})
(defn selected-account-container
[account-background-color]
{:background-color account-background-color
:padding-horizontal 10
:justify-content :center
:flex-direction :row
:align-items :center
:border-radius 40
:height 26})
(def delete-icon-container
{:margin-horizontal 10})

View File

@ -1,20 +0,0 @@
(ns status-im.ui.screens.wallet.manage-connections.views
(:require
[re-frame.core :as re-frame]
[react-native.core :as rn]
[status-im.ui.screens.wallet.manage-connections.styles :as styles]
[status-im2.common.not-implemented :as not-implemented]))
(defn print-session-info
[{:keys [peer]}]
^{:key peer}
[rn/view
[:<>
[not-implemented/not-implemented
[rn/view {:style styles/app-row}]]]])
(defn views
[]
(let [sessions @(re-frame/subscribe [:wallet-connect/sessions])]
[rn/view {:margin-top 10}
(doall (map print-session-info sessions))]))

View File

@ -1,155 +0,0 @@
(ns status-im.ui.screens.wallet-connect.session-proposal.styles
(:require
[status-im.ui.components.colors :as colors]))
(defn toolbar-container
[background-color]
{:height 36
:border-radius 18
:background-color background-color
:align-items :center
:flex-direction :row
:padding-left 13
:padding-right 6})
(def toolbar-text
{:flex-grow 1
:margin-right 3})
(defn dapp-logo
[]
{:width 120
:height 120
:resize-mode :cover
:margin-top 31
:border-radius 16
:border-width 2
:border-color (:interactive-02 @colors/theme)
:padding 5})
(def sheet-body-container
{:flex 1
:align-items :center})
(defn acc-sheet
[]
{:background-color (:ui-background @colors/theme)
:border-top-right-radius 16
:border-top-left-radius 16
:padding-bottom 1})
(defn proposal-sheet-container
[]
{:background-color (:ui-background @colors/theme)
:width "100%"
:align-items :center
:padding-top 0
:padding-bottom 50
:border-top-right-radius 16
:border-top-left-radius 16})
(defn proposal-sheet-header
[]
{:flex-direction :row
:align-items :center
:justify-content :center
:height 56
:width "100%"
:border-color colors/gray-lighter
:border-bottom-width 1})
(def proposal-title-container
{:align-items :center
:margin-top 21})
(def message-title
{:margin-top 10
:margin-bottom 14
:margin-horizontal 72.5
:text-align :center})
(defn proposal-buttons-container
[]
{:width "100%"
:height 76
:border-color colors/gray-lighter
:border-top-width 1
:flex 1
:flex-direction :row
:justify-content :space-between
:align-items :center
:padding-horizontal 16})
(defn success-button-container
[]
{:width "100%"
:height 76
:border-color colors/gray-lighter
:border-top-width 1
:flex-direction :row
:justify-content :flex-end
:align-items :center
:padding-horizontal 16})
(defn account-container
[color account-selected?]
{:height 34
:background-color color
:border-radius 17
:padding-horizontal 10
:justify-content :center
:margin-right 4
:opacity (if account-selected? 1 0.5)})
(def account-selector-container
{:height 80
:width "100%"
:justify-content :center
:padding-horizontal 16})
(def account-selector-wrapper
{:margin-top 40
:width "100%"})
(def account-selector-list
{:height 40
:width "100%"
:margin-top 10})
(def single-account-container
{:width "100%"
:align-items :center
:padding-top 8})
(defn blur-view
[]
{:position :absolute
:top 60
:left 0
:right 0
:bottom 0
:background-color (:blurred-bg @colors/theme)})
(def shadow
{:width "100%"
:height 50
:opacity 0.3})
(defn management-sheet-header
[]
{:width "100%"
:flex-direction :row
:padding 16
:align-items :center
:border-bottom-width 1
:border-bottom-color colors/gray-lighter})
(def management-icon
{:width 40
:height 40
:border-radius 20
:margin-right 16})
(def app-info-container
{:flex-direction :column
:flex 1})

View File

@ -1,246 +0,0 @@
(ns status-im.ui.screens.wallet-connect.session-proposal.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require
[clojure.string :as string]
[re-frame.core :as re-frame]
[react-native.platform :as platform]
[reagent.core :as reagent]
[status-im.ui.components.bottom-panel.views :as bottom-panel]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.core :as quo]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.list.views :as list]
[status-im.ui.components.react :as react]
[status-im.ui.screens.wallet-connect.session-proposal.styles :as styles]
[status-im.utils.utils :as status.utils]
[utils.i18n :as i18n]
[utils.security.core]))
(def chevron-icon-container-width 24)
(def chevron-icon-container-height 24)
(defn toolbar-selection
[{:keys [text background-color on-press]}]
[react/touchable-opacity {:on-press on-press}
[react/view (styles/toolbar-container background-color)
[quo/text
{:color :inverse
:weight :medium
:style styles/toolbar-text}
text]
[icons/icon
:main-icons/chevron-down
{:color (:text-05 @colors/theme)
:width chevron-icon-container-width
:height chevron-icon-container-height}]]])
(def show-account-selector? (reagent/atom false))
(defn render-account
[{:keys [address name color] :as account} _ _ {:keys [selected-account on-select]}]
(let [account-selected? (= (:address @selected-account) address)]
[react/touchable-without-feedback
{:on-press #(do
(reset! selected-account (merge {} account))
(when on-select (on-select)))}
[react/view (styles/account-container color account-selected?)
[quo/text
{:color :inverse
:weight (if account-selected? :medium :regular)}
name]]]))
(defn account-selector
[accounts selected-account-atom on-select]
[react/view styles/account-selector-container
[quo/text {:size :small} (i18n/label :t/select-account)]
[list/flat-list
{:data accounts
:key-fn :address
:render-fn render-account
:render-data {:selected-account selected-account-atom
:on-select on-select}
:horizontal true
:shows-horizontal-scroll-indicator false
:extra-data @selected-account-atom
:style styles/account-selector-list}]])
(defn account-picker
[accounts selected-account-atom {:keys [on-press on-select]}]
(if (> (count accounts) 1)
[react/view {:style styles/account-selector-wrapper}
[account-selector accounts selected-account-atom on-select]]
[react/touchable-opacity {:style styles/single-account-container}
[toolbar-selection
{:text (:name @selected-account-atom)
:background-color (:color @selected-account-atom)
:on-press on-press}]]))
(defview success-sheet-view
[{:keys [topic]}]
(letsubs [visible-accounts [:visible-accounts-without-watch-only]
dapps-account [:dapps-account]
sessions [:wallet-connect/sessions]
managed-session [:wallet-connect/session-managed]]
(let [{:keys [peer state] :as session} (first (filter #(= (:topic %) topic) sessions))
{:keys [metadata]} peer
{:keys [accounts]} state
{:keys [name icons]} metadata
filtered-icons (status.utils/exclude-svg-resources icons)
icon-uri (when (and filtered-icons (pos? (count filtered-icons)))
(first filtered-icons))
address (last (string/split (first accounts) #":"))
account (first (filter #(= (:address %) address) visible-accounts))
selected-account-atom (reagent/atom account)]
[react/view (styles/proposal-sheet-container)
[react/view (styles/proposal-sheet-header)
[quo/text
{:weight :bold
:size :large}
(i18n/label :t/successful-connection)]]
[react/image
{:style (styles/dapp-logo)
:source {:uri icon-uri}}]
[react/view styles/sheet-body-container
[react/view styles/proposal-title-container
[quo/text
{:weight :bold
:size :large}
name]
[quo/text
{:weight :regular
:size :large}
(i18n/label :t/connected)]]]
[account-picker
(vector dapps-account)
selected-account-atom
{:on-press (fn []
(re-frame/dispatch [:wallet-connect/manage-app session])
(reset! show-account-selector? true))}]
[quo/text
{:weight :regular
:color :secondary
:style styles/message-title}
(i18n/label :t/manage-connections)]
[react/view (styles/success-button-container)
[quo/button
{:theme :accent
:on-press #(do
(reset! show-account-selector? false)
(re-frame/dispatch [:hide-wallet-connect-success-sheet]))}
(i18n/label :t/close)]]
(when managed-session
(if platform/ios?
[react/blur-view
{:style (styles/blur-view)
:blurAmount 2
:blurType (if (colors/dark?) :dark :light)}]
[react/view (styles/blur-view)]))])))
(defview app-management-sheet-view
[{:keys [topic]}]
(letsubs [sessions [:wallet-connect/sessions]
visible-accounts [:visible-accounts-without-watch-only]]
(let [{:keys [peer state]} (first (filter #(= (:topic %) topic) sessions))
{:keys [metadata]} peer
{:keys [accounts]} state
{:keys [name icons url]} metadata
filtered-icons (status-im.utils.utils/exclude-svg-resources icons)
icon-uri (when (and filtered-icons (pos? (count filtered-icons)))
(first filtered-icons))
address (last (string/split (first accounts) #":"))
account (first (filter #(= (:address %) address) visible-accounts))
selected-account-atom (reagent/atom account)]
[react/view {:style (merge (styles/acc-sheet) {:background-color "rgba(0,0,0,0)"})}
[react/linear-gradient
{:colors ["rgba(0,0,0,0)" "rgba(0,0,0,0.3)"]
:start {:x 0 :y 0}
:end {:x 0 :y 1}
:style styles/shadow}]
[react/view (styles/proposal-sheet-container)
[react/view (styles/management-sheet-header)
[react/image
{:style styles/management-icon
:source {:uri icon-uri}}]
[react/view styles/app-info-container
[quo/text {:weight :medium} name]
[quo/text
{:color :secondary
:number-of-lines 1
:elipsize-mode :tail} url]]
[quo/button
{:type :secondary
:theme :secondary
:on-press #(re-frame/dispatch [:wallet-connect/disconnect topic])}
(i18n/label :t/disconnect)]]
[account-selector
visible-accounts
selected-account-atom
#(re-frame/dispatch
[:wallet-connect/change-session-account topic @selected-account-atom])]]])))
(defview session-proposal-sheet
[{:keys [name icons]}]
(letsubs [visible-accounts [:visible-accounts-without-watch-only]
dapps-account [:dapps-account]]
(let [filtered-icons (status-im.utils.utils/exclude-svg-resources icons)
icon-uri (when (and filtered-icons (> (count filtered-icons) 0))
(first filtered-icons))
selected-account-atom (reagent/atom dapps-account)]
[react/view (styles/proposal-sheet-container)
[react/view (styles/proposal-sheet-header)
[quo/text
{:weight :bold
:size :large}
(i18n/label :t/connection-request)]]
[react/image
{:style (styles/dapp-logo)
:source {:uri icon-uri}}]
[react/view styles/sheet-body-container
[react/view styles/proposal-title-container
[quo/text
{:weight :bold
:size :large}
(str name " ")]
[quo/text
{:weight :regular
:size :large}
(i18n/label :t/wallet-connect-proposal-title)]]]
[account-picker visible-accounts selected-account-atom]
[react/view
(merge (styles/proposal-buttons-container)
(when (= (count visible-accounts) 1) {:margin-top 12}))
[quo/button
{:type :secondary
:on-press #(re-frame/dispatch [:wallet-connect/reject-proposal])}
(i18n/label :t/reject)]
[quo/button
{:theme :accent
:on-press #(re-frame/dispatch [:wallet-connect/approve-proposal @selected-account-atom])}
(i18n/label :t/connect)]]])))
(defview wallet-connect-proposal-sheet
[]
(letsubs [proposal-metadata [:wallet-connect/proposal-metadata]]
[bottom-panel/animated-bottom-panel
proposal-metadata
session-proposal-sheet
#(re-frame/dispatch [:hide-wallet-connect-sheet])]))
(defview wallet-connect-success-sheet-view
[]
(letsubs [session [:wallet-connect/session-connected]]
[bottom-panel/animated-bottom-panel
session
success-sheet-view
#(re-frame/dispatch [:hide-wallet-connect-success-sheet])]))
(defview wallet-connect-app-management-sheet-view
[]
(letsubs [session [:wallet-connect/session-managed]]
[bottom-panel/animated-bottom-panel
session
app-management-sheet-view
#(re-frame/dispatch [:hide-wallet-connect-app-management-sheet])
#(re-frame/dispatch [:hide-wallet-connect-app-management-sheet])
false]))

View File

@ -57,7 +57,7 @@
"message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js "message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js
:keywordize-keys :keywordize-keys
true)] true)]
(models.message/update-db-message-status cofx (models.message/update-message-status cofx
chatID chatID
messageID messageID
:delivered)) :delivered))

View File

@ -139,24 +139,12 @@
[id network]) [id network])
default-networks))) default-networks)))
(def default-wallet-connect-metadata
{:name "Status Wallet"
:description
"Status is a secure messaging app, crypto wallet, and Web3 browser built with state of the art technology."
:url "#"
:icons ["https://statusnetwork.com/img/press-kit-status-logo.svg"]})
(def default-network-id (def default-network-id
(get-in default-networks-by-id [default-network :config :NetworkId])) (get-in default-networks-by-id [default-network :config :NetworkId]))
(def default-network-rpc-url (def default-network-rpc-url
(get-in default-networks-by-id [default-network :config :UpstreamConfig :URL])) (get-in default-networks-by-id [default-network :config :UpstreamConfig :URL]))
(def wallet-connect-project-id "87815d72a81d739d2a7ce15c2cfdefb3")
(def delete-message-undo-time-limit-ms 4000)
(def delete-message-for-me-undo-time-limit-ms 4000)
(def waku-nodes-config (def waku-nodes-config
{:status.prod {:status.prod
["enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"] ["enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"]

View File

@ -11,6 +11,7 @@
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.composer.link-preview.events :as link-preview] [status-im2.contexts.chat.composer.link-preview.events :as link-preview]
status-im2.contexts.chat.effects status-im2.contexts.chat.effects
status-im2.contexts.chat.lightbox.events
[status-im2.contexts.chat.messages.delete-message-for-me.events :as delete-for-me] [status-im2.contexts.chat.messages.delete-message-for-me.events :as delete-for-me]
[status-im2.contexts.chat.messages.delete-message.events :as delete-message] [status-im2.contexts.chat.messages.delete-message.events :as delete-message]
[status-im2.contexts.chat.messages.list.state :as chat.state] [status-im2.contexts.chat.messages.list.state :as chat.state]

View File

@ -0,0 +1,29 @@
(ns status-im2.contexts.chat.lightbox.effects
(:require [react-native.blob :as blob]
[react-native.cameraroll :as cameraroll]
[react-native.fs :as fs]
[react-native.platform :as platform]
[react-native.share :as share]
[utils.re-frame :as rf]))
(def config
{:trusty platform/ios?
:path (str (fs/cache-dir) "/StatusIm_Image.jpeg")})
(rf/reg-fx :effects.chat/share-image
(fn [uri]
(blob/fetch uri
config
(fn [downloaded-url]
(share/open {:url (str (when platform/android? "file://") downloaded-url)
:isNewTask true}
#(fs/unlink downloaded-url)
#(fs/unlink downloaded-url))))))
(rf/reg-fx :effects.chat/save-image-to-gallery
(fn [[uri on-success]]
(blob/fetch uri
config
(fn [downloaded-url]
(cameraroll/save-image downloaded-url)
(on-success)))))

View File

@ -0,0 +1,23 @@
(ns status-im2.contexts.chat.lightbox.events
(:require status-im2.contexts.chat.lightbox.effects
[utils.re-frame :as rf]))
(rf/reg-event-fx :chat.ui/clear-sending-images
(fn [{:keys [db]}]
{:db (update-in db [:chat/inputs (:current-chat-id db) :metadata] assoc :sending-image {})}))
(rf/reg-event-fx :chat.ui/image-unselected
(fn [{:keys [db]} [original]]
(let [current-chat-id (:current-chat-id db)]
{:db (update-in db
[:chat/inputs current-chat-id :metadata :sending-image]
dissoc
(:uri original))})))
(rf/reg-event-fx :chat.ui/share-image
(fn [_ [uri]]
{:effects.chat/share-image uri}))
(rf/reg-event-fx :chat.ui/save-image-to-gallery
(fn [_ [uri on-success]]
{:effects.chat/save-image-to-gallery [uri on-success]}))

View File

@ -6,7 +6,6 @@
[react-native.orientation :as orientation] [react-native.orientation :as orientation]
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[status-im.chat.models.images :as images]
[status-im2.contexts.chat.lightbox.animations :as anim] [status-im2.contexts.chat.lightbox.animations :as anim]
[status-im2.contexts.chat.lightbox.constants :as c] [status-im2.contexts.chat.lightbox.constants :as c]
[status-im2.contexts.chat.lightbox.style :as style] [status-im2.contexts.chat.lightbox.style :as style]
@ -52,20 +51,21 @@
:label (i18n/label :t/save-image-library) :label (i18n/label :t/save-image-library)
:on-press (fn [] :on-press (fn []
(rf/dispatch [:hide-bottom-sheet]) (rf/dispatch [:hide-bottom-sheet])
(images/save-image-to-gallery (rf/dispatch
[:chat.ui/save-image-to-gallery
uri uri
#(rf/dispatch [:toasts/upsert #(rf/dispatch [:toasts/upsert
{:id :random-id {:id :random-id
:icon :i/correct :icon :i/correct
:icon-color colors/success-50 :icon-color colors/success-50
:container-style {:bottom (when platform/android? 20)} :container-style {:bottom (when platform/android? 20)}
:text (i18n/label :t/photo-saved)}])))}]]])) :text (i18n/label :t/photo-saved)}])]))}]]]))
(defn share-image (defn share-image
[messages index] [messages index]
(let [{:keys [content]} (nth messages index) (let [{:keys [content]} (nth messages index)
uri (url/replace-port (:image content) (rf/sub [:mediaserver/port]))] uri (url/replace-port (:image content) (rf/sub [:mediaserver/port]))]
(images/share-image uri))) (rf/dispatch [:chat.ui/share-image uri])))
(defn top-view (defn top-view
[messages insets index animations derived landscape? screen-width] [messages insets index animations derived landscape? screen-width]

View File

@ -200,6 +200,9 @@
constants/content-type-album constants/content-type-album
[album/album-message message-data context on-long-press message-container-data] [album/album-message message-data context on-long-press message-container-data]
constants/content-type-gap
[rn/view]
[not-implemented/not-implemented [not-implemented/not-implemented
[content.unknown/unknown-content message-data]]) [content.unknown/unknown-content message-data]])

View File

@ -11,7 +11,6 @@
[react-native.react-native-intersection-observer :as rnio] [react-native.react-native-intersection-observer :as rnio]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[status-im.ui.screens.chat.group :as chat.group] [status-im.ui.screens.chat.group :as chat.group]
[status-im.ui.screens.chat.message.gap :as message.gap]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.composer.constants :as composer.constants] [status-im2.contexts.chat.composer.constants :as composer.constants]
[status-im2.contexts.chat.messages.content.view :as message] [status-im2.contexts.chat.messages.content.view :as message]
@ -274,9 +273,6 @@
(= type :datemark) (= type :datemark)
[quo/divider-date value] [quo/divider-date value]
(= content-type constants/content-type-gap)
[message.gap/gap message-data]
:else :else
[message/message message-data context keyboard-shown?])])) [message/message message-data context keyboard-shown?])]))

View File

@ -111,21 +111,6 @@
(fn [] (gesture/gesture-handler-root-hoc views/sheet-comp-old)) (fn [] (gesture/gesture-handler-root-hoc views/sheet-comp-old))
(fn [] views/sheet-comp-old)) (fn [] views/sheet-comp-old))
(navigation/register-component
"wallet-connect-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/wallet-connect-comp))
(fn [] views/wallet-connect-comp))
(navigation/register-component
"wallet-connect-success-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/wallet-connect-success-comp))
(fn [] views/wallet-connect-success-comp))
(navigation/register-component
"wallet-connect-app-management-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/wallet-connect-app-management-comp))
(fn [] views/wallet-connect-app-management-comp))
(navigation/register-component (navigation/register-component
"signing-sheet" "signing-sheet"
(fn [] (gesture/gesture-handler-root-hoc views/signing-comp)) (fn [] (gesture/gesture-handler-root-hoc views/signing-comp))

View File

@ -134,31 +134,6 @@
[_] [_]
{:hide-signing-sheet nil}) {:hide-signing-sheet nil})
(rf/defn hide-select-acc-sheet
{:events [:hide-select-acc-sheet]}
[_]
{:hide-select-acc-sheet nil})
(rf/defn hide-wallet-connect-sheet
{:events [:hide-wallet-connect-sheet]}
[_]
{:hide-wallet-connect-sheet nil})
(rf/defn hide-wallet-connect-success-sheet
{:events [:hide-wallet-connect-success-sheet]}
[_]
{:hide-wallet-connect-success-sheet nil})
(rf/defn hide-wallet-connect-app-management-sheet
{:events [:hide-wallet-connect-app-management-sheet]}
[{:keys [db]}]
{:db (-> db
(assoc db
:wallet-connect/showing-app-management-sheet?
false)
(dissoc :wallet-connect/session-managed))
:hide-wallet-connect-app-management-sheet nil})
(rf/defn set-multiaccount-root (rf/defn set-multiaccount-root
{:events [:set-multiaccount-root]} {:events [:set-multiaccount-root]}
[{:keys [db]}] [{:keys [db]}]
@ -171,16 +146,12 @@
(rf/defn dismiss-all-overlays (rf/defn dismiss-all-overlays
{:events [:dismiss-all-overlays]} {:events [:dismiss-all-overlays]}
[{:keys [db]}] [_]
{:dispatch-n [[:hide-popover] {:dispatch-n [[:hide-popover]
[:hide-visibility-status-popover] [:hide-visibility-status-popover]
[:hide-bottom-sheet] [:hide-bottom-sheet]
[:bottom-sheet-hidden] [:bottom-sheet-hidden]
[:hide-wallet-connect-sheet]
[:hide-wallet-connect-success-sheet]
[:hide-wallet-connect-app-management-sheet]
[:hide-signing-sheet] [:hide-signing-sheet]
[:hide-select-acc-sheet]
[:bottom-sheet/hide-old-navigation-overlay] [:bottom-sheet/hide-old-navigation-overlay]
[:toasts/close-all-toasts]]}) [:toasts/close-all-toasts]]})

View File

@ -10,7 +10,6 @@
[status-im.ui.screens.popover.views :as popover] [status-im.ui.screens.popover.views :as popover]
[status-im.ui.screens.profile.visibility-status.views :as visibility-status-views] [status-im.ui.screens.profile.visibility-status.views :as visibility-status-views]
[status-im.ui.screens.signing.views :as signing] [status-im.ui.screens.signing.views :as signing]
[status-im.ui.screens.wallet-connect.session-proposal.views :as wallet-connect]
[status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen] [status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen]
[status-im2.common.bottom-sheet.view :as bottom-sheet] [status-im2.common.bottom-sheet.view :as bottom-sheet]
[status-im2.common.toasts.view :as toasts] [status-im2.common.toasts.view :as toasts]
@ -133,33 +132,3 @@
[signing/signing] [signing/signing]
(when js/goog.DEBUG (when js/goog.DEBUG
[reloader/reload-view])]))) [reloader/reload-view])])))
(def wallet-connect-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-proposal-sheet]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def wallet-connect-success-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-success-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-success-sheet-view]
(when js/goog.DEBUG
[reloader/reload-view])])))
(def wallet-connect-app-management-comp
(reagent/reactify-component
(fn []
^{:key (str "wallet-connect-app-management-sheet" @reloader/cnt)}
[:<>
[inactive]
[wallet-connect/wallet-connect-app-management-sheet-view]
(when js/goog.DEBUG
[reloader/reload-view])])))

View File

@ -5,7 +5,6 @@
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.messages.list.events :as models.message-list] [status-im2.contexts.chat.messages.list.events :as models.message-list]
[status-im2.contexts.chat.messages.resolver.message-resolver :as resolver] [status-im2.contexts.chat.messages.resolver.message-resolver :as resolver]
[utils.datetime :as datetime]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
(defn intersperse-datemark (defn intersperse-datemark
@ -50,54 +49,6 @@
{:value (:datemark (peek messages-with-datemarks)) {:value (:datemark (peek messages-with-datemarks))
:type :datemark})))) :type :datemark}))))
(defn last-gap
"last-gap is a special gap that is put last in the message stream"
[chat-id synced-from]
{:message-id "0x123"
:message-type constants/message-type-gap
:chat-id chat-id
:content-type constants/content-type-gap
:gap-ids #{:first-gap}
:gap-parameters {:from synced-from}})
(defn collapse-gaps
"collapse-gaps will take an array of messages and collapse any gap next to
each other in a single gap.
It will also append one last gap if the last message is a non-gap"
[messages chat-id synced-from now chat-type joined loading-messages?]
(let [messages-with-gaps (reduce
(fn [acc {:keys [gap-parameters message-id] :as message}]
(let [last-element (peek acc)]
(cond
;; If it's a message, just add
(empty? gap-parameters)
(conj acc message)
;; Both are gaps, merge them
(and
(seq (:gap-parameters last-element))
(seq gap-parameters))
(conj (pop acc) (update last-element :gap-ids conj message-id))
;; it's a gap
:else
(conj acc (assoc message :gap-ids #{message-id})))))
[]
messages)]
(if (or loading-messages? ; it's loading messages from the database
(nil? synced-from) ; it's still syncing
(= constants/timeline-chat-type chat-type) ; it's a timeline chat
(= constants/profile-chat-type chat-type) ; it's a profile chat
(and (not (nil? synced-from)) ; it's not more than a month
(<= synced-from (- (quot now 1000) constants/one-month)))
(and (= constants/private-group-chat-type chat-type) ; it's a private group chat
(or (not (pos? joined)) ; we haven't joined
(>= (quot joined 1000) synced-from))) ; the history goes before we joined
(:gap-ids (peek messages-with-gaps))) ; there's already a gap on top of the
; chat history
messages-with-gaps ; don't add an extra gap
(conj messages-with-gaps (last-gap chat-id synced-from)))))
(defn hydrate-messages (defn hydrate-messages
"Pull data from messages and add it to the sorted list" "Pull data from messages and add it to the sorted list"
([message-list messages] (hydrate-messages message-list messages {})) ([message-list messages] (hydrate-messages message-list messages {}))
@ -258,7 +209,7 @@
(re-frame/subscribe [:chats/synced-from chat-id]) (re-frame/subscribe [:chats/synced-from chat-id])
(re-frame/subscribe [:chats/chat-type chat-id]) (re-frame/subscribe [:chats/chat-type chat-id])
(re-frame/subscribe [:chats/joined chat-id])]) (re-frame/subscribe [:chats/joined chat-id])])
(fn [[message-list messages pin-messages loading-messages? synced-from chat-type joined] [_ chat-id]] (fn [[message-list messages pin-messages loading-messages?] _]
;;TODO (perf) ;;TODO (perf)
(let [message-list-seq (models.message-list/->seq message-list)] (let [message-list-seq (models.message-list/->seq message-list)]
; Don't show gaps if that's the case as we are still loading messages ; Don't show gaps if that's the case as we are still loading messages
@ -267,12 +218,6 @@
(-> message-list-seq (-> message-list-seq
(add-datemarks) (add-datemarks)
(hydrate-messages messages pin-messages) (hydrate-messages messages pin-messages)
(collapse-gaps chat-id
synced-from
(datetime/timestamp)
chat-type
joined
loading-messages?)
(albumize-messages)))))) (albumize-messages))))))
(re-frame/reg-sub (re-frame/reg-sub