Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
301b2bc6f7 | ||
|
|
d039864dca | ||
|
|
a4f1f23d3c | ||
|
|
fe20fa4e99 | ||
|
|
5c30fd847a | ||
|
|
64de325678 | ||
|
|
489557c1a3 | ||
|
|
439fdfa12c | ||
|
|
f695dbf115 | ||
|
|
7c45b1e075 | ||
|
|
64453716b0 |
@@ -95,7 +95,6 @@ react-native.fs/unlink
|
||||
react-native.fs/file-exists?
|
||||
status-im.ui.components.colors/white
|
||||
status-im.ui.components.colors/black
|
||||
status-im.transport.core-test/messages
|
||||
status-im.ui.components.core/animated-header
|
||||
status-im.ui.components.core/safe-area-provider
|
||||
status-im.ui.components.core/safe-area-consumer
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"letsubs" :binding
|
||||
"with-let" "let"
|
||||
"reg-event-fx" :arg1-pair
|
||||
"reg-fx" :arg1-pair
|
||||
"testing" :arg1-body
|
||||
"deftest-sub" :arg1-body
|
||||
"wait-for" :arg1-body
|
||||
|
||||
@@ -27,18 +27,23 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
|
||||
X509Certificate cert = null;
|
||||
HandshakeCertificates clientCertificates;
|
||||
String certPem = "";
|
||||
// Get TLS PEM certificate from status-go
|
||||
try {
|
||||
// induce half second sleep because sometimes a cert is not immediately available
|
||||
// TODO : remove sleep if App no longer crashes on Android 10 devices with
|
||||
// java.lang.RuntimeException: Could not invoke WebSocketModule.connect
|
||||
Thread.sleep(500);
|
||||
certPem = getCertificatePem();
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "Could not getImageTLSCert",e);
|
||||
}
|
||||
|
||||
// Get TLS PEM certificate from status-go
|
||||
try {
|
||||
// induce half second sleep because sometimes a cert is not immediately available
|
||||
// TODO : remove sleep if App no longer crashes on Android 10 devices with
|
||||
// java.lang.RuntimeException: Could not invoke WebSocketModule.connect
|
||||
Thread.sleep(500);
|
||||
certPem = StatusPackage.getImageTLSCert();
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "Could not getImageTLSCert",e);
|
||||
}
|
||||
// Convert PEM certificate string to X509Certificate object
|
||||
if (certPem.isEmpty()) {
|
||||
Log.e(TAG, "Certificate is empty, cannot create OkHttpClient without a valid certificate");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert PEM certificate string to X509Certificate object
|
||||
try {
|
||||
// induce half second sleep because sometimes a cert is not immediately available
|
||||
// TODO : remove sleep if App no longer crashes on Android 10 devices
|
||||
@@ -74,4 +79,17 @@ class StatusOkHttpClientFactory implements OkHttpClientFactory {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private String getCertificatePem() {
|
||||
try {
|
||||
String certPem = StatusPackage.getImageTLSCert();
|
||||
if (certPem == null || certPem.trim().isEmpty()) {
|
||||
Log.e(TAG, "Certificate PEM string is null or empty");
|
||||
return "";
|
||||
}
|
||||
return certPem;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Could not getImageTLSCert", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@
|
||||
"process": "0.11.10",
|
||||
"react-test-renderer": "18.0.0",
|
||||
"rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#refs/tags/v2.0.2-status",
|
||||
"shadow-cljs": "2.25.0"
|
||||
"shadow-cljs": "2.26.2"
|
||||
},
|
||||
"binary": {
|
||||
"module_name": "status_nodejs_addon",
|
||||
|
||||
+3
-2
@@ -12,9 +12,10 @@
|
||||
[metosin/malli "0.13.0"]
|
||||
|
||||
;; Dev dependencies
|
||||
[refactor-nrepl "2.5.0"]
|
||||
[cider/cider-nrepl "0.25.3"]
|
||||
[refactor-nrepl "3.9.1"]
|
||||
[cider/cider-nrepl "0.31.0"]
|
||||
[cider/piggieback "0.4.1"]
|
||||
[org.slf4j/slf4j-nop "2.0.9"]
|
||||
[re-frisk-remote "1.6.0"]
|
||||
|
||||
;; Use the same version specified in the Nix dependency.
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
(ns quo.components.status-link-previews.community.component-spec
|
||||
(:require
|
||||
[quo.components.status-link-previews.community.view :as view]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(def props
|
||||
{:title "Some title"
|
||||
:description "Some description"
|
||||
:link "status.im"
|
||||
:logo "data:image/png,logo-x"
|
||||
:thumbnail "data:image/png,whatever"
|
||||
:member-count 20
|
||||
:active-members-count 20})
|
||||
|
||||
(h/describe "Status link previews - Community"
|
||||
(h/test "default render"
|
||||
(h/render [view/view])
|
||||
(h/is-truthy (h/query-by-label-text :link-preview))
|
||||
(h/is-null (h/query-by-label-text :button-enable-preview)))
|
||||
|
||||
(h/test "renders with most common props"
|
||||
(h/render [view/view props])
|
||||
(h/is-truthy (h/query-by-text (:title props)))
|
||||
(h/is-truthy (h/query-by-text (:description props)))
|
||||
(h/is-truthy (h/query-by-text (:link props)))
|
||||
(h/is-truthy (h/query-by-label-text :logo))
|
||||
(h/is-truthy (h/query-by-label-text :thumbnail)))
|
||||
|
||||
(h/test "does not render thumbnail if prop is not present"
|
||||
(h/render [view/view (dissoc props :thumbnail)])
|
||||
(h/is-null (h/query-by-label-text :thumbnail)))
|
||||
|
||||
(h/test "does not render logo if prop is not present"
|
||||
(h/render [view/view (dissoc props :logo)])
|
||||
(h/is-null (h/query-by-label-text :logo))))
|
||||
@@ -1,51 +0,0 @@
|
||||
(ns quo.components.status-link-previews.community.style
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(defn loading-circle
|
||||
[theme]
|
||||
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||
:margin-right 4
|
||||
:width 16
|
||||
:height 16
|
||||
:border-radius 16})
|
||||
|
||||
(defn loading-stat
|
||||
[theme]
|
||||
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||
:margin-right 4
|
||||
:width 32
|
||||
:height 8
|
||||
:border-radius 16})
|
||||
|
||||
(def loading-stat-container {:flex-direction :row :align-items :center :margin-right 12})
|
||||
|
||||
(defn loading-first-line-bar
|
||||
[theme]
|
||||
{:style {:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||
:width 145
|
||||
:height 16
|
||||
:border-radius 6}})
|
||||
|
||||
(defn loading-second-line-bar
|
||||
[theme]
|
||||
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||
:width 112
|
||||
:height 8
|
||||
:border-radius 6
|
||||
:margin-bottom 17})
|
||||
|
||||
(defn loading-thumbnail-box
|
||||
[theme]
|
||||
{:background-color (colors/theme-colors colors/neutral-5 colors/neutral-80 theme)
|
||||
:margin-right 4
|
||||
:width 271
|
||||
:height 139
|
||||
:border-radius 16})
|
||||
|
||||
(def thumbnail
|
||||
{:width "100%"
|
||||
:height 139
|
||||
:margin-top 8
|
||||
:border-radius 12})
|
||||
|
||||
(def row-spacing {:flex-direction :row :margin-bottom 12})
|
||||
@@ -1,101 +0,0 @@
|
||||
(ns quo.components.status-link-previews.community.view
|
||||
(:require
|
||||
[quo.components.community.community-stat.view :as community-stat]
|
||||
[quo.components.links.link-preview.style :as style]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.status-link-previews.community.style :as status-link-previews-style]
|
||||
[quo.theme :as theme]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn- description-comp
|
||||
[description members-count active-members-count]
|
||||
[rn/view
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:number-of-lines 3
|
||||
:accessibility-label :description} description]
|
||||
[rn/view {:flex-direction :row :margin-top 12}
|
||||
[community-stat/view
|
||||
{:value members-count
|
||||
:icon :i/members
|
||||
:accessibility-label :members-count
|
||||
:style {:margin-right 12}}]
|
||||
[community-stat/view
|
||||
{:value (or active-members-count 0)
|
||||
:icon :i/active-members
|
||||
:accessibility-label :active-members-count}]]])
|
||||
|
||||
(defn- title-comp
|
||||
[title]
|
||||
[text/text
|
||||
{:size :paragraph-1
|
||||
:number-of-lines 1
|
||||
:weight :semi-bold
|
||||
:style style/title
|
||||
:accessibility-label :title}
|
||||
title])
|
||||
|
||||
(defn- thumbnail-comp
|
||||
[thumbnail]
|
||||
[rn/image
|
||||
{:style status-link-previews-style/thumbnail
|
||||
:source (if (string? thumbnail)
|
||||
{:uri thumbnail}
|
||||
thumbnail)
|
||||
:accessibility-label :thumbnail}])
|
||||
|
||||
(defn- logo-comp
|
||||
[logo]
|
||||
[rn/image
|
||||
{:accessibility-label :logo
|
||||
:source (if (string? logo)
|
||||
{:uri logo}
|
||||
logo)
|
||||
:style style/logo}])
|
||||
|
||||
(defn- stat-loading
|
||||
[theme]
|
||||
[rn/view {:style status-link-previews-style/loading-stat-container}
|
||||
[rn/view {:style (status-link-previews-style/loading-circle theme)}]
|
||||
[rn/view {:style (status-link-previews-style/loading-stat theme)}]])
|
||||
|
||||
(defn- loading-view
|
||||
[theme]
|
||||
[rn/view
|
||||
{:accessibility-label :loading}
|
||||
[rn/view {:style status-link-previews-style/row-spacing}
|
||||
[rn/view (status-link-previews-style/loading-circle theme)]
|
||||
[rn/view (status-link-previews-style/loading-first-line-bar theme)]]
|
||||
[rn/view {:style (status-link-previews-style/loading-second-line-bar theme)}]
|
||||
[rn/view status-link-previews-style/row-spacing
|
||||
[stat-loading theme]
|
||||
[stat-loading theme]]
|
||||
[rn/view {:style (status-link-previews-style/loading-thumbnail-box theme)}]])
|
||||
|
||||
(defn f-internal-view
|
||||
[{:keys [title description loading? thumbnail-size icon banner members-count active-members-count
|
||||
theme on-press]
|
||||
:or {loading? false}}]
|
||||
[rn/touchable-opacity
|
||||
{:style (merge (style/container (not loading?))
|
||||
{:width 295
|
||||
:height 245})
|
||||
:accessibility-label :link-preview
|
||||
:on-press on-press}
|
||||
(if loading?
|
||||
[loading-view theme]
|
||||
[:<>
|
||||
[rn/view {:style style/header-container}
|
||||
(when icon
|
||||
[logo-comp icon])
|
||||
[title-comp title]]
|
||||
(when description
|
||||
[description-comp description members-count active-members-count])
|
||||
(when banner
|
||||
[thumbnail-comp banner thumbnail-size])])])
|
||||
|
||||
(defn- internal-view
|
||||
[props]
|
||||
[:f> f-internal-view props])
|
||||
|
||||
(def view (theme/with-theme internal-view))
|
||||
@@ -107,3 +107,4 @@
|
||||
[tag-resources size type resource icon-color label text-color labelled?]]]))
|
||||
|
||||
(def tag (quo.theme/with-theme tag-internal))
|
||||
|
||||
|
||||
@@ -125,7 +125,6 @@
|
||||
quo.components.settings.settings-item.view
|
||||
quo.components.share.qr-code.view
|
||||
quo.components.share.share-qr-code.view
|
||||
quo.components.status-link-previews.community.view
|
||||
quo.components.switchers.group-messaging-card.view
|
||||
quo.components.tabs.account-selector
|
||||
quo.components.tabs.segmented-tab
|
||||
@@ -282,9 +281,6 @@
|
||||
(def url-preview quo.components.links.url-preview.view/view)
|
||||
(def url-preview-list quo.components.links.url-preview-list.view/view)
|
||||
|
||||
;;;; Status links
|
||||
(def status-link-preview-community quo.components.status-link-previews.community.view/view)
|
||||
|
||||
;;;; List items
|
||||
(def account-item quo.components.list-items.account.view/view)
|
||||
(def account-list-card quo.components.list-items.account-list-card.view/view)
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
[goog.object :as object]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.chat.models.mentions :as mentions]
|
||||
[status-im.chat.models.message :as chat.message]
|
||||
[status-im.chat.models.message-content :as message-content]
|
||||
[status-im.data-store.messages :as data-store-messages]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.chat.composer.link-preview.events :as link-preview]
|
||||
[status-im2.contexts.chat.messages.transport.events :as messages.transport]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
@@ -147,48 +147,15 @@
|
||||
preferred-name (get-in db [:profile/profile :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
|
||||
constants/content-type-text)
|
||||
:text input-text
|
||||
:response-to message-id
|
||||
:ens-name preferred-name
|
||||
:link-previews (map #(select-keys % [:url :title :description :thumbnail])
|
||||
(get-in db [:chat/link-previews :unfurled]))
|
||||
:status-link-previews (map (fn [item]
|
||||
{:url (:url item)
|
||||
:community
|
||||
{:community-id (get-in item [:community :community-id])
|
||||
:color (get-in item
|
||||
[:community :color])
|
||||
:description (get-in item
|
||||
[:community :description])
|
||||
:display-name (get-in item
|
||||
[:community :display-name])
|
||||
:members-count (get-in item
|
||||
[:community :members-count])
|
||||
:active-members-count (get-in item
|
||||
[:community :active-members-count])
|
||||
:icon {:data-uri (get-in item
|
||||
[:community :icon
|
||||
:data-uri])
|
||||
:width (get-in item
|
||||
[:community :icon
|
||||
:width])
|
||||
:height (get-in item
|
||||
[:community :icon
|
||||
:height])}
|
||||
:banner {:data-uri (get-in item
|
||||
[:community :banner
|
||||
:data-uri])
|
||||
:width (get-in item
|
||||
[:community :banner
|
||||
:width])
|
||||
:height (get-in item
|
||||
[:community :banner
|
||||
:height])}}})
|
||||
(get-in db [:chat/status-link-previews :unfurled]))})))
|
||||
{:chat-id current-chat-id
|
||||
:content-type (if emoji?
|
||||
constants/content-type-emoji
|
||||
constants/content-type-text)
|
||||
:text input-text
|
||||
:response-to message-id
|
||||
:ens-name preferred-name
|
||||
:link-previews (map #(select-keys % [:url :title :description :thumbnail])
|
||||
(get-in db [:chat/link-previews :unfurled]))})))
|
||||
|
||||
(defn build-image-messages
|
||||
[{db :db} chat-id input-text]
|
||||
@@ -226,7 +193,6 @@
|
||||
(rf/merge cofx
|
||||
(clean-input current-chat-id)
|
||||
(link-preview/reset-unfurled)
|
||||
(link-preview/clear-status-link-previews)
|
||||
(mentions/clear-mentions))))
|
||||
|
||||
(rf/defn send-messages
|
||||
@@ -239,8 +205,7 @@
|
||||
(rf/merge cofx
|
||||
(clean-input (:current-chat-id db))
|
||||
(link-preview/reset-unfurled)
|
||||
(link-preview/clear-status-link-previews)
|
||||
(chat.message/send-messages messages)))))
|
||||
(messages.transport/send-chat-messages messages)))))
|
||||
|
||||
(rf/defn send-audio-message
|
||||
[{:keys [db] :as cofx} audio-path duration current-chat-id]
|
||||
@@ -249,55 +214,51 @@
|
||||
(when-not (string/blank? audio-path)
|
||||
(rf/merge
|
||||
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)}
|
||||
(chat.message/send-message
|
||||
(merge
|
||||
{: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"})}
|
||||
(when message-id
|
||||
{:response-to message-id})))))))
|
||||
(messages.transport/send-chat-messages
|
||||
[(merge
|
||||
{: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"})}
|
||||
(when message-id
|
||||
{:response-to message-id}))])))))
|
||||
|
||||
(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"})})))
|
||||
(messages.transport/send-chat-messages
|
||||
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 chat-id]}]
|
||||
(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)
|
||||
:linkPreviews (map #(-> %
|
||||
(select-keys [:url :title :description
|
||||
:thumbnail])
|
||||
data-store-messages/->link-preview-rpc)
|
||||
(get-in db [:chat/link-previews :unfurled]))
|
||||
:statusLinkPreviews (map
|
||||
data-store-messages/<-status-link-previews-rpc
|
||||
(get-in db [:chat/status-link-previews :unfurled]))}]
|
||||
:js-response true
|
||||
:on-error #(log/error "failed to edit message " %)
|
||||
:on-success (fn [result]
|
||||
(re-frame/dispatch [:sanitize-messages-and-process-response
|
||||
result]))}]}
|
||||
{: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)
|
||||
:linkPreviews (map #(-> %
|
||||
(select-keys [:url :title :description
|
||||
:thumbnail])
|
||||
data-store-messages/->link-preview-rpc)
|
||||
(get-in db [:chat/link-previews :unfurled]))}]
|
||||
:js-response true
|
||||
:on-error #(log/error "failed to edit message " %)
|
||||
:on-success (fn [result]
|
||||
(re-frame/dispatch [:sanitize-messages-and-process-response
|
||||
result]))}]}
|
||||
(link-preview/reset-unfurled)
|
||||
(link-preview/clear-status-link-previews)
|
||||
(cancel-message-edit)))
|
||||
|
||||
(rf/defn send-current-message
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[react-native.platform :as platform]
|
||||
[status-im.chat.models.loading :as chat.loading]
|
||||
[status-im.data-store.messages :as data-store.messages]
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.utils.deprecated-types :as types]
|
||||
[status-im2.contexts.chat.messages.delete-message.events :as delete-message]
|
||||
[status-im2.contexts.chat.messages.list.events :as message-list]
|
||||
@@ -21,12 +20,6 @@
|
||||
[db chat-id clock-value]
|
||||
(>= (get-in db [:chats chat-id :deleted-at-clock-value]) clock-value))
|
||||
|
||||
(defn add-timeline-message
|
||||
[acc chat-id message-id message]
|
||||
(-> acc
|
||||
(update-in [:db :messages chat-id] assoc message-id message)
|
||||
(update-in [:db :message-lists chat-id] message-list/add message)))
|
||||
|
||||
(defn hide-message
|
||||
"Hide chat message, rebuild message-list"
|
||||
[{:keys [db]} chat-id message-id]
|
||||
@@ -145,14 +138,6 @@
|
||||
:on-error #(log/error "failed to re-send message" %)}]}
|
||||
(update-message-status chat-id message-id :sending)))
|
||||
|
||||
(rf/defn send-message
|
||||
[cofx message]
|
||||
(protocol/send-chat-messages cofx [message]))
|
||||
|
||||
(rf/defn send-messages
|
||||
[cofx messages]
|
||||
(protocol/send-chat-messages cofx messages))
|
||||
|
||||
(rf/defn handle-removed-messages
|
||||
{:events [::handle-removed-messages]}
|
||||
[{:keys [db] :as cofx} removed-messages]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.data-store.reactions :as data-store.reactions]
|
||||
[status-im.transport.message.protocol :as message.protocol]
|
||||
[status-im2.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]
|
||||
@@ -63,23 +62,6 @@
|
||||
(let [reactions-w-chat-id (map #(assoc % :chat-id chat-id) reactions)]
|
||||
{:db (update db :reactions (process-reactions (:chats db)) reactions-w-chat-id)})))
|
||||
|
||||
|
||||
;; Send reactions
|
||||
|
||||
|
||||
(rf/defn send-emoji-reaction
|
||||
{:events [:models.reactions/send-emoji-reaction]}
|
||||
[{{:keys [current-chat-id]} :db :as cofx} reaction]
|
||||
(message.protocol/send-reaction cofx
|
||||
(update reaction :chat-id #(or % current-chat-id))))
|
||||
|
||||
(rf/defn send-retract-emoji-reaction
|
||||
{:events [:models.reactions/send-emoji-reaction-retraction]}
|
||||
[{{:keys [current-chat-id]} :db :as cofx} reaction]
|
||||
(message.protocol/send-retract-reaction cofx
|
||||
(update reaction :chat-id #(or % current-chat-id))))
|
||||
|
||||
|
||||
(defn message-reactions
|
||||
[current-public-key reactions]
|
||||
(reduce
|
||||
|
||||
@@ -326,7 +326,7 @@
|
||||
(conj contacts user-pk)
|
||||
contacts)]
|
||||
(when (seq pks)
|
||||
{:json-rpc/call [{:method "wakuext_shareCommunityV2"
|
||||
{:json-rpc/call [{:method "wakuext_shareCommunity"
|
||||
:params [{:communityId community-id
|
||||
:users pks}]
|
||||
:js-response true
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn ->rpc
|
||||
[{:keys [content]
|
||||
:as message}]
|
||||
[{:keys [content] :as message}]
|
||||
(cond-> message
|
||||
content
|
||||
(assoc :text (:text content)
|
||||
@@ -17,18 +16,6 @@
|
||||
:community-id :communityId
|
||||
:clock-value :clock})))
|
||||
|
||||
(defn- <-status-link-previews-rpc
|
||||
[preview]
|
||||
(-> preview
|
||||
(update :community
|
||||
set/rename-keys
|
||||
{:communityId :community-id
|
||||
:displayName :display-name
|
||||
:membersCount :members-count
|
||||
:activeMembersCount :active-members-count})
|
||||
(update-in [:community :banner] set/rename-keys {:dataUri :data-uri})
|
||||
(update-in [:community :icon] set/rename-keys {:dataUri :data-uri})))
|
||||
|
||||
(defn- <-link-preview-rpc
|
||||
[preview]
|
||||
(update preview :thumbnail set/rename-keys {:dataUri :data-uri}))
|
||||
@@ -66,10 +53,8 @@
|
||||
:new :new?
|
||||
:albumImagesCount :album-images-count
|
||||
:displayName :display-name
|
||||
:linkPreviews :link-previews
|
||||
:statusLinkPreviews :status-link-previews})
|
||||
:linkPreviews :link-previews})
|
||||
(update :link-previews #(map <-link-preview-rpc %))
|
||||
(update :status-link-previews #(map <-status-link-previews-rpc %))
|
||||
(update :quoted-message
|
||||
set/rename-keys
|
||||
{:parsedText :parsed-text
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
status-im.pairing.core
|
||||
status-im.profile.core
|
||||
status-im.search.core
|
||||
status-im.signals.core
|
||||
status-im.stickers.core
|
||||
status-im.transport.core
|
||||
status-im.ui.components.invite.events
|
||||
[status-im.ui.components.react :as react]
|
||||
status-im.ui.screens.notifications-settings.events
|
||||
@@ -136,7 +134,7 @@
|
||||
|
||||
(rf/defn on-return-from-background
|
||||
[{:keys [db now] :as cofx}]
|
||||
(let [new-account? (get db :onboarding-2/new-account?)
|
||||
(let [new-account? (get db :onboarding/new-account?)
|
||||
app-in-background-since (get db :app-in-background-since)
|
||||
signed-up? (get-in db [:profile/profile :signed-up?])
|
||||
requires-bio-auth (and
|
||||
@@ -194,9 +192,9 @@
|
||||
(rf/merge cofx
|
||||
(cond
|
||||
(= :chat view-id)
|
||||
{:async-storage-set {:chat-id (get-in cofx [:db :current-chat-id])
|
||||
:key-uid (get-in cofx [:db :profile/profile :key-uid])}
|
||||
:db (assoc db :screens/was-focused-once? true)}
|
||||
{:effects.async-storage/set {:chat-id (get-in cofx [:db :current-chat-id])
|
||||
:key-uid (get-in cofx [:db :profile/profile :key-uid])}
|
||||
:db (assoc db :screens/was-focused-once? true)}
|
||||
|
||||
(not (get db :screens/was-focused-once?))
|
||||
{:db (assoc db :screens/was-focused-once? true)})
|
||||
|
||||
@@ -141,14 +141,14 @@
|
||||
(let [pin (get-in db [:keycard :pin :original])
|
||||
puk-restore? (get-in db [:keycard :pin :puk-restore?])]
|
||||
(rf/merge cofx
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:login pin
|
||||
:confirmation []
|
||||
:error-label nil})
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pin-changed)}}
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:login pin
|
||||
:confirmation []
|
||||
:error-label nil})
|
||||
:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pin-changed)}}
|
||||
(common/hide-connection-sheet)
|
||||
(if puk-restore?
|
||||
(navigation/navigate-to :multiaccounts nil)
|
||||
@@ -160,14 +160,14 @@
|
||||
{:events [:keycard.callback/on-change-puk-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(rf/merge cofx
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:puk-original []
|
||||
:puk-confirmation []
|
||||
:error-label nil})
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/puk-changed)}}
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:puk-original []
|
||||
:puk-confirmation []
|
||||
:error-label nil})
|
||||
:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/puk-changed)}}
|
||||
(common/hide-connection-sheet)
|
||||
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])))
|
||||
|
||||
@@ -175,13 +175,13 @@
|
||||
{:events [:keycard.callback/on-change-pairing-success]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(rf/merge cofx
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:pairing-code nil
|
||||
:error-label nil})
|
||||
:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pairing-changed)}}
|
||||
{:db (assoc-in db
|
||||
[:keycard :pin]
|
||||
{:status nil
|
||||
:pairing-code nil
|
||||
:error-label nil})
|
||||
:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/pairing-changed)}}
|
||||
(common/hide-connection-sheet)
|
||||
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])))
|
||||
|
||||
|
||||
@@ -293,14 +293,14 @@
|
||||
(rf/defn show-wrong-keycard-alert
|
||||
[_]
|
||||
(log/debug "show-wrong-keycard-alert")
|
||||
{:utils/show-popup {:title (i18n/label :t/wrong-card)
|
||||
:content (i18n/label :t/wrong-card-text)}})
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/wrong-card)
|
||||
:content (i18n/label :t/wrong-card-text)}})
|
||||
|
||||
(rf/defn unauthorized-operation
|
||||
[cofx]
|
||||
(rf/merge cofx
|
||||
{:utils/show-popup {:title ""
|
||||
:content (i18n/label :t/keycard-unauthorized-operation)}}
|
||||
{:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/keycard-unauthorized-operation)}}
|
||||
(clear-on-card-connected)
|
||||
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])))
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
(rf/defn show-keycard-has-multiaccount-alert
|
||||
[{:keys [db] :as cofx}]
|
||||
(rf/merge cofx
|
||||
{:db (assoc-in db [:keycard :setup-step] nil)
|
||||
:utils/show-confirmation {:title nil
|
||||
:content (i18n/label
|
||||
:t/keycard-has-multiaccount-on-it)
|
||||
:cancel-button-text ""
|
||||
:confirm-button-text :t/okay}}))
|
||||
{:db (assoc-in db [:keycard :setup-step] nil)
|
||||
:effects.utils/show-confirmation {:title nil
|
||||
:content (i18n/label
|
||||
:t/keycard-has-multiaccount-on-it)
|
||||
:cancel-button-text ""
|
||||
:confirm-button-text :t/okay}}))
|
||||
|
||||
(rf/defn load-pin-screen
|
||||
[{:keys [db] :as cofx}]
|
||||
@@ -548,10 +548,11 @@
|
||||
|
||||
(rf/defn show-no-keycard-applet-alert
|
||||
[_]
|
||||
{:utils/show-confirmation {:title (i18n/label :t/no-keycard-applet-on-card)
|
||||
:content (i18n/label :t/keycard-applet-install-instructions)
|
||||
:cancel-button-text ""
|
||||
:confirm-button-text :t/okay}})
|
||||
{:effects.utils/show-confirmation {:title (i18n/label :t/no-keycard-applet-on-card)
|
||||
:content (i18n/label
|
||||
:t/keycard-applet-install-instructions)
|
||||
:cancel-button-text ""
|
||||
:confirm-button-text :t/okay}})
|
||||
|
||||
;; NOTE: Maybe replaced by multiple events based on on flow to make it easier to maintain.
|
||||
;; Because there are many execution paths it is harder to follow all possible states.
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
(do
|
||||
(log/debug (str "Cannot start keycard installation from state: " card-state))
|
||||
(rf/merge cofx
|
||||
{:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
(navigation/navigate-to :keycard-authentication-method nil))))))
|
||||
|
||||
(rf/defn load-preparing-screen
|
||||
|
||||
@@ -221,12 +221,12 @@
|
||||
(rf/defn on-backup-success
|
||||
[{:keys [db] :as cofx} backup-type]
|
||||
(rf/merge cofx
|
||||
{:utils/show-popup {:title (i18n/label (if (= backup-type :recovery-card)
|
||||
:t/keycard-access-reset
|
||||
:t/keycard-backup-success-title))
|
||||
:content (i18n/label (if (= backup-type :recovery-card)
|
||||
:t/keycard-can-use-with-new-passcode
|
||||
:t/keycard-backup-success-body))}}
|
||||
{:effects.utils/show-popup {:title (i18n/label (if (= backup-type :recovery-card)
|
||||
:t/keycard-access-reset
|
||||
:t/keycard-backup-success-title))
|
||||
:content (i18n/label (if (= backup-type :recovery-card)
|
||||
:t/keycard-can-use-with-new-passcode
|
||||
:t/keycard-backup-success-body))}}
|
||||
(cond
|
||||
(multiaccounts.model/logged-in? db)
|
||||
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])
|
||||
@@ -373,4 +373,3 @@
|
||||
cofx
|
||||
{:on-card-connected :keycard/load-recovering-key-screen
|
||||
:handler (common/dispatch-event :keycard/import-multiaccount)}))
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:keycard/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
:utils/show-popup {:title ""
|
||||
:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/card-unpaired)}}
|
||||
(common/clear-on-card-connected)
|
||||
(remove-pairing-from-multiaccount nil)
|
||||
@@ -100,7 +100,7 @@
|
||||
:error-label nil
|
||||
:on-verified nil})
|
||||
:keycard/get-application-info nil
|
||||
:utils/show-popup {:title ""
|
||||
:effects.utils/show-popup {:title ""
|
||||
:content (i18n/label :t/something-went-wrong)}}
|
||||
(common/clear-on-card-connected)
|
||||
(navigation/navigate-to :keycard-settings nil)))
|
||||
@@ -139,15 +139,14 @@
|
||||
:error-label nil
|
||||
:on-verified nil}))
|
||||
:keycard/persist-pairings (dissoc pairings (keyword instance-uid))
|
||||
:utils/show-popup {:title (i18n/label (if keys-removed-from-card?
|
||||
:effects.utils/show-popup {:title (i18n/label (if keys-removed-from-card?
|
||||
:t/profile-deleted-title
|
||||
:t/database-reset-title))
|
||||
:content (i18n/label (if keys-removed-from-card?
|
||||
:t/profile-deleted-keycard
|
||||
:t/database-reset-content))
|
||||
:on-dismiss #(re-frame/dispatch [:logout])}}
|
||||
;;should be reimplemented
|
||||
;;:key-storage/delete-profile {:key-uid key-uid
|
||||
;;should be reimplemented :key-storage/delete-profile {:key-uid key-uid
|
||||
;;:on-success #(log/debug "[keycard] remove account ok")
|
||||
;; :on-error #(log/warn "[keycard] remove account: " %)}
|
||||
(common/clear-on-card-connected)
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
{:events [:mailserver.ui/request-error-pressed]}
|
||||
[{:keys [db]}]
|
||||
(let [mailserver-error (:mailserver/request-error db)]
|
||||
{:utils/show-confirmation
|
||||
{:effects.utils/show-confirmation
|
||||
{:title (i18n/label :t/mailserver-request-error-title)
|
||||
:content (i18n/label :t/mailserver-request-error-content
|
||||
{:error mailserver-error})
|
||||
@@ -290,8 +290,7 @@
|
||||
[{:method "mailservers_addMailserver"
|
||||
:params [(mailserver->rpc mailserver current-fleet)]
|
||||
:on-success (fn []
|
||||
;; we naively logout if the user is connected to
|
||||
;; the edited mailserver
|
||||
;; we naively logout if the user is connected to the edited mailserver
|
||||
(when current
|
||||
(re-frame/dispatch
|
||||
[:multiaccounts.logout.ui/logout-confirmed]))
|
||||
@@ -413,3 +412,17 @@
|
||||
(rf/merge cofx
|
||||
{:db (dissoc db :mailserver.edit/mailserver)}
|
||||
(navigation/navigate-to :edit-mailserver nil)))
|
||||
|
||||
(defn add-mailservers
|
||||
[db mailservers]
|
||||
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
|
||||
(let [updated-mailserver
|
||||
(-> mailserver
|
||||
(update :id keyword)
|
||||
(assoc :name (if (seq name) name id))
|
||||
(dissoc :fleet))]
|
||||
(assoc-in db
|
||||
[:mailserver/mailservers (keyword fleet) (keyword id)]
|
||||
updated-mailserver)))
|
||||
db
|
||||
mailservers))
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
(rf/merge cofx
|
||||
{:set-root :progress
|
||||
:chat.ui/clear-inputs nil
|
||||
:shell/reset-state nil
|
||||
:effects.shell/reset-state nil
|
||||
:hide-popover nil
|
||||
::logout nil
|
||||
:profile.settings/webview-debug-changed false
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
(rf/defn connect-failure
|
||||
{:events [::connect-failure]}
|
||||
[_ reason]
|
||||
{:utils/show-popup
|
||||
{:effects.utils/show-popup
|
||||
{:title (i18n/label :t/error)
|
||||
:content (str reason)}})
|
||||
|
||||
|
||||
@@ -165,9 +165,9 @@
|
||||
(if (< (count (filter :enabled? (vals (get-in cofx [:db :pairing/installations]))))
|
||||
(inc config/max-installations))
|
||||
{:pairing/enable-installation [installation-id]}
|
||||
{:utils/show-popup {:title (i18n/label :t/pairing-maximum-number-reached-title)
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/pairing-maximum-number-reached-title)
|
||||
|
||||
:content (i18n/label :t/pairing-maximum-number-reached-content)}}))
|
||||
:content (i18n/label :t/pairing-maximum-number-reached-content)}}))
|
||||
|
||||
(rf/defn disable-fx
|
||||
{:events [:pairing.ui/disable-installation-pressed]}
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
[{:keys [db] :as cofx} {:keys [chat-id]}]
|
||||
(if-not (own-public-key? db chat-id)
|
||||
{:dispatch [:chat.ui/start-chat chat-id]}
|
||||
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/can-not-add-yourself)}}))
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/can-not-add-yourself)}}))
|
||||
|
||||
(rf/defn handle-group-chat
|
||||
[cofx params]
|
||||
@@ -71,9 +71,9 @@
|
||||
(navigation/navigate-back))
|
||||
|
||||
:else
|
||||
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/ens-name-not-found)
|
||||
:on-dismiss #(re-frame/dispatch [:pop-to-root :shell-stack])}})))
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/ens-name-not-found)
|
||||
:on-dismiss #(re-frame/dispatch [:pop-to-root :shell-stack])}})))
|
||||
|
||||
(rf/defn handle-eip681
|
||||
[cofx data]
|
||||
@@ -103,9 +103,9 @@
|
||||
(log/info "Unable to find matcher for scanned value"
|
||||
{:type type
|
||||
:event ::match-scanned-value})
|
||||
{:dispatch [:navigate-back]
|
||||
:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:on-dismiss #(re-frame/dispatch [:pop-to-root :shell-stack])}})))
|
||||
{:dispatch [:navigate-back]
|
||||
:effects.utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:on-dismiss #(re-frame/dispatch [:pop-to-root :shell-stack])}})))
|
||||
|
||||
(rf/defn on-scan
|
||||
{:events [::on-scan-success]}
|
||||
|
||||
@@ -78,9 +78,9 @@
|
||||
[{:keys [db]} data typed? result]
|
||||
(let [{:keys [result error]} (types/json->clj result)]
|
||||
(if error
|
||||
{:dispatch [:signing.ui/cancel-is-pressed]
|
||||
:utils/show-popup {:title (i18n/label :t/sign-request-failed)
|
||||
:content (:message error)}}
|
||||
{:dispatch [:signing.ui/cancel-is-pressed]
|
||||
:effects.utils/show-popup {:title (i18n/label :t/sign-request-failed)
|
||||
:content (:message error)}}
|
||||
{:db (update db
|
||||
:keycard assoc
|
||||
:hash result
|
||||
|
||||
@@ -104,7 +104,6 @@
|
||||
;;; Link previews
|
||||
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
|
||||
(reg-root-key-sub :chat/link-previews :chat/link-previews)
|
||||
(reg-root-key-sub :chat/status-link-previews :chat/status-link-previews)
|
||||
|
||||
;;commands
|
||||
(reg-root-key-sub :commands/select-account :commands/select-account)
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
(ns ^{:doc "API to init and stop whisper messaging"} status-im.transport.core
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.pairing.core :as pairing]
|
||||
[status-im.stickers.core :as stickers]
|
||||
status-im.transport.shh
|
||||
[status-im2.common.universal-links :as universal-links]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn set-node-info
|
||||
{:events [:transport.callback/node-info-fetched]}
|
||||
[{:keys [db]} node-info]
|
||||
{:db (assoc db :node-info node-info)})
|
||||
|
||||
(rf/defn fetch-node-info-fx
|
||||
[_]
|
||||
{:json-rpc/call [{:method "admin_nodeInfo"
|
||||
:on-success #(re-frame/dispatch [:transport.callback/node-info-fetched %])
|
||||
:on-error #(log/error "node-info: failed error" %)}]})
|
||||
|
||||
(defn add-mailservers
|
||||
[db mailservers]
|
||||
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
|
||||
(let [updated-mailserver
|
||||
(-> mailserver
|
||||
(update :id keyword)
|
||||
(assoc :name (if (seq name) name id))
|
||||
(dissoc :fleet))]
|
||||
(assoc-in db
|
||||
[:mailserver/mailservers (keyword fleet) (keyword id)]
|
||||
updated-mailserver)))
|
||||
db
|
||||
mailservers))
|
||||
|
||||
(rf/defn start-messenger
|
||||
"We should only start receiving messages/processing topics once all the
|
||||
initializiation is completed, otherwise we might receive messages/topics
|
||||
when the state has not been properly initialized."
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_startMessenger"
|
||||
:on-success #(re-frame/dispatch [::messenger-started %])
|
||||
:on-error #(log/error "failed to start messenger")}]})
|
||||
|
||||
(rf/defn messenger-started
|
||||
{:events [::messenger-started]}
|
||||
[{:keys [db] :as cofx} {:keys [mailservers] :as response}]
|
||||
(log/info "Messenger started")
|
||||
(let [new-account? (get db :onboarding-2/new-account?)]
|
||||
(rf/merge cofx
|
||||
{:db (-> db
|
||||
(assoc :messenger/started? true)
|
||||
(add-mailservers mailservers))}
|
||||
(fetch-node-info-fx)
|
||||
(pairing/init)
|
||||
(stickers/load-packs)
|
||||
(when-not new-account?
|
||||
(universal-links/process-stored-event)))))
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
(ns ^{:doc "Protocol API and protocol utils"} status-im.transport.message.protocol
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- image->rpc [image] (set/rename-keys image {:data-uri :dataUri}))
|
||||
|
||||
(defn- link-preview->rpc
|
||||
[preview]
|
||||
(update preview
|
||||
:thumbnail
|
||||
(fn [thumbnail]
|
||||
(image->rpc thumbnail))))
|
||||
|
||||
(defn- status-link-preview->rpc
|
||||
[preview]
|
||||
(update preview
|
||||
:community
|
||||
(fn [community]
|
||||
(-> community
|
||||
(set/rename-keys {:community-id :communityId
|
||||
:display-name :displayName
|
||||
:members-count :membersCount
|
||||
:active-members-count :activeMembersCount})
|
||||
(update :banner image->rpc)
|
||||
(update :icon image->rpc)))))
|
||||
|
||||
(defn build-message
|
||||
[msg]
|
||||
(-> msg
|
||||
(update :link-previews #(map link-preview->rpc %))
|
||||
(update :status-link-previews #(set (map status-link-preview->rpc %)))
|
||||
(set/rename-keys
|
||||
{:album-id :albumId
|
||||
:audio-duration-ms :audioDurationMs
|
||||
:audio-path :audioPath
|
||||
:chat-id :chatId
|
||||
:community-id :communityId
|
||||
:content-type :contentType
|
||||
:ens-name :ensName
|
||||
:image-height :imageHeight
|
||||
:image-path :imagePath
|
||||
:image-width :imageWidth
|
||||
:link-previews :linkPreviews
|
||||
:status-link-previews :statusLinkPreviews
|
||||
:response-to :responseTo
|
||||
:sticker :sticker
|
||||
:text :text})))
|
||||
|
||||
(rf/defn send-chat-messages
|
||||
[_ messages]
|
||||
{:json-rpc/call [{:method "wakuext_sendChatMessages"
|
||||
:params [(mapv build-message messages)]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:transport/message-sent %])
|
||||
:on-error #(do
|
||||
(log/warn "failed to send a message" %)
|
||||
(js/alert (str "failed to send a message: " %)))}]})
|
||||
|
||||
(rf/defn send-reaction
|
||||
[_ {:keys [message-id chat-id emoji-id]}]
|
||||
{:json-rpc/call [{:method "wakuext_sendEmojiReaction"
|
||||
:params [chat-id message-id emoji-id]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to send a reaction" %)}]})
|
||||
|
||||
(rf/defn send-retract-reaction
|
||||
[_ {:keys [emoji-reaction-id]}]
|
||||
{:json-rpc/call [{:method "wakuext_sendEmojiReactionRetraction"
|
||||
:params [emoji-reaction-id]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to send a reaction retraction" %)}]})
|
||||
@@ -1,35 +0,0 @@
|
||||
(ns ^{:doc "Whisper API and events for managing keys and posting messages"} status-im.transport.shh
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im2.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn generate-sym-key-from-password
|
||||
[{:keys [password on-success on-error]}]
|
||||
(json-rpc/call {:method "waku_generateSymKeyFromPassword"
|
||||
:params [password]
|
||||
:on-success on-success
|
||||
:on-error on-error}))
|
||||
|
||||
(defn get-sym-key
|
||||
[{:keys [sym-key-id on-success on-error]}]
|
||||
(json-rpc/call {:method "waku_getSymKey"
|
||||
:params [sym-key-id]
|
||||
:on-success on-success
|
||||
:on-error on-error}))
|
||||
|
||||
(defn log-error
|
||||
[error]
|
||||
(log/error :shh/get-new-sym-key-error error))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:shh/generate-sym-key-from-password
|
||||
(fn [{:keys [password on-success]}]
|
||||
(generate-sym-key-from-password
|
||||
{:password password
|
||||
:on-success (fn [sym-key-id]
|
||||
(get-sym-key {:sym-key-id sym-key-id
|
||||
:on-success (fn [sym-key]
|
||||
(on-success sym-key sym-key-id))
|
||||
:on-error log-error}))
|
||||
:on-error log-error})))
|
||||
@@ -1,18 +0,0 @@
|
||||
(ns ^{:doc "Utils for transport layer"} status-im.transport.utils
|
||||
(:require
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn extract-enode-id
|
||||
[enode]
|
||||
(-> enode
|
||||
(string/split #"/")
|
||||
(get 2 "")
|
||||
(string/split #":")
|
||||
(get 0 "")
|
||||
(string/split "@")
|
||||
(get 0)))
|
||||
|
||||
(defn extract-url-components
|
||||
[address]
|
||||
(when address
|
||||
(rest (re-matches #"enode://(.*?)@(.*):(.*)" address))))
|
||||
@@ -56,7 +56,7 @@
|
||||
{:events [::on-delete-profile-success]}
|
||||
[cofx]
|
||||
(log/info "[delete-profile] on-success")
|
||||
{:utils/show-popup
|
||||
{:effects.utils/show-popup
|
||||
{:title (i18n/label :t/profile-deleted-title)
|
||||
:content (i18n/label :t/profile-deleted-content)
|
||||
:on-dismiss #(re-frame/dispatch [:logout])}})
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
key-uid]
|
||||
:as profile}
|
||||
@(re-frame/subscribe [:profile/profile-with-image])
|
||||
customization-color (or (:color @(re-frame/subscribe [:onboarding-2/profile]))
|
||||
customization-color (or (:color @(re-frame/subscribe [:onboarding/profile]))
|
||||
@(re-frame/subscribe [:profile/customization-color key-uid]))
|
||||
on-share #(re-frame/dispatch [:show-popover
|
||||
{:view :share-chat-key
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
[react-native.mail :as react-native-mail]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.bottom-sheet.events :as bottom-sheet]
|
||||
[status-im.transport.utils :as transport.utils]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.utils.build :as build]
|
||||
[status-im.utils.deprecated-types :as types]
|
||||
@@ -38,6 +37,11 @@
|
||||
{:json-rpc/call [{:method "web3_clientVersion"
|
||||
:on-success #(re-frame/dispatch [:logging/store-web3-client-version %])}]})
|
||||
|
||||
(defn extract-url-components
|
||||
[address]
|
||||
(when address
|
||||
(rest (re-matches #"enode://(.*?)@(.*):(.*)" address))))
|
||||
|
||||
(defn email-body
|
||||
"logs attached"
|
||||
[{:keys [:web3-node-version :mailserver/current-id
|
||||
@@ -46,7 +50,7 @@
|
||||
build-version (str build/version " (" build-number ")")
|
||||
separator (string/join (take 40 (repeat "-")))
|
||||
[enode-id ip-address port]
|
||||
(transport.utils/extract-url-components (:enode node-info))]
|
||||
(extract-url-components (:enode node-info))]
|
||||
(string/join
|
||||
"\n"
|
||||
(concat [(i18n/label :t/report-bug-email-template
|
||||
@@ -68,7 +72,7 @@
|
||||
(mapcat
|
||||
(fn [{:keys [enode]}]
|
||||
(let [[enode-id ip-address port]
|
||||
(transport.utils/extract-url-components enode)]
|
||||
(extract-url-components enode)]
|
||||
[(str "id: " enode-id)
|
||||
(str "ip: " ip-address)
|
||||
(str "port: " port)
|
||||
@@ -151,15 +155,15 @@
|
||||
(rf/defn show-client-error
|
||||
{:events [:show-client-error]}
|
||||
[_]
|
||||
{:utils/show-popup {:title (i18n/label :t/cant-report-bug)
|
||||
:content (i18n/label :t/mail-should-be-configured)}})
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/cant-report-bug)
|
||||
:content (i18n/label :t/mail-should-be-configured)}})
|
||||
|
||||
(rf/defn show-logs-dialog
|
||||
{:events [:shake-event]}
|
||||
[{:keys [db]}]
|
||||
(when-not (:logging/dialog-shown? db)
|
||||
{:db (assoc db :logging/dialog-shown? true)
|
||||
:utils/show-confirmation
|
||||
:effects.utils/show-confirmation
|
||||
(cond-> {:title (i18n/label :t/send-logs)
|
||||
:content (i18n/label :t/send-logs-to
|
||||
{:email report-email})
|
||||
|
||||
@@ -359,8 +359,8 @@
|
||||
(let [deleted-address (:address account)
|
||||
dapps-address (get-in cofx [:db :profile/profile :dapps-address])]
|
||||
(if (= (string/lower-case dapps-address) (string/lower-case deleted-address))
|
||||
{:utils/show-popup {:title (i18n/label :t/warning)
|
||||
:content (i18n/label :t/account-is-used)}}
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/warning)
|
||||
:content (i18n/label :t/account-is-used)}}
|
||||
{:key-storage/delete-imported-key
|
||||
{:key-uid (get-in db [:profile/profile :key-uid])
|
||||
:address (:address account)
|
||||
@@ -379,8 +379,8 @@
|
||||
(assoc-in [:add-account :scanned-address] address)
|
||||
(assoc-in [:add-account :address] address))}
|
||||
(when-not address
|
||||
{:utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/invalid-address-qr-code)}}))
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/error)
|
||||
:content (i18n/label :t/invalid-address-qr-code)}}))
|
||||
(navigation/navigate-back))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
@@ -392,4 +392,3 @@
|
||||
{:events [:wallet-legacy.accounts/share]}
|
||||
[_ address]
|
||||
{:list.selection/open-share {:message (eip55/address->checksum address)}})
|
||||
|
||||
|
||||
@@ -246,8 +246,8 @@
|
||||
assets (get visible-tokens chain)
|
||||
tokens (->> (vals all-tokens)
|
||||
(remove #(or (:hidden? %)
|
||||
;;if not scan-all-tokens? remove not
|
||||
;;visible tokens
|
||||
;;if not scan-all-tokens? remove
|
||||
;;not visible tokens
|
||||
(and (not scan-all-tokens?)
|
||||
(not (get assets (:symbol %))))))
|
||||
(reduce (fn [acc {:keys [address symbol]}]
|
||||
@@ -822,8 +822,8 @@
|
||||
(rf/defn get-buy-crypto-preference
|
||||
{:events [::get-buy-crypto]}
|
||||
[_]
|
||||
{:async-storage-get {:keys [:buy-crypto-hidden]
|
||||
:cb #(re-frame/dispatch [::store-buy-crypto-preference %])}})
|
||||
{:effects.async-storage/get {:keys [:buy-crypto-hidden]
|
||||
:cb #(re-frame/dispatch [::store-buy-crypto-preference %])}})
|
||||
|
||||
(rf/defn wallet-will-focus
|
||||
{:events [::wallet-stack]}
|
||||
@@ -844,8 +844,8 @@
|
||||
(rf/defn hide-buy-crypto
|
||||
{:events [::hide-buy-crypto]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc db :wallet-legacy/buy-crypto-hidden true)
|
||||
:async-storage-set {:buy-crypto-hidden true}})
|
||||
{:db (assoc db :wallet-legacy/buy-crypto-hidden true)
|
||||
:effects.async-storage/set {:buy-crypto-hidden true}})
|
||||
|
||||
(rf/defn store-buy-crypto
|
||||
{:events [::store-buy-crypto-preference]}
|
||||
@@ -1023,8 +1023,8 @@
|
||||
(rf/defn switch-transactions-management-enabled
|
||||
{:events [:multiaccounts.ui/switch-transactions-management-enabled]}
|
||||
[{:keys [db]} enabled?]
|
||||
{:async-storage-set {:transactions-management-enabled? enabled?}
|
||||
:db (assoc db :wallet-legacy/transactions-management-enabled? enabled?)})
|
||||
{:effects.async-storage/set {:transactions-management-enabled? enabled?}
|
||||
:db (assoc db :wallet-legacy/transactions-management-enabled? enabled?)})
|
||||
|
||||
(re-frame/reg-fx
|
||||
:wallet-legacy/initialize-transactions-management-enabled
|
||||
@@ -1072,9 +1072,8 @@
|
||||
true])}))
|
||||
2000)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
;;TODO: this could be replaced by a single API call on status-go side
|
||||
:wallet-legacy/initialize-wallet
|
||||
;;TODO: this could be replaced by a single API call on status-go side
|
||||
(re-frame/reg-fx :wallet-legacy/initialize-wallet
|
||||
(fn [[network-id network callback]]
|
||||
(-> (js/Promise.all
|
||||
(clj->js
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
(rf/defn not-supported
|
||||
{:events [:wallet-legacy.custom-token/not-supported]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:wallet-legacy/custom-token-screen :in-progress?] nil)
|
||||
:utils/show-popup {:content (i18n/label :t/contract-isnt-supported)}})
|
||||
{:db (assoc-in db [:wallet-legacy/custom-token-screen :in-progress?] nil)
|
||||
:effects.utils/show-popup {:content (i18n/label :t/contract-isnt-supported)}})
|
||||
|
||||
(rf/defn add-custom-token
|
||||
{:events [:wallet-legacy.custom-token.ui/add-pressed]}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
(ns status-im2.common.alert.events
|
||||
(ns status-im2.common.alert.effects
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.core :as rn]
|
||||
[utils.i18n :as i18n]))
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn show-popup
|
||||
([title content]
|
||||
@@ -26,8 +26,7 @@
|
||||
(when on-dismiss
|
||||
{:cancelable false})))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:utils/show-popup
|
||||
(rf/reg-fx :effects.utils/show-popup
|
||||
(fn [{:keys [title content on-dismiss]}]
|
||||
(show-popup title content on-dismiss)))
|
||||
|
||||
@@ -50,8 +49,7 @@
|
||||
(or extra-options nil))
|
||||
{:cancelable false}))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:utils/show-confirmation
|
||||
(rf/reg-fx :effects.utils/show-confirmation
|
||||
(fn [{:keys [title content confirm-button-text on-accept on-cancel cancel-button-text extra-options]}]
|
||||
(show-confirmation {:title title
|
||||
:content content
|
||||
@@ -60,18 +58,3 @@
|
||||
:on-accept on-accept
|
||||
:on-cancel on-cancel
|
||||
:extra-options extra-options})))
|
||||
|
||||
(defn show-question
|
||||
([title content on-accept]
|
||||
(show-question title content on-accept nil))
|
||||
([title content on-accept on-cancel]
|
||||
(rn/alert
|
||||
title
|
||||
content
|
||||
(vector (merge {:text (i18n/label :t/no)
|
||||
:accessibility-label :no-button}
|
||||
(when on-cancel {:onPress on-cancel}))
|
||||
{:text (i18n/label :t/yes)
|
||||
:onPress on-accept
|
||||
:accessibility-label :yes-button})
|
||||
nil)))
|
||||
@@ -1,8 +0,0 @@
|
||||
(ns status-im2.common.async-storage
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
react-native.async-storage))
|
||||
|
||||
(re-frame/reg-fx :async-storage-set (react-native.async-storage/set-item-factory))
|
||||
(re-frame/reg-fx :async-storage-get
|
||||
(fn [{ks :keys cb :cb}] (react-native.async-storage/get-items ks cb)))
|
||||
@@ -0,0 +1,11 @@
|
||||
(ns status-im2.common.async-storage.effects
|
||||
(:require
|
||||
[react-native.async-storage :as async-storage]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.async-storage/set
|
||||
(async-storage/set-item-factory))
|
||||
|
||||
(rf/reg-fx :effects.async-storage/get
|
||||
(fn [{ks :keys cb :cb}]
|
||||
(async-storage/get-items ks cb)))
|
||||
@@ -51,7 +51,7 @@
|
||||
(i18n/label :t/grant-face-id-permissions)
|
||||
(i18n/label :t/biometric-auth-error {:code code}))]
|
||||
(when handle-error?
|
||||
{:utils/show-popup
|
||||
{:effects.utils/show-popup
|
||||
{:title (i18n/label :t/biometric-auth-login-error-title)
|
||||
:content content}})))
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
(ns status-im2.common.font.effects
|
||||
(:require
|
||||
utils.image-server
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.font/get-font-file-for-initials-avatar
|
||||
(fn [callback]
|
||||
(utils.image-server/get-font-file-ready callback)))
|
||||
@@ -1,15 +1,9 @@
|
||||
(ns status-im2.common.font
|
||||
(ns status-im2.common.font.events
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
utils.image-server
|
||||
status-im2.common.font.effects
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:font/get-font-file-for-initials-avatar
|
||||
(fn [callback]
|
||||
(utils.image-server/get-font-file-ready callback)))
|
||||
|
||||
(rf/defn init-abs-root-path
|
||||
{:events [:font/init-font-file-for-initials-avatar]}
|
||||
[{:keys [db]} initials-avatar-font-file]
|
||||
@@ -0,0 +1,65 @@
|
||||
(ns status-im2.common.pairing.events
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.communities.discover.events]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn handle-local-pairing-signals
|
||||
[{:keys [db]} {:keys [type action data error] :as event}]
|
||||
(log/info "local pairing signal received"
|
||||
{:event event})
|
||||
(let [{:keys [account password]} data
|
||||
role (get-in db [:syncing :role])
|
||||
receiver? (= role constants/local-pairing-role-receiver)
|
||||
sender? (= role constants/local-pairing-role-sender)
|
||||
connection-success? (and (= type
|
||||
constants/local-pairing-event-connection-success)
|
||||
(= action
|
||||
constants/local-pairing-action-connect))
|
||||
error-on-pairing? (contains? constants/local-pairing-event-errors type)
|
||||
completed-pairing? (and (= type
|
||||
constants/local-pairing-event-transfer-success)
|
||||
(= action
|
||||
constants/local-pairing-action-pairing-installation))
|
||||
received-account? (and (= type
|
||||
constants/local-pairing-event-received-account)
|
||||
(= action
|
||||
constants/local-pairing-action-pairing-account)
|
||||
(and (some? account) (some? password)))
|
||||
multiaccount-data (when received-account?
|
||||
(merge account {:password password}))
|
||||
navigate-to-syncing-devices? (and (or connection-success? error-on-pairing?) receiver?)
|
||||
user-in-syncing-devices-screen? (or (= (:view-id db) :syncing-progress)
|
||||
(= (:view-id db) :syncing-progress-intro))
|
||||
user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)]
|
||||
(merge {:db (cond-> db
|
||||
connection-success?
|
||||
(assoc-in [:syncing :pairing-status] :connected)
|
||||
|
||||
received-account?
|
||||
(assoc-in [:syncing :profile] multiaccount-data)
|
||||
|
||||
error-on-pairing?
|
||||
(assoc-in [:syncing :pairing-status] :error)
|
||||
|
||||
completed-pairing?
|
||||
(assoc-in [:syncing :pairing-status] :completed))}
|
||||
(cond
|
||||
(and navigate-to-syncing-devices? (not user-in-syncing-devices-screen?))
|
||||
{:dispatch (if user-in-sign-in-intro-screen?
|
||||
[:navigate-to-within-stack [:syncing-progress-intro :sign-in-intro]]
|
||||
[:navigate-to :syncing-progress])}
|
||||
|
||||
(and completed-pairing? sender?)
|
||||
{:dispatch [:syncing/clear-states]}
|
||||
|
||||
(and completed-pairing? receiver?)
|
||||
{:dispatch [:profile.login/local-paired-user]}
|
||||
|
||||
(and error-on-pairing? (some? error))
|
||||
{:dispatch [:toasts/upsert
|
||||
{:icon :i/alert
|
||||
:icon-color colors/danger-50
|
||||
:text error}]}))))
|
||||
@@ -38,10 +38,11 @@
|
||||
:padding-horizontal screen-padding
|
||||
:margin-vertical 12})
|
||||
|
||||
(def header-text
|
||||
(defn header-text
|
||||
[bottom-padding?]
|
||||
{:padding-horizontal screen-padding
|
||||
:padding-top 12
|
||||
:padding-bottom 8
|
||||
:padding-bottom (when bottom-padding? 8)
|
||||
:color colors/white})
|
||||
|
||||
(def header-sub-text
|
||||
@@ -53,7 +54,7 @@
|
||||
:margin-top 20})
|
||||
|
||||
(def scan-qr-code-container
|
||||
{:margin-top 19})
|
||||
{:margin-top 20})
|
||||
|
||||
(def qr-view-finder
|
||||
{:margin-horizontal screen-padding
|
||||
|
||||
@@ -35,13 +35,14 @@
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style style/header-text}
|
||||
:style (style/header-text (when subtitle true))}
|
||||
title]
|
||||
[quo/text
|
||||
{:size :paragraph-1
|
||||
:weight :regular
|
||||
:style style/header-sub-text}
|
||||
subtitle]])
|
||||
(when subtitle
|
||||
[quo/text
|
||||
{:size :paragraph-1
|
||||
:weight :regular
|
||||
:style style/header-sub-text}
|
||||
subtitle])])
|
||||
|
||||
(defn get-labels-and-on-press-method
|
||||
[]
|
||||
@@ -109,21 +110,22 @@
|
||||
[white-border :bottom-right]]])
|
||||
|
||||
(defn- viewfinder
|
||||
[qr-view-finder]
|
||||
[qr-view-finder helper-text?]
|
||||
(let [layout-size (+ (:width qr-view-finder) 2)]
|
||||
[rn/view {:style (style/viewfinder-container qr-view-finder)}
|
||||
[white-square layout-size]
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :regular
|
||||
:style style/viewfinder-text}
|
||||
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)]]))
|
||||
(when helper-text?
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :regular
|
||||
:style style/viewfinder-text}
|
||||
(i18n/label :t/ensure-qr-code-is-in-focus-to-scan)])]))
|
||||
|
||||
(defn- scan-qr-code-tab
|
||||
[qr-view-finder]
|
||||
[qr-view-finder helper-text?]
|
||||
(if (and @camera-permission-granted?
|
||||
(boolean (not-empty qr-view-finder)))
|
||||
[viewfinder qr-view-finder]
|
||||
[viewfinder qr-view-finder helper-text?]
|
||||
[camera-permission-view]))
|
||||
|
||||
(defn- check-qr-code-and-navigate
|
||||
@@ -223,7 +225,7 @@
|
||||
[:<>
|
||||
[rn/view {:style style/scan-qr-code-container}]
|
||||
[qr-scan-hole-area qr-view-finder]])
|
||||
[scan-qr-code-tab @qr-view-finder]
|
||||
[scan-qr-code-tab @qr-view-finder (when subtitle true)]
|
||||
[rn/view {:style style/flex-spacer}]
|
||||
(when show-camera?
|
||||
[quo.theme/provider {:theme :light}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
(ns status-im.signals.core
|
||||
(ns status-im2.common.signals.events
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]
|
||||
[status-im.chat.models.message :as models.message]
|
||||
[status-im.ethereum.subscriptions :as ethereum.subscriptions]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.transport.message.core :as transport.message]
|
||||
[status-im.visibility-status-updates.core :as visibility-status-updates]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.common.pairing.events :as pairing]
|
||||
[status-im2.contexts.chat.messages.link-preview.events :as link-preview]
|
||||
[status-im2.contexts.chat.messages.transport.events :as messages.transport]
|
||||
[status-im2.contexts.communities.discover.events]
|
||||
[status-im2.contexts.profile.login.events :as profile.login]
|
||||
[status-im2.contexts.push-notifications.local.events :as local-notifications]
|
||||
@@ -29,64 +28,6 @@
|
||||
[{:keys [db]} peer-stats]
|
||||
{:db (assoc db :peer-stats peer-stats :peers-count (count (:peers peer-stats)))})
|
||||
|
||||
(rf/defn handle-local-pairing-signals
|
||||
[{:keys [db]} {:keys [type action data error] :as event}]
|
||||
(log/info "local pairing signal received"
|
||||
{:event event})
|
||||
(let [{:keys [account password]} data
|
||||
role (get-in db [:syncing :role])
|
||||
receiver? (= role constants/local-pairing-role-receiver)
|
||||
sender? (= role constants/local-pairing-role-sender)
|
||||
connection-success? (and (= type
|
||||
constants/local-pairing-event-connection-success)
|
||||
(= action
|
||||
constants/local-pairing-action-connect))
|
||||
error-on-pairing? (contains? constants/local-pairing-event-errors type)
|
||||
completed-pairing? (and (= type
|
||||
constants/local-pairing-event-transfer-success)
|
||||
(= action
|
||||
constants/local-pairing-action-pairing-installation))
|
||||
received-account? (and (= type
|
||||
constants/local-pairing-event-received-account)
|
||||
(= action
|
||||
constants/local-pairing-action-pairing-account)
|
||||
(and (some? account) (some? password)))
|
||||
multiaccount-data (when received-account?
|
||||
(merge account {:password password}))
|
||||
navigate-to-syncing-devices? (and (or connection-success? error-on-pairing?) receiver?)
|
||||
user-in-syncing-devices-screen? (or (= (:view-id db) :syncing-progress)
|
||||
(= (:view-id db) :syncing-progress-intro))
|
||||
user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)]
|
||||
(merge {:db (cond-> db
|
||||
connection-success?
|
||||
(assoc-in [:syncing :pairing-status] :connected)
|
||||
|
||||
received-account?
|
||||
(assoc-in [:syncing :profile] multiaccount-data)
|
||||
|
||||
error-on-pairing?
|
||||
(assoc-in [:syncing :pairing-status] :error)
|
||||
|
||||
completed-pairing?
|
||||
(assoc-in [:syncing :pairing-status] :completed))}
|
||||
(cond
|
||||
(and navigate-to-syncing-devices? (not user-in-syncing-devices-screen?))
|
||||
{:dispatch (if user-in-sign-in-intro-screen?
|
||||
[:navigate-to-within-stack [:syncing-progress-intro :sign-in-intro]]
|
||||
[:navigate-to :syncing-progress])}
|
||||
|
||||
(and completed-pairing? sender?)
|
||||
{:dispatch [:syncing/clear-states]}
|
||||
|
||||
(and completed-pairing? receiver?)
|
||||
{:dispatch [:profile.login/local-paired-user]}
|
||||
|
||||
(and error-on-pairing? (some? error))
|
||||
{:dispatch [:toasts/upsert
|
||||
{:icon :i/alert
|
||||
:icon-color colors/danger-50
|
||||
:text error}]}))))
|
||||
|
||||
(rf/defn process
|
||||
{:events [:signals/signal-received]}
|
||||
[{:keys [db] :as cofx} event-str]
|
||||
@@ -101,18 +42,18 @@
|
||||
"backup.performed" {:db (assoc-in db
|
||||
[:profile/profile :last-backup]
|
||||
(.-lastBackup event-js))}
|
||||
"envelope.sent" (transport.message/update-envelopes-status cofx
|
||||
(:ids
|
||||
(js->clj event-js
|
||||
:keywordize-keys
|
||||
true))
|
||||
:sent)
|
||||
"envelope.expired" (transport.message/update-envelopes-status cofx
|
||||
(:ids
|
||||
(js->clj event-js
|
||||
:keywordize-keys
|
||||
true))
|
||||
:not-sent)
|
||||
"envelope.sent" (messages.transport/update-envelopes-status cofx
|
||||
(:ids
|
||||
(js->clj event-js
|
||||
:keywordize-keys
|
||||
true))
|
||||
:sent)
|
||||
"envelope.expired" (messages.transport/update-envelopes-status cofx
|
||||
(:ids
|
||||
(js->clj event-js
|
||||
:keywordize-keys
|
||||
true))
|
||||
:not-sent)
|
||||
"message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js
|
||||
:keywordize-keys
|
||||
true)]
|
||||
@@ -126,9 +67,9 @@
|
||||
"discovery.summary" (summary cofx (js->clj event-js :keywordize-keys true))
|
||||
"mediaserver.started" {:db (assoc db :mediaserver/port (.-port event-js))}
|
||||
"wakuv2.peerstats" (wakuv2-peer-stats cofx (js->clj event-js :keywordize-keys true))
|
||||
"messages.new" (transport.message/sanitize-messages-and-process-response cofx
|
||||
event-js
|
||||
true)
|
||||
"messages.new" (messages.transport/sanitize-messages-and-process-response cofx
|
||||
event-js
|
||||
true)
|
||||
"wallet" (ethereum.subscriptions/new-wallet-event cofx
|
||||
(js->clj event-js
|
||||
:keywordize-keys
|
||||
@@ -141,7 +82,7 @@
|
||||
"status.updates.timedout" (visibility-status-updates/handle-visibility-status-updates
|
||||
cofx
|
||||
(js->clj event-js :keywordize-keys true))
|
||||
"localPairing" (handle-local-pairing-signals
|
||||
"localPairing" (pairing/handle-local-pairing-signals
|
||||
cofx
|
||||
(js->clj event-js :keywordize-keys true))
|
||||
"curated.communities.update" (rf/dispatch [:fetched-contract-communities
|
||||
@@ -44,8 +44,8 @@
|
||||
(when chat-id
|
||||
(if-not (own-public-key? db chat-id)
|
||||
{:dispatch [:chat.ui/start-chat chat-id]}
|
||||
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/can-not-add-yourself)}})))
|
||||
{:effects.utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||
:content (i18n/label :t/can-not-add-yourself)}})))
|
||||
|
||||
(rf/defn handle-community-requests
|
||||
[cofx {:keys [community-id]}]
|
||||
|
||||
@@ -372,7 +372,9 @@
|
||||
;; wallet
|
||||
(def ^:const mainnet-chain-id 1)
|
||||
(def ^:const optimism-chain-id 10)
|
||||
(def ^:const optimism-test-chain-id 420)
|
||||
(def ^:const arbitrum-chain-id 42161)
|
||||
(def ^:const arbitrum-test-chain-id 421613)
|
||||
(def ^:const goerli-chain-id 5)
|
||||
|
||||
(def ^:const mainnet-short-name "eth")
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
(ns status-im2.contexts.add-new-contact.effects
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[status-im.ethereum.ens :as ens]
|
||||
[status-im2.constants :as constants]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(rf/reg-fx :effects.contacts/decompress-public-key
|
||||
(fn [{:keys [compressed-key on-success on-error]}]
|
||||
(native-module/compressed-key->public-key
|
||||
compressed-key
|
||||
constants/deserialization-key
|
||||
(fn [resp]
|
||||
(let [{:keys [error]} (transforms/json->clj resp)]
|
||||
(if error
|
||||
(on-error error)
|
||||
(on-success (str "0x" (subs resp 5)))))))))
|
||||
|
||||
(rf/reg-fx :effects.contacts/resolve-public-key-from-ens
|
||||
(fn [{:keys [chain-id ens on-success on-error]}]
|
||||
(ens/pubkey chain-id ens on-success on-error)))
|
||||
@@ -1,17 +1,13 @@
|
||||
(ns status-im2.contexts.add-new-contact.events
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ethereum.ens :as ens]
|
||||
[status-im2.constants :as constants]
|
||||
status-im2.contexts.add-new-contact.effects
|
||||
[status-im2.contexts.contacts.events :as data-store.contacts]
|
||||
[status-im2.navigation.events :as navigation]
|
||||
[utils.ens.stateofus :as stateofus]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.string :as utils.string]
|
||||
[utils.transforms :as transforms]
|
||||
[utils.validators :as validators]))
|
||||
|
||||
(defn init-contact
|
||||
@@ -108,14 +104,14 @@
|
||||
:empty {:db (dissoc db :contacts/new-identity)}
|
||||
(:valid :invalid) {:db (assoc db :contacts/new-identity contact)}
|
||||
:decompress-key {:db (assoc db :contacts/new-identity contact)
|
||||
:contacts/decompress-public-key
|
||||
:effects.contacts/decompress-public-key
|
||||
{:compressed-key id
|
||||
:on-success
|
||||
(dispatcher :contacts/set-new-identity-success input)
|
||||
:on-error
|
||||
(dispatcher :contacts/set-new-identity-error input)}}
|
||||
:resolve-ens {:db (assoc db :contacts/new-identity contact)
|
||||
:contacts/resolve-public-key-from-ens
|
||||
:effects.contacts/resolve-public-key-from-ens
|
||||
{:chain-id (chain/chain-id db)
|
||||
:ens ens
|
||||
:on-success
|
||||
@@ -123,22 +119,7 @@
|
||||
:on-error
|
||||
(dispatcher :contacts/set-new-identity-error input)}})))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:contacts/decompress-public-key
|
||||
(fn [{:keys [compressed-key on-success on-error]}]
|
||||
(native-module/compressed-key->public-key
|
||||
compressed-key
|
||||
constants/deserialization-key
|
||||
(fn [resp]
|
||||
(let [{:keys [error]} (transforms/json->clj resp)]
|
||||
(if error
|
||||
(on-error error)
|
||||
(on-success (str "0x" (subs resp 5)))))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:contacts/resolve-public-key-from-ens
|
||||
(fn [{:keys [chain-id ens on-success on-error]}]
|
||||
(ens/pubkey chain-id ens on-success on-error)))
|
||||
|
||||
(rf/defn build-contact
|
||||
{:events [:contacts/build-contact]}
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
:ens ens-stateofus-eth
|
||||
:public-key nil ; not yet...
|
||||
:state :resolve-ens}))
|
||||
:contacts/resolve-public-key-from-ens
|
||||
:effects.contacts/resolve-public-key-from-ens
|
||||
{:chain-id 1
|
||||
:ens ens-stateofus-eth
|
||||
:on-success [:contacts/set-new-identity-success ens]
|
||||
@@ -131,7 +131,7 @@
|
||||
:type :compressed-key
|
||||
:public-key nil ; not yet...
|
||||
:state :decompress-key}))
|
||||
:contacts/decompress-public-key
|
||||
:effects.contacts/decompress-public-key
|
||||
{:compressed-key user-ckey
|
||||
:on-success [:contacts/set-new-identity-success user-ckey]
|
||||
:on-error [:contacts/set-new-identity-error user-ckey]}})))
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
(ns status-im2.contexts.add-new-contact.scan.scan-profile-qr-page
|
||||
(:require [react-native.core :as rn]
|
||||
[react-native.hooks :as hooks]
|
||||
[status-im2.common.scan-qr-code.view :as scan-qr-code]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(defn- f-internal-view
|
||||
[]
|
||||
(let [{:keys [keyboard-shown]} (hooks/use-keyboard)]
|
||||
[:<>
|
||||
(when keyboard-shown
|
||||
(rn/dismiss-keyboard!))
|
||||
[scan-qr-code/view
|
||||
{:title (i18n/label :t/scan-qr)
|
||||
:on-success-scan #(debounce/debounce-and-dispatch [:contacts/set-new-identity % %] 300)}]]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
[:f> f-internal-view])
|
||||
@@ -4,7 +4,6 @@
|
||||
[react-native.clipboard :as clipboard]
|
||||
[react-native.core :as rn]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.qr-scanner.core :as qr-scanner]
|
||||
[status-im2.contexts.add-new-contact.style :as style]
|
||||
[utils.address :as address]
|
||||
[utils.debounce :as debounce]
|
||||
@@ -96,8 +95,7 @@
|
||||
{:type :outline
|
||||
:icon-only? true
|
||||
:size 40
|
||||
:on-press #(rf/dispatch [::qr-scanner/scan-code
|
||||
{:handler :contacts/qr-code-scanned}])}
|
||||
:on-press #(rf/dispatch [:open-modal :scan-profile-qr-code])}
|
||||
:i/scan]]])
|
||||
(finally
|
||||
(rf/dispatch [:contacts/clear-new-identity]))))
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[react-native.platform :as platform]
|
||||
[react-native.reanimated :as reanimated]
|
||||
[reagent.core :as reagent]
|
||||
[status-im2.common.alert.events :as alert]
|
||||
[status-im2.common.alert.effects :as alert.effects]
|
||||
[status-im2.common.device-permissions :as device-permissions]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.chat.composer.actions.style :as style]
|
||||
@@ -146,7 +146,7 @@
|
||||
:on-denied
|
||||
#(js/setTimeout
|
||||
(fn []
|
||||
(alert/show-popup
|
||||
(alert.effects/show-popup
|
||||
(i18n/label :t/audio-recorder-error)
|
||||
(i18n/label
|
||||
:t/audio-recorder-permissions-error)
|
||||
@@ -198,9 +198,9 @@
|
||||
(reanimated/get-shared-value height)])
|
||||
(rf/dispatch [:open-modal :photo-selector {:insets insets}]))
|
||||
:on-denied (fn []
|
||||
(alert/show-popup (i18n/label :t/error)
|
||||
(i18n/label
|
||||
:t/external-storage-denied)))}))
|
||||
(alert.effects/show-popup (i18n/label :t/error)
|
||||
(i18n/label
|
||||
:t/external-storage-denied)))}))
|
||||
|
||||
(defn image-button
|
||||
[props animations insets edit]
|
||||
@@ -246,6 +246,6 @@
|
||||
[:f> send-button props state animations window-height images edit send-btn-opacity
|
||||
scroll-to-bottom-fn]
|
||||
(when (and (not edit) (not images))
|
||||
;; TODO(alwx): needs to be replaced with an `audio-button` later.
|
||||
;; See https://github.com/status-im/status-mobile/issues/16084 for more details.
|
||||
;; TODO(alwx): needs to be replaced with an `audio-button` later. See
|
||||
;; https://github.com/status-im/status-mobile/issues/16084 for more details.
|
||||
[:f> disabled-audio-button audio-btn-opacity])]))
|
||||
|
||||
@@ -35,29 +35,25 @@
|
||||
(let [cleared (set (get-in db [:chat/link-previews :cleared]))]
|
||||
(when (or (empty? urls)
|
||||
(not= (set urls) cleared))
|
||||
(let [cache (get-in db [:chat/link-previews :cache])
|
||||
previews (urls->previews cache urls)
|
||||
new-urls (->> previews
|
||||
(filter :loading?)
|
||||
(map :url))
|
||||
status-link-preview? #(string/includes? % "status.app")
|
||||
status-link-urls (->> urls
|
||||
(filter status-link-preview?))
|
||||
(let [cache (get-in db [:chat/link-previews :cache])
|
||||
previews (urls->previews cache urls)
|
||||
new-urls (->> previews
|
||||
(filter :loading?)
|
||||
(map :url))
|
||||
;; `request-id` is a must because we need to process only the last
|
||||
;; unfurling event, as well as avoid needlessly updating the app db
|
||||
;; if the user changes the URLs in the input text when there are
|
||||
;; in-flight RPC requests.
|
||||
request-id
|
||||
(new-request-id)]
|
||||
request-id (new-request-id)]
|
||||
(merge {:db (-> db
|
||||
(assoc-in [:chat/link-previews :unfurled] previews)
|
||||
(assoc-in [:chat/link-previews :request-id] request-id)
|
||||
(update :chat/link-previews dissoc :cleared))}
|
||||
(when (or (seq status-link-urls) (seq new-urls))
|
||||
(when (seq new-urls)
|
||||
(log/debug "Unfurling URLs" {:urls new-urls :request-id request-id})
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_unfurlURLs"
|
||||
:params [(concat new-urls status-link-urls)]
|
||||
:params [new-urls]
|
||||
:on-success #(rf/dispatch [:link-preview/unfurl-parsed-urls-success request-id %])
|
||||
:on-error #(rf/dispatch [:link-preview/unfurl-parsed-urls-error request-id
|
||||
%])}]}))))))
|
||||
@@ -86,22 +82,17 @@
|
||||
|
||||
(rf/defn unfurl-parsed-urls-success
|
||||
{:events [:link-preview/unfurl-parsed-urls-success]}
|
||||
[{:keys [db]} request-id {new-previews :linkPreviews status-link-previews :statusLinkPreviews}]
|
||||
(when (or (seq status-link-previews) (= request-id (get-in db [:chat/link-previews :request-id])))
|
||||
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
|
||||
status-link-previews (map data-store.messages/<-status-link-previews-rpc
|
||||
status-link-previews)
|
||||
curr-previews (get-in db [:chat/link-previews :unfurled])
|
||||
indexed-new-previews (utils.collection/index-by :url new-previews)
|
||||
indexed-status-link-previews (utils.collection/index-by :url status-link-previews)]
|
||||
[{:keys [db]} request-id {new-previews :linkPreviews}]
|
||||
(when (= request-id (get-in db [:chat/link-previews :request-id]))
|
||||
(let [new-previews (map data-store.messages/<-link-preview-rpc new-previews)
|
||||
curr-previews (get-in db [:chat/link-previews :unfurled])
|
||||
indexed-new-previews (utils.collection/index-by :url new-previews)]
|
||||
(log/debug "URLs unfurled"
|
||||
{:event :link-preview/unfurl-parsed-urls-success
|
||||
:previews (map #(update % :thumbnail dissoc :data-uri) new-previews)
|
||||
:request-id request-id})
|
||||
{:db (-> db
|
||||
(update-in [:chat/link-previews :unfurled] reconcile-unfurled indexed-new-previews)
|
||||
(assoc-in [:chat/status-link-previews :unfurled]
|
||||
status-link-previews)
|
||||
(update-in [:chat/link-previews :cache]
|
||||
merge
|
||||
indexed-new-previews
|
||||
@@ -139,12 +130,3 @@
|
||||
{:db (-> db
|
||||
(update :chat/link-previews dissoc :unfurled :request-id)
|
||||
(assoc-in [:chat/link-previews :cleared] unfurled-urls))}))
|
||||
|
||||
(rf/defn clear-status-link-previews
|
||||
{:events [:status-link-preview/clear]}
|
||||
[{:keys [db]}]
|
||||
(let [unfurled-urls (set (map :url (get-in db [:chat/status-link-previews :unfurled])))]
|
||||
{:db (-> db
|
||||
(update :chat/status-link-previews dissoc :unfurled)
|
||||
(assoc-in [:chat/status-link-previews :cleared] unfurled-urls))}))
|
||||
|
||||
|
||||
@@ -20,37 +20,26 @@
|
||||
|
||||
(defn f-view
|
||||
[]
|
||||
(let [previews (rf/sub [:chats/link-previews-unfurled])
|
||||
status-link-previews (rf/sub [:chats/status-link-previews-unfurled])
|
||||
height (use-animated-height (boolean (or (seq status-link-previews)
|
||||
(seq previews))))]
|
||||
(let [previews (rf/sub [:chats/link-previews-unfurled])
|
||||
height (use-animated-height (boolean (seq previews)))]
|
||||
[reanimated/view
|
||||
{:style (reanimated/apply-animations-to-style {:height height} {:z-index 1})}
|
||||
[quo/url-preview-list
|
||||
{:key-fn :url
|
||||
:preview-width (- (:width (rn/get-window))
|
||||
(* 2 style/padding-horizontal))
|
||||
:container-style (when (or (seq status-link-previews) (seq previews)) style/preview-list)
|
||||
:container-style (when (seq previews) style/preview-list)
|
||||
:container-style-item {:height style/preview-height}
|
||||
:horizontal-spacing style/padding-horizontal
|
||||
:loading-message (i18n/label :t/link-preview-loading-message)
|
||||
:on-clear #(do
|
||||
(rf/dispatch [:status-link-preview/clear])
|
||||
(rf/dispatch [:link-preview/clear]))
|
||||
:data (map (fn [{:keys [title thumbnail hostname loading? url community]}]
|
||||
(if (seq community)
|
||||
(let [{:keys [display-name banner]} community]
|
||||
{:title display-name
|
||||
:body "status.app"
|
||||
:loading? loading?
|
||||
:thumbnail (:data-uri banner)
|
||||
:url url})
|
||||
{:title title
|
||||
:body hostname
|
||||
:loading? loading?
|
||||
:thumbnail (:data-uri thumbnail)
|
||||
:url url}))
|
||||
(set (concat previews status-link-previews)))}]]))
|
||||
:on-clear #(rf/dispatch [:link-preview/clear])
|
||||
:data (map (fn [{:keys [title thumbnail hostname loading? url]}]
|
||||
{:title title
|
||||
:body hostname
|
||||
:loading? loading?
|
||||
:thumbnail (:data-uri thumbnail)
|
||||
:url url})
|
||||
previews)}]]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
(ns status-im2.contexts.chat.effects
|
||||
(:require
|
||||
[react-native.async-storage :as async-storage]
|
||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.chat/open-last-chat
|
||||
(fn [key-uid]
|
||||
(async-storage/get-item
|
||||
:chat-id
|
||||
(fn [chat-id]
|
||||
(when chat-id
|
||||
(async-storage/get-item
|
||||
:key-uid
|
||||
(fn [stored-key-uid]
|
||||
(when (= stored-key-uid key-uid)
|
||||
(rf/dispatch [:chat/navigate-to-chat chat-id
|
||||
shell.constants/open-screen-without-animation])))))))))
|
||||
@@ -3,7 +3,6 @@
|
||||
[clojure.set :as set]
|
||||
[quo.foundations.colors :as colors]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.async-storage :as async-storage]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.chat.models.loading :as loading]
|
||||
[status-im.data-store.chats :as chats-store]
|
||||
@@ -11,11 +10,11 @@
|
||||
[status-im2.config :as config]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.chat.composer.link-preview.events :as link-preview]
|
||||
status-im2.contexts.chat.effects
|
||||
[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.list.state :as chat.state]
|
||||
[status-im2.contexts.contacts.events :as contacts-store]
|
||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]
|
||||
[status-im2.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.datetime :as datetime]
|
||||
@@ -172,11 +171,11 @@
|
||||
(chat.state/reset-visible-item)
|
||||
(rf/merge cofx
|
||||
(merge
|
||||
{:db (-> db
|
||||
(dissoc :current-chat-id)
|
||||
(assoc-in [:chat/inputs chat-id :focused?] false))
|
||||
:async-storage-set {:chat-id nil
|
||||
:key-uid nil}}
|
||||
{:db (-> db
|
||||
(dissoc :current-chat-id)
|
||||
(assoc-in [:chat/inputs chat-id :focused?] false))
|
||||
:effects.async-storage/set {:chat-id nil
|
||||
:key-uid nil}}
|
||||
(let [community-id (get-in db [:chats chat-id :community-id])]
|
||||
;; When navigating back from community chat to community, update switcher card
|
||||
;; A close chat event is also called while opening any chat.
|
||||
@@ -431,21 +430,7 @@
|
||||
[{:keys [db]} value]
|
||||
{:db (assoc db :lightbox/scale value)})
|
||||
|
||||
(re-frame/reg-fx
|
||||
:chat/open-last-chat
|
||||
(fn [key-uid]
|
||||
(async-storage/get-item
|
||||
:chat-id
|
||||
(fn [chat-id]
|
||||
(when chat-id
|
||||
(async-storage/get-item
|
||||
:key-uid
|
||||
(fn [stored-key-uid]
|
||||
(when (= stored-key-uid key-uid)
|
||||
(re-frame/dispatch [:chat/navigate-to-chat chat-id
|
||||
shell.constants/open-screen-without-animation])))))))))
|
||||
|
||||
(rf/defn check-last-chat
|
||||
{:events [:chat/check-last-chat]}
|
||||
[{:keys [db]}]
|
||||
{:chat/open-last-chat (get-in db [:profile/profile :key-uid])})
|
||||
{:effects.chat/open-last-chat (get-in db [:profile/profile :key-uid])})
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
(ns status-im2.contexts.chat.menus.pinned-messages.style
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]))
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.platform :as platform]))
|
||||
|
||||
(defn heading
|
||||
[community?]
|
||||
{:margin-horizontal 20
|
||||
:margin-bottom (when-not community? 24)})
|
||||
{:padding-horizontal 20
|
||||
:margin-bottom (when-not community? 12)})
|
||||
|
||||
(defn heading-container
|
||||
[]
|
||||
@@ -31,23 +32,28 @@
|
||||
:margin-right 8
|
||||
:color (colors/theme-colors colors/neutral-60 colors/neutral-20)})
|
||||
|
||||
(defn list-footer
|
||||
[bottom-inset]
|
||||
{:height bottom-inset})
|
||||
|
||||
(defn no-pinned-messages-container
|
||||
[bottom-inset]
|
||||
(def no-pinned-messages-container
|
||||
{:justify-content :center
|
||||
:align-items :center
|
||||
:margin-top 20
|
||||
:margin-bottom bottom-inset})
|
||||
:margin 12
|
||||
:margin-bottom (when platform/android? 12)})
|
||||
|
||||
(def no-pinned-messages-icon
|
||||
{:width 120
|
||||
:height 120
|
||||
{:width 80
|
||||
:height 80
|
||||
:justify-content :center
|
||||
:align-items :center
|
||||
:border-width 1})
|
||||
|
||||
(def no-pinned-messages-content
|
||||
{:margin-top 12})
|
||||
|
||||
(def no-pinned-messages-title
|
||||
{:text-align :center})
|
||||
|
||||
(def no-pinned-messages-text
|
||||
{:margin-top 20})
|
||||
{:text-align :center
|
||||
:margin-top 2})
|
||||
|
||||
(def list-footer
|
||||
{:height (when platform/android? 12)})
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[react-native.core :as rn]
|
||||
[react-native.fast-image :as fast-image]
|
||||
[react-native.gesture :as gesture]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im2.contexts.chat.menus.pinned-messages.style :as style]
|
||||
[status-im2.contexts.chat.messages.content.view :as message]
|
||||
[utils.i18n :as i18n]
|
||||
@@ -24,6 +23,25 @@
|
||||
[message _ _ context]
|
||||
[message/message message context (atom false)])
|
||||
|
||||
(defn empty-pinned-messages-state
|
||||
[{:keys [community?]}]
|
||||
[rn/view {:style style/no-pinned-messages-container}
|
||||
[rn/view {:style style/no-pinned-messages-icon}
|
||||
[quo/icon :i/placeholder]]
|
||||
[rn/view {:style style/no-pinned-messages-content}
|
||||
[quo/text
|
||||
{:size :paragraph-1
|
||||
:weight :semi-bold
|
||||
:style style/no-pinned-messages-title}
|
||||
(i18n/label :t/no-pinned-messages)]
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:style style/no-pinned-messages-text}
|
||||
(i18n/label
|
||||
(if community?
|
||||
:t/no-pinned-messages-community-desc
|
||||
:t/no-pinned-messages-desc))]]])
|
||||
|
||||
(defn pinned-messages
|
||||
[chat-id]
|
||||
(let [pinned (rf/sub [:chats/pinned-sorted-list chat-id])
|
||||
@@ -31,10 +49,10 @@
|
||||
current-chat (rf/sub [:chat-by-id chat-id])
|
||||
{:keys [community-id]} current-chat
|
||||
community (rf/sub [:communities/community community-id])
|
||||
bottom-inset (safe-area/get-bottom)
|
||||
community-images (rf/sub [:community/images community-id])]
|
||||
[gesture/scroll-view
|
||||
{:accessibility-label :pinned-messages-menu}
|
||||
{:accessibility-label :pinned-messages-menu
|
||||
:bounces false}
|
||||
[:<>
|
||||
[quo/text
|
||||
{:size :heading-2
|
||||
@@ -61,18 +79,8 @@
|
||||
{:data pinned
|
||||
:render-data render-data
|
||||
:render-fn message-render-fn
|
||||
:footer [rn/view {:style (style/list-footer bottom-inset)}]
|
||||
:footer [rn/view {:style style/list-footer}]
|
||||
:key-fn list-key-fn
|
||||
:separator [quo/separator {:style {:margin-vertical 8}}]}]
|
||||
[rn/view {:style (style/no-pinned-messages-container bottom-inset)}
|
||||
[rn/view {:style style/no-pinned-messages-icon}
|
||||
[quo/icon :i/placeholder]]
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:style style/no-pinned-messages-text}
|
||||
(i18n/label :t/no-pinned-messages)]
|
||||
[quo/text {:size :paragraph-2}
|
||||
(i18n/label
|
||||
(if community
|
||||
:t/no-pinned-messages-community-desc
|
||||
:t/no-pinned-messages-desc))]])]))
|
||||
[empty-pinned-messages-state
|
||||
{:community? (boolean community)}])]))
|
||||
|
||||
@@ -13,32 +13,15 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [chat-id message-id]}]
|
||||
(let [previews (rf/sub [:chats/message-link-previews chat-id message-id])
|
||||
status-link-previews (rf/sub [:chats/message-status-link-previews chat-id message-id])]
|
||||
(when (or (seq status-link-previews)
|
||||
(seq previews))
|
||||
(let [previews (rf/sub [:chats/message-link-previews chat-id message-id])]
|
||||
(when (seq previews)
|
||||
[:<>
|
||||
(for [{:keys [url title description thumbnail hostname community]}
|
||||
(concat status-link-previews previews)]
|
||||
(for [{:keys [url title description thumbnail hostname]} previews]
|
||||
^{:key url}
|
||||
(if community
|
||||
(let [{community-description :description
|
||||
community-icon :icon
|
||||
community-banner :banner
|
||||
community-name :display-name
|
||||
members-count :members-count} community]
|
||||
[quo/status-link-preview-community
|
||||
{:description community-description
|
||||
:members-count members-count
|
||||
:title community-name
|
||||
:banner (:url community-banner)
|
||||
:icon (:url community-icon)
|
||||
:link url
|
||||
:on-press #(rf/dispatch [:universal-links/handle-url url])}])
|
||||
[quo/link-preview
|
||||
{:title title
|
||||
:description description
|
||||
:link hostname
|
||||
:thumbnail (:url thumbnail)
|
||||
:thumbnail-size (when (nearly-square? thumbnail) :large)
|
||||
:container-style {:margin-top 8}}]))])))
|
||||
[quo/link-preview
|
||||
{:title title
|
||||
:description description
|
||||
:link hostname
|
||||
:thumbnail (:url thumbnail)
|
||||
:thumbnail-size (when (nearly-square? thumbnail) :large)
|
||||
:container-style {:margin-top 8}}])])))
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
(defn- on-press
|
||||
[{:keys [own message-id emoji-id emoji-reaction-id]}]
|
||||
(if own
|
||||
(rf/dispatch [:models.reactions/send-emoji-reaction-retraction
|
||||
{:message-id message-id
|
||||
:emoji-id emoji-id
|
||||
:emoji-reaction-id emoji-reaction-id}])
|
||||
(rf/dispatch [:models.reactions/send-emoji-reaction
|
||||
(rf/dispatch [:reactions/send-emoji-reaction-retraction emoji-reaction-id])
|
||||
(rf/dispatch [:reactions/send-emoji-reaction
|
||||
{:message-id message-id
|
||||
:emoji-id emoji-id}])))
|
||||
|
||||
|
||||
@@ -192,11 +192,8 @@
|
||||
:on-press
|
||||
(fn []
|
||||
(if emoji-reaction-id
|
||||
(rf/dispatch [:models.reactions/send-emoji-reaction-retraction
|
||||
{:message-id message-id
|
||||
:emoji-id id
|
||||
:emoji-reaction-id emoji-reaction-id}])
|
||||
(rf/dispatch [:models.reactions/send-emoji-reaction
|
||||
(rf/dispatch [:reactions/send-emoji-reaction-retraction emoji-reaction-id])
|
||||
(rf/dispatch [:reactions/send-emoji-reaction
|
||||
{:message-id message-id
|
||||
:emoji-id id}]))
|
||||
(rf/dispatch [:hide-bottom-sheet]))}])]))
|
||||
|
||||
+58
-1
@@ -1,5 +1,6 @@
|
||||
(ns ^{:doc "Definition of the StatusMessage protocol"} status-im.transport.message.core
|
||||
(ns status-im2.contexts.chat.messages.transport.events
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[status-im.browser.core :as browser]
|
||||
[status-im.chat.models.message :as models.message]
|
||||
@@ -20,6 +21,7 @@
|
||||
[status-im2.contexts.chat.messages.pin.events :as messages.pin]
|
||||
[status-im2.contexts.contacts.events :as models.contact]
|
||||
[status-im2.contexts.shell.activity-center.events :as activity-center]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn process-next
|
||||
@@ -347,3 +349,58 @@
|
||||
cofx
|
||||
(conj set-hash-fxs
|
||||
#(sanitize-messages-and-process-response % response-js false)))))
|
||||
|
||||
(defn- link-preview->rpc
|
||||
[preview]
|
||||
(update preview
|
||||
:thumbnail
|
||||
(fn [thumbnail]
|
||||
(set/rename-keys thumbnail {:data-uri :dataUri}))))
|
||||
|
||||
(defn build-message
|
||||
[msg]
|
||||
(-> msg
|
||||
(update :link-previews #(map link-preview->rpc %))
|
||||
(set/rename-keys
|
||||
{:album-id :albumId
|
||||
:audio-duration-ms :audioDurationMs
|
||||
:audio-path :audioPath
|
||||
:chat-id :chatId
|
||||
:community-id :communityId
|
||||
:content-type :contentType
|
||||
:ens-name :ensName
|
||||
:image-height :imageHeight
|
||||
:image-path :imagePath
|
||||
:image-width :imageWidth
|
||||
:link-previews :linkPreviews
|
||||
:response-to :responseTo
|
||||
:sticker :sticker
|
||||
:text :text})))
|
||||
|
||||
(rf/defn send-chat-messages
|
||||
[_ messages]
|
||||
{:json-rpc/call [{:method "wakuext_sendChatMessages"
|
||||
:params [(mapv build-message messages)]
|
||||
:js-response true
|
||||
:on-success #(rf/dispatch [:transport/message-sent %])
|
||||
:on-error #(do
|
||||
(log/warn "failed to send a message" %)
|
||||
(js/alert (str "failed to send a message: " %)))}]})
|
||||
|
||||
(rf/defn send-emoji-reaction
|
||||
{:events [:reactions/send-emoji-reaction]}
|
||||
[{{:keys [current-chat-id]} :db} {:keys [message-id emoji-id]}]
|
||||
{:json-rpc/call [{:method "wakuext_sendEmojiReaction"
|
||||
:params [current-chat-id message-id emoji-id]
|
||||
:js-response true
|
||||
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to send a reaction" %)}]})
|
||||
|
||||
(rf/defn send-retract-emoji-reaction
|
||||
{:events [:reactions/send-emoji-reaction-retraction]}
|
||||
[_ emoji-reaction-id]
|
||||
{:json-rpc/call [{:method "wakuext_sendEmojiReactionRetraction"
|
||||
:params [emoji-reaction-id]
|
||||
:js-response true
|
||||
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %])
|
||||
:on-error #(log/error "failed to send a reaction retraction" %)}]})
|
||||
@@ -0,0 +1,94 @@
|
||||
(ns status-im2.contexts.chat.photo-selector.effects
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[react-native.cameraroll :as cameraroll]
|
||||
[react-native.core :as rn]
|
||||
[react-native.image-resizer :as image-resizer]
|
||||
[react-native.permissions :as permissions]
|
||||
[react-native.platform :as platform]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def ^:private maximum-image-size-px 2000)
|
||||
|
||||
(rf/reg-fx :effects.camera-roll/request-permissions-and-get-photos
|
||||
(fn [[num end-cursor album]]
|
||||
(permissions/request-permissions
|
||||
{:permissions [:read-external-storage]
|
||||
:on-allowed
|
||||
(fn []
|
||||
(cameraroll/get-photos
|
||||
(merge {:first num
|
||||
:assetType "Photos"
|
||||
:groupTypes (if (= album (i18n/label :t/recent)) "All" "Albums")
|
||||
:groupName (if (not= album (i18n/label :t/recent)) album "")
|
||||
:include ["imageSize"]}
|
||||
(when end-cursor
|
||||
{:after end-cursor}))
|
||||
#(rf/dispatch [:on-camera-roll-get-photos (:edges %) (:page_info %) end-cursor])))})))
|
||||
|
||||
(defn- resize-photo
|
||||
[uri callback]
|
||||
(rn/image-get-size
|
||||
uri
|
||||
(fn [width height]
|
||||
(let [resize? (> (max width height) maximum-image-size-px)]
|
||||
(image-resizer/resize
|
||||
uri
|
||||
(if resize? maximum-image-size-px width)
|
||||
(if resize? maximum-image-size-px height)
|
||||
60
|
||||
(fn [^js resized-image]
|
||||
(let [path (.-path resized-image)
|
||||
path (if (string/starts-with? path "file") path (str "file://" path))]
|
||||
(callback {:resized-uri path
|
||||
:width width
|
||||
:height height})))
|
||||
#(log/error "could not resize image" %))))))
|
||||
|
||||
(rf/reg-fx :effects.camera-roll/image-selected
|
||||
(fn [[image chat-id]]
|
||||
(resize-photo (:uri image) #(rf/dispatch [:photo-selector/image-selected chat-id image %]))))
|
||||
|
||||
(defn- get-albums
|
||||
[callback]
|
||||
(let [albums (atom {:smart-album []
|
||||
:my-albums []})]
|
||||
;; Get the "recent" album first
|
||||
(cameraroll/get-photos
|
||||
{:first 1 :groupTypes "All" :assetType "Photos"}
|
||||
(fn [res-recent]
|
||||
(swap! albums assoc
|
||||
:smart-album
|
||||
{:title (i18n/label :t/recent)
|
||||
:uri (get-in (first (:edges res-recent)) [:node :image :uri])})
|
||||
;; Get albums, then loop over albums and get each one's cover (first photo)
|
||||
(cameraroll/get-albums
|
||||
{:assetType "Photos"}
|
||||
(fn [res-albums]
|
||||
(let [response-count (count res-albums)]
|
||||
(if (pos? response-count)
|
||||
(doseq [album res-albums]
|
||||
(cameraroll/get-photos
|
||||
{:first 1 :groupTypes "Albums" :groupName (:title album) :assetType "Photos"}
|
||||
(fn [res]
|
||||
(let [uri (get-in (first (:edges res)) [:node :image :uri])]
|
||||
(swap! albums update :my-albums conj (merge album {:uri uri}))
|
||||
(when (= (count (:my-albums @albums)) response-count)
|
||||
(swap! albums update :my-albums #(sort-by :title %))
|
||||
(callback @albums))))))
|
||||
(callback @albums)))))))))
|
||||
|
||||
(rf/reg-fx :effects.camera-roll/get-albums
|
||||
(fn []
|
||||
(get-albums #(rf/dispatch [:on-camera-roll-get-albums %]))))
|
||||
|
||||
(defn get-photos-count-ios-fx
|
||||
[cb]
|
||||
(cameraroll/get-photos-count-ios cb))
|
||||
|
||||
(rf/reg-fx :effects.camera-roll/get-photos-count-ios
|
||||
(fn []
|
||||
(when platform/ios?
|
||||
(get-photos-count-ios-fx #(rf/dispatch [:on-camera-roll-get-images-count-ios %])))))
|
||||
@@ -1,104 +1,10 @@
|
||||
(ns status-im2.contexts.chat.photo-selector.events
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.cameraroll :as cameraroll]
|
||||
[react-native.core :as rn]
|
||||
[react-native.image-resizer :as image-resizer]
|
||||
[react-native.permissions :as permissions]
|
||||
[react-native.platform :as platform]
|
||||
[status-im2.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
status-im2.contexts.chat.photo-selector.effects
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def maximum-image-size-px 2000)
|
||||
|
||||
(defn- resize-photo
|
||||
[uri callback]
|
||||
(rn/image-get-size
|
||||
uri
|
||||
(fn [width height]
|
||||
(let [resize? (> (max width height) maximum-image-size-px)]
|
||||
(image-resizer/resize
|
||||
uri
|
||||
(if resize? maximum-image-size-px width)
|
||||
(if resize? maximum-image-size-px height)
|
||||
60
|
||||
(fn [^js resized-image]
|
||||
(let [path (.-path resized-image)
|
||||
path (if (string/starts-with? path "file") path (str "file://" path))]
|
||||
(callback {:resized-uri path
|
||||
:width width
|
||||
:height height})))
|
||||
#(log/error "could not resize image" %))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:camera-roll-request-permissions-and-get-photos
|
||||
(fn [[num end-cursor album]]
|
||||
(permissions/request-permissions
|
||||
{:permissions [:read-external-storage]
|
||||
:on-allowed
|
||||
(fn []
|
||||
(cameraroll/get-photos
|
||||
(merge {:first num
|
||||
:assetType "Photos"
|
||||
:groupTypes (if (= album (i18n/label :t/recent)) "All" "Albums")
|
||||
:groupName (if (not= album (i18n/label :t/recent)) album "")
|
||||
:include ["imageSize"]}
|
||||
(when end-cursor
|
||||
{:after end-cursor}))
|
||||
#(re-frame/dispatch [:on-camera-roll-get-photos (:edges %) (:page_info %) end-cursor])))})))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:camera-roll-image-selected
|
||||
(fn [[image chat-id]]
|
||||
(resize-photo (:uri image) #(re-frame/dispatch [:photo-selector/image-selected chat-id image %]))))
|
||||
|
||||
(defn get-albums
|
||||
[callback]
|
||||
(let [albums (atom {:smart-album []
|
||||
:my-albums []})]
|
||||
;; Get the "recent" album first
|
||||
(cameraroll/get-photos
|
||||
{:first 1 :groupTypes "All" :assetType "Photos"}
|
||||
(fn [res-recent]
|
||||
(swap! albums assoc
|
||||
:smart-album
|
||||
{:title (i18n/label :t/recent)
|
||||
:uri (get-in (first (:edges res-recent)) [:node :image :uri])})
|
||||
;; Get albums, then loop over albums and get each one's cover (first photo)
|
||||
(cameraroll/get-albums
|
||||
{:assetType "Photos"}
|
||||
(fn [res-albums]
|
||||
(let [response-count (count res-albums)]
|
||||
(if (pos? response-count)
|
||||
(doseq [album res-albums]
|
||||
(cameraroll/get-photos
|
||||
{:first 1 :groupTypes "Albums" :groupName (:title album) :assetType "Photos"}
|
||||
(fn [res]
|
||||
(let [uri (get-in (first (:edges res)) [:node :image :uri])]
|
||||
(swap! albums update :my-albums conj (merge album {:uri uri}))
|
||||
(when (= (count (:my-albums @albums)) response-count)
|
||||
(swap! albums update :my-albums #(sort-by :title %))
|
||||
(callback @albums))))))
|
||||
(callback @albums)))))))))
|
||||
|
||||
(defn get-photos-count-ios-fx
|
||||
[cb]
|
||||
(cameraroll/get-photos-count-ios cb))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:camera-roll-get-albums
|
||||
(fn []
|
||||
(get-albums #(re-frame/dispatch [:on-camera-roll-get-albums %]))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:camera-roll-get-photos-count-ios
|
||||
(fn []
|
||||
(when platform/ios?
|
||||
(get-photos-count-ios-fx #(re-frame/dispatch [:on-camera-roll-get-images-count-ios %])))))
|
||||
|
||||
(rf/defn on-camera-roll-get-albums
|
||||
{:events [:on-camera-roll-get-albums]}
|
||||
[{:keys [db]} albums]
|
||||
@@ -113,12 +19,12 @@
|
||||
(rf/defn camera-roll-get-albums
|
||||
{:events [:photo-selector/camera-roll-get-albums]}
|
||||
[_]
|
||||
{:camera-roll-get-albums nil})
|
||||
{:effects.camera-roll/get-albums nil})
|
||||
|
||||
(rf/defn camera-roll-get-ios-photo-count
|
||||
{:events [:photo-selector/camera-roll-get-ios-photo-count]}
|
||||
[_]
|
||||
{:camera-roll-get-photos-count-ios nil})
|
||||
{:effects.camera-roll/get-photos-count-ios nil})
|
||||
|
||||
(rf/defn camera-roll-select-album
|
||||
{:events [:chat.ui/camera-roll-select-album]}
|
||||
@@ -150,9 +56,10 @@
|
||||
(rf/defn get-photos-for-selected-album
|
||||
{:events [:photo-selector/get-photos-for-selected-album]}
|
||||
[{:keys [db]} end-cursor]
|
||||
{:camera-roll-request-permissions-and-get-photos [21 end-cursor
|
||||
(or (:camera-roll/selected-album db)
|
||||
(i18n/label :t/recent))]})
|
||||
{:effects.camera-roll/request-permissions-and-get-photos
|
||||
[21 end-cursor
|
||||
(or (:camera-roll/selected-album db)
|
||||
(i18n/label :t/recent))]})
|
||||
|
||||
(rf/defn camera-roll-loading-more
|
||||
{:events [:photo-selector/camera-roll-loading-more]}
|
||||
@@ -166,4 +73,4 @@
|
||||
images (get-in db [:chat/inputs current-chat-id :metadata :sending-image])]
|
||||
(when (and (< (count images) constants/max-album-photos)
|
||||
(not (some #(= (:uri image) (:uri %)) images)))
|
||||
{:camera-roll-image-selected [image current-chat-id]})))
|
||||
{:effects.camera-roll/image-selected [image current-chat-id]})))
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
same-password-length? #(and (seq @password)
|
||||
(= (count @password) (count @repeat-password)))]
|
||||
(fn []
|
||||
(let [{user-color :color} (rf/sub [:onboarding-2/profile])
|
||||
(let [{user-color :color} (rf/sub [:onboarding/profile])
|
||||
{:keys [long-enough?]
|
||||
:as validations} (password-validations @password)
|
||||
password-strength (calc-password-strength validations)
|
||||
@@ -177,7 +177,7 @@
|
||||
{:disabled? (not meet-requirements?)
|
||||
:customization-color user-color
|
||||
:on-press #(rf/dispatch
|
||||
[:onboarding-2/password-set
|
||||
[:onboarding/password-set
|
||||
(security/mask-data @password)])}
|
||||
(i18n/label :t/password-creation-confirm)]]]]))))
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@
|
||||
:type :primary
|
||||
:customization-color @custom-color
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:onboarding-2/profile-data-set
|
||||
(rf/dispatch [:onboarding/profile-data-set
|
||||
{:image-path @profile-pic
|
||||
:display-name @full-name
|
||||
:color @custom-color}]))
|
||||
@@ -232,7 +232,7 @@
|
||||
(defn create-profile
|
||||
[]
|
||||
(let [{:keys [top]} (safe-area/get-insets)
|
||||
onboarding-profile-data (rf/sub [:onboarding-2/profile])]
|
||||
onboarding-profile-data (rf/sub [:onboarding/profile])]
|
||||
[:<>
|
||||
[:f> f-page
|
||||
{:navigation-bar-top top
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
[insets]
|
||||
(let [supported-biometric-type (rf/sub [:biometric/supported-type])
|
||||
bio-type-label (biometric/get-label-by-type supported-biometric-type)
|
||||
profile-color (or (:color (rf/sub [:onboarding-2/profile]))
|
||||
profile-color (or (:color (rf/sub [:onboarding/profile]))
|
||||
(rf/sub [:profile/customization-color]))
|
||||
syncing-results? (= :syncing-results @state/root-id)]
|
||||
[rn/view {:style (style/buttons insets)}
|
||||
@@ -36,7 +36,7 @@
|
||||
:accessibility-label :enable-biometrics-button
|
||||
:icon-left :i/face-id
|
||||
:customization-color profile-color
|
||||
:on-press #(rf/dispatch [:onboarding-2/enable-biometrics])
|
||||
:on-press #(rf/dispatch [:onboarding/enable-biometrics])
|
||||
:button-label (i18n/label :t/biometric-enable-button {:bio-type-label bio-type-label})}]
|
||||
[quo/button
|
||||
{:accessibility-label :maybe-later-button
|
||||
@@ -45,7 +45,7 @@
|
||||
:on-press #(rf/dispatch (if syncing-results?
|
||||
[:navigate-to-within-stack
|
||||
[:enable-notifications :enable-biometrics]]
|
||||
[:onboarding-2/create-account-and-login]))
|
||||
[:onboarding/create-account-and-login]))
|
||||
:container-style {:margin-top 12}}
|
||||
(i18n/label :t/maybe-later)]]))
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
(defn enable-notification-buttons
|
||||
[{:keys [insets]}]
|
||||
(let [profile-color (rf/sub [:onboarding-2/customization-color])]
|
||||
(let [profile-color (rf/sub [:onboarding/customization-color])]
|
||||
[rn/view {:style (style/buttons insets)}
|
||||
[quo/button
|
||||
{:on-press (fn []
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
(reset! seed-phrase new-phrase))
|
||||
on-submit (fn []
|
||||
(swap! seed-phrase clean-seed-phrase)
|
||||
(rf/dispatch [:onboarding-2/seed-phrase-entered
|
||||
(rf/dispatch [:onboarding/seed-phrase-entered
|
||||
(security/mask-data @seed-phrase)
|
||||
set-invalid-seed-phrase]))]
|
||||
(let [words-coll (mnemonic/passphrase->words @seed-phrase)
|
||||
|
||||
@@ -24,57 +24,57 @@
|
||||
(on-success mnemonic keyUID)))))))
|
||||
|
||||
(rf/defn profile-data-set
|
||||
{:events [:onboarding-2/profile-data-set]}
|
||||
{:events [:onboarding/profile-data-set]}
|
||||
[{:keys [db]} onboarding-data]
|
||||
{:db (update db :onboarding-2/profile merge onboarding-data)
|
||||
{:db (update db :onboarding/profile merge onboarding-data)
|
||||
:dispatch [:navigate-to-within-stack [:create-profile-password :new-to-status]]})
|
||||
|
||||
(rf/defn enable-biometrics
|
||||
{:events [:onboarding-2/enable-biometrics]}
|
||||
{:events [:onboarding/enable-biometrics]}
|
||||
[_]
|
||||
{:biometric/authenticate {:on-success #(rf/dispatch [:onboarding-2/biometrics-done])
|
||||
:on-fail #(rf/dispatch [:onboarding-2/biometrics-fail %])}})
|
||||
{:biometric/authenticate {:on-success #(rf/dispatch [:onboarding/biometrics-done])
|
||||
:on-fail #(rf/dispatch [:onboarding/biometrics-fail %])}})
|
||||
|
||||
(rf/defn navigate-to-enable-notifications
|
||||
{:events [:onboarding-2/navigate-to-enable-notifications]}
|
||||
{:events [:onboarding/navigate-to-enable-notifications]}
|
||||
[{:keys [db]}]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:db (dissoc db :onboarding-2/profile)
|
||||
{:db (dissoc db :onboarding/profile)
|
||||
:dispatch [:navigate-to-within-stack [:enable-notifications :enable-biometrics]]}))
|
||||
|
||||
(rf/defn biometrics-done
|
||||
{:events [:onboarding-2/biometrics-done]}
|
||||
{:events [:onboarding/biometrics-done]}
|
||||
[{:keys [db]}]
|
||||
(let [syncing? (get-in db [:onboarding-2/profile :syncing?])]
|
||||
{:db (assoc-in db [:onboarding-2/profile :auth-method] constants/auth-method-biometric)
|
||||
(let [syncing? (get-in db [:onboarding/profile :syncing?])]
|
||||
{:db (assoc-in db [:onboarding/profile :auth-method] constants/auth-method-biometric)
|
||||
:dispatch (if syncing?
|
||||
[:onboarding-2/finalize-setup]
|
||||
[:onboarding-2/create-account-and-login])}))
|
||||
[:onboarding/finalize-setup]
|
||||
[:onboarding/create-account-and-login])}))
|
||||
|
||||
(rf/defn biometrics-fail
|
||||
{:events [:onboarding-2/biometrics-fail]}
|
||||
{:events [:onboarding/biometrics-fail]}
|
||||
[cofx code]
|
||||
(biometric/show-message cofx code))
|
||||
|
||||
(rf/defn create-account-and-login
|
||||
{:events [:onboarding-2/create-account-and-login]}
|
||||
{:events [:onboarding/create-account-and-login]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [display-name seed-phrase password image-path color] :as profile}
|
||||
(:onboarding-2/profile db)]
|
||||
(:onboarding/profile db)]
|
||||
(rf/merge cofx
|
||||
{:dispatch [:navigate-to-within-stack [:generating-keys :new-to-status]]
|
||||
:dispatch-later [{:ms constants/onboarding-generating-keys-animation-duration-ms
|
||||
:dispatch [:onboarding-2/navigate-to-identifiers]}]
|
||||
:dispatch [:onboarding/navigate-to-identifiers]}]
|
||||
:db (-> db
|
||||
(dissoc :profile/login)
|
||||
(dissoc :auth-method)
|
||||
(assoc :onboarding-2/new-account? true))}
|
||||
(assoc :onboarding/new-account? true))}
|
||||
(if seed-phrase
|
||||
(profile.recover/recover-profile-and-login profile)
|
||||
(profile.create/create-profile-and-login profile)))))
|
||||
|
||||
(rf/defn on-delete-profile-success
|
||||
{:events [:onboarding-2/on-delete-profile-success]}
|
||||
{:events [:onboarding/on-delete-profile-success]}
|
||||
[{:keys [db]} key-uid]
|
||||
(let [multiaccounts (dissoc (:profile/profiles-overview db) key-uid)]
|
||||
(merge
|
||||
@@ -83,18 +83,18 @@
|
||||
{:set-root :intro}))))
|
||||
|
||||
(rf/defn password-set
|
||||
{:events [:onboarding-2/password-set]}
|
||||
{:events [:onboarding/password-set]}
|
||||
[{:keys [db]} password]
|
||||
(let [supported-type (:biometric/supported-type db)]
|
||||
{:db (-> db
|
||||
(assoc-in [:onboarding-2/profile :password] password)
|
||||
(assoc-in [:onboarding-2/profile :auth-method] constants/auth-method-password))
|
||||
(assoc-in [:onboarding/profile :password] password)
|
||||
(assoc-in [:onboarding/profile :auth-method] constants/auth-method-password))
|
||||
:dispatch (if supported-type
|
||||
[:navigate-to-within-stack [:enable-biometrics :new-to-status]]
|
||||
[:onboarding-2/create-account-and-login])}))
|
||||
[:onboarding/create-account-and-login])}))
|
||||
|
||||
(rf/defn navigate-to-enable-biometrics
|
||||
{:events [:onboarding-2/navigate-to-enable-biometrics]}
|
||||
{:events [:onboarding/navigate-to-enable-biometrics]}
|
||||
[{:keys [db]}]
|
||||
(let [supported-type (:biometric/supported-type db)]
|
||||
{:dispatch (if supported-type
|
||||
@@ -102,19 +102,19 @@
|
||||
[:open-modal :enable-notifications])}))
|
||||
|
||||
(rf/defn seed-phrase-entered
|
||||
{:events [:onboarding-2/seed-phrase-entered]}
|
||||
{:events [:onboarding/seed-phrase-entered]}
|
||||
[_ seed-phrase on-error]
|
||||
{:multiaccount/validate-mnemonic [seed-phrase
|
||||
(fn [mnemonic key-uid]
|
||||
(re-frame/dispatch [:onboarding-2/seed-phrase-validated
|
||||
(re-frame/dispatch [:onboarding/seed-phrase-validated
|
||||
mnemonic key-uid]))
|
||||
on-error]})
|
||||
|
||||
(rf/defn seed-phrase-validated
|
||||
{:events [:onboarding-2/seed-phrase-validated]}
|
||||
{:events [:onboarding/seed-phrase-validated]}
|
||||
[{:keys [db]} seed-phrase key-uid]
|
||||
(if (contains? (:profile/profiles-overview db) key-uid)
|
||||
{:utils/show-confirmation
|
||||
{:effects.utils/show-confirmation
|
||||
{:title (i18n/label :t/multiaccount-exists-title)
|
||||
:content (i18n/label :t/multiaccount-exists-content)
|
||||
:confirm-button-text (i18n/label :t/unlock)
|
||||
@@ -123,25 +123,25 @@
|
||||
(re-frame/dispatch
|
||||
[:profile/profile-selected key-uid]))
|
||||
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
|
||||
{:db (assoc-in db [:onboarding-2/profile :seed-phrase] seed-phrase)
|
||||
{:db (assoc-in db [:onboarding/profile :seed-phrase] seed-phrase)
|
||||
:dispatch [:navigate-to-within-stack [:create-profile :new-to-status]]}))
|
||||
|
||||
(rf/defn navigate-to-create-profile
|
||||
{:events [:onboarding-2/navigate-to-create-profile]}
|
||||
{:events [:onboarding/navigate-to-create-profile]}
|
||||
[{:keys [db]}]
|
||||
;; Restart the flow
|
||||
{:db (dissoc db :onboarding-2/profile)
|
||||
{:db (dissoc db :onboarding/profile)
|
||||
:dispatch [:navigate-to-within-stack [:create-profile :new-to-status]]})
|
||||
|
||||
(rf/defn onboarding-new-account-finalize-setup
|
||||
{:events [:onboarding-2/finalize-setup]}
|
||||
{:events [:onboarding/finalize-setup]}
|
||||
[{:keys [db]}]
|
||||
(let [masked-password (get-in db [:onboarding-2/profile :password])
|
||||
(let [masked-password (get-in db [:onboarding/profile :password])
|
||||
key-uid (get-in db [:profile/profile :key-uid])
|
||||
syncing? (get-in db [:onboarding-2/profile :syncing?])
|
||||
biometric-enabled? (= (get-in db [:onboarding-2/profile :auth-method])
|
||||
syncing? (get-in db [:onboarding/profile :syncing?])
|
||||
biometric-enabled? (= (get-in db [:onboarding/profile :auth-method])
|
||||
constants/auth-method-biometric)]
|
||||
(cond-> {:db (assoc db :onboarding-2/generated-keys? true)}
|
||||
(cond-> {:db (assoc db :onboarding/generated-keys? true)}
|
||||
biometric-enabled?
|
||||
(assoc :keychain/save-password-and-auth-method
|
||||
{:key-uid key-uid
|
||||
@@ -150,16 +150,16 @@
|
||||
(security/hash-masked-password masked-password))
|
||||
:on-success (fn []
|
||||
(if syncing?
|
||||
(rf/dispatch [:onboarding-2/navigate-to-enable-notifications])
|
||||
(rf/dispatch [:onboarding/navigate-to-enable-notifications])
|
||||
(log/error "successfully saved biometrics")))
|
||||
:on-error #(log/error "failed to save biometrics"
|
||||
{:key-uid key-uid
|
||||
:error %})}))))
|
||||
|
||||
(rf/defn navigate-to-identifiers
|
||||
{:events [:onboarding-2/navigate-to-identifiers]}
|
||||
{:events [:onboarding/navigate-to-identifiers]}
|
||||
[{:keys [db]}]
|
||||
(if (:onboarding-2/generated-keys? db)
|
||||
(if (:onboarding/generated-keys? db)
|
||||
{:dispatch [:navigate-to-within-stack [:identifiers :new-to-status]]}
|
||||
{:dispatch-later [{:ms constants/onboarding-generating-keys-navigation-retry-ms
|
||||
:dispatch [:onboarding-2/navigate-to-identifiers]}]}))
|
||||
:dispatch [:onboarding/navigate-to-identifiers]}]}))
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
drag-amount (atom nil)
|
||||
{:keys [emoji-hash display-name compressed-key
|
||||
public-key]} (rf/sub [:profile/profile])
|
||||
{:keys [color]} (rf/sub [:onboarding-2/profile])
|
||||
{:keys [color]} (rf/sub [:onboarding/profile])
|
||||
photo-path (rf/sub [:chats/photo-path public-key])
|
||||
emoji-string (string/join emoji-hash)]
|
||||
(carousel.animation/use-initialize-animation progress paused? true is-dragging? drag-amount)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
(* 2 56) ;; two other list items
|
||||
(* 2 16) ;; spacing between items
|
||||
220) ;; extra spacing (top bar)
|
||||
:on-press #(rf/dispatch [:onboarding-2/navigate-to-create-profile])}]
|
||||
:on-press #(rf/dispatch [:onboarding/navigate-to-create-profile])}]
|
||||
[rn/view {:style style/subtitle-container}
|
||||
[quo/text
|
||||
{:style style/subtitle
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
(defn view
|
||||
[in-onboarding?]
|
||||
(let [pairing-status (rf/sub [:pairing/pairing-status])
|
||||
profile-color (:color (rf/sub [:onboarding-2/profile]))]
|
||||
profile-color (:color (rf/sub [:onboarding/profile]))]
|
||||
[rn/view {:style (style/page-container in-onboarding?)}
|
||||
(when-not in-onboarding? [background/view true])
|
||||
[quo/page-nav {:type :no-title :background :blur}]
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
{:on-press (fn []
|
||||
(when on-press
|
||||
(on-press))
|
||||
(rf/dispatch [:onboarding-2/navigate-to-enable-biometrics]))
|
||||
(rf/dispatch [:onboarding/navigate-to-enable-biometrics]))
|
||||
:accessibility-label :continue-button
|
||||
:customization-color profile-color
|
||||
:container-style style/continue-button}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
(defn page-title
|
||||
[]
|
||||
(let [new-account? (rf/sub [:onboarding-2/new-account?])]
|
||||
(let [new-account? (rf/sub [:onboarding/new-account?])]
|
||||
[quo/text-combinations
|
||||
{:container-style {:margin-top 12 :margin-horizontal 20}
|
||||
:title (i18n/label (if new-account?
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [profile-color (rf/sub [:onboarding-2/customization-color])
|
||||
(let [profile-color (rf/sub [:onboarding/customization-color])
|
||||
{:keys [status-type]} (rf/sub [:multiaccount/current-user-visibility-status])
|
||||
window (rf/sub [:dimensions/window])
|
||||
insets (safe-area/get-insets)]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
(ns status-im2.contexts.profile.create.effects
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.profile/create-and-login
|
||||
(fn [request]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/create-account-and-login request)))
|
||||
@@ -1,21 +1,15 @@
|
||||
(ns status-im2.contexts.profile.create.events
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im2.contexts.profile.config :as profile.config]
|
||||
status-im2.contexts.profile.create.effects
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::create-profile-and-login
|
||||
(fn [request]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/create-account-and-login request)))
|
||||
|
||||
(rf/defn create-profile-and-login
|
||||
{:events [:profile.create/create-and-login]}
|
||||
[_ {:keys [display-name password image-path color]}]
|
||||
{::create-profile-and-login
|
||||
{:effects.profile/create-and-login
|
||||
(assoc (profile.config/create)
|
||||
:displayName display-name
|
||||
:password (native-module/sha3 (security/safe-unmask-data password))
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
{:keys [key-uid]} (first (sort-by :timestamp > (vals profiles)))]
|
||||
(rf/merge cofx
|
||||
(navigation/init-root :profiles)
|
||||
(init-profiles-overview profiles key-uid)
|
||||
(when key-uid (init-profiles-overview profiles key-uid))
|
||||
;;we check if biometric is available, and try to login with it,
|
||||
;;if succeed "node.login" signal will be triggered
|
||||
(profile.login/login-with-biometric-if-available key-uid)))
|
||||
(when key-uid (profile.login/login-with-biometric-if-available key-uid))))
|
||||
(navigation/init-root cofx :intro)))
|
||||
|
||||
(rf/defn update-setting-from-backup
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
(ns status-im2.contexts.profile.login.effects
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[status-im2.contexts.profile.config :as profile.config]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.profile/login
|
||||
(fn [[key-uid hashed-password]]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/login-account
|
||||
(assoc (profile.config/login) :keyUid key-uid :password hashed-password))))
|
||||
@@ -9,14 +9,18 @@
|
||||
[status-im.data-store.switcher-cards :as switcher-cards-store]
|
||||
[status-im.data-store.visibility-status-updates :as visibility-status-updates-store]
|
||||
[status-im.group-chats.core :as group-chats]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.mobile-sync-settings.core :as mobile-network]
|
||||
[status-im.transport.core :as transport]
|
||||
[status-im.pairing.core :as pairing]
|
||||
[status-im.stickers.core :as stickers]
|
||||
[status-im2.common.keychain.events :as keychain]
|
||||
[status-im2.common.log :as logging]
|
||||
[status-im2.common.universal-links :as universal-links]
|
||||
[status-im2.config :as config]
|
||||
[status-im2.contexts.chat.messages.link-preview.events :as link-preview]
|
||||
[status-im2.contexts.contacts.events :as contacts]
|
||||
[status-im2.contexts.profile.config :as profile.config]
|
||||
status-im2.contexts.profile.login.effects
|
||||
[status-im2.contexts.profile.rpc :as profile.rpc]
|
||||
[status-im2.contexts.profile.settings.events :as profile.settings.events]
|
||||
[status-im2.contexts.push-notifications.events :as notifications]
|
||||
@@ -27,36 +31,29 @@
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::login
|
||||
(fn [[key-uid hashed-password]]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/login-account
|
||||
(assoc (profile.config/login) :keyUid key-uid :password hashed-password))))
|
||||
|
||||
(rf/defn login
|
||||
{:events [:profile.login/login]}
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (:profile/login db)]
|
||||
{:db (assoc-in db [:profile/login :processing] true)
|
||||
::login [key-uid (native-module/sha3 (security/safe-unmask-data password))]}))
|
||||
{:db (assoc-in db [:profile/login :processing] true)
|
||||
:effects.profile/login [key-uid (native-module/sha3 (security/safe-unmask-data password))]}))
|
||||
|
||||
(rf/defn biometrics-login
|
||||
{:events [:profile.login/biometrics-login]}
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (:profile/login db)]
|
||||
{:db (assoc-in db [:profile/login :processing] true)
|
||||
::login [key-uid (security/safe-unmask-data password)]}))
|
||||
{:db (assoc-in db [:profile/login :processing] true)
|
||||
:effects.profile/login [key-uid (security/safe-unmask-data password)]}))
|
||||
|
||||
(rf/defn login-local-paired-user
|
||||
{:events [:profile.login/local-paired-user]}
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (get-in db [:syncing :profile])
|
||||
masked-password (security/mask-data password)]
|
||||
{:db (-> db
|
||||
(assoc-in [:onboarding-2/profile :password] masked-password)
|
||||
(assoc-in [:onboarding-2/profile :syncing?] true))
|
||||
::login [key-uid password]}))
|
||||
{:db (-> db
|
||||
(assoc-in [:onboarding/profile :password] masked-password)
|
||||
(assoc-in [:onboarding/profile :syncing?] true))
|
||||
:effects.profile/login [key-uid password]}))
|
||||
|
||||
(rf/defn redirect-to-root
|
||||
[{:keys [db] :as cofx}]
|
||||
@@ -66,8 +63,8 @@
|
||||
{:db (dissoc db :syncing)
|
||||
:dispatch [:init-root :syncing-results]}
|
||||
|
||||
(get db :onboarding-2/new-account?)
|
||||
{:dispatch [:onboarding-2/finalize-setup]}
|
||||
(get db :onboarding/new-account?)
|
||||
{:dispatch [:onboarding/finalize-setup]}
|
||||
|
||||
:else
|
||||
(rf/merge
|
||||
@@ -116,7 +113,10 @@
|
||||
network-id (str (get-in networks
|
||||
[current-network :config :NetworkId]))]
|
||||
(rf/merge cofx
|
||||
(cond-> {:wallet-legacy/initialize-transactions-management-enabled nil
|
||||
(cond-> {:json-rpc/call [{:method "wakuext_startMessenger"
|
||||
:on-success #(re-frame/dispatch [:messenger-started %])
|
||||
:on-error #(log/error "failed to start messenger")}]
|
||||
:wallet-legacy/initialize-transactions-management-enabled nil
|
||||
:wallet-legacy/initialize-wallet
|
||||
[network-id
|
||||
current-network-config
|
||||
@@ -128,7 +128,6 @@
|
||||
(assoc :chat/open-last-chat (get-in db [:profile/profile :key-uid]))
|
||||
notifications-enabled?
|
||||
(assoc :effects/push-notifications-enable nil))
|
||||
(transport/start-messenger)
|
||||
(contacts/initialize-contacts)
|
||||
(browser/initialize-browser)
|
||||
(mobile-network/on-network-status-change)
|
||||
@@ -139,8 +138,30 @@
|
||||
(visibility-status-updates-store/fetch-visibility-status-updates-rpc)
|
||||
(switcher-cards-store/fetch-switcher-cards-rpc))))
|
||||
|
||||
(rf/defn messenger-started
|
||||
{:events [:messenger-started]}
|
||||
[{:keys [db] :as cofx} {:keys [mailservers] :as response}]
|
||||
(log/info "Messenger started")
|
||||
(let [new-account? (get db :onboarding-2/new-account?)]
|
||||
(rf/merge cofx
|
||||
{:db (-> db
|
||||
(assoc :messenger/started? true)
|
||||
(mailserver/add-mailservers mailservers))
|
||||
:json-rpc/call [{:method "admin_nodeInfo"
|
||||
:on-success #(re-frame/dispatch [:node-info-fetched %])
|
||||
:on-error #(log/error "node-info: failed error" %)}]}
|
||||
(pairing/init)
|
||||
(stickers/load-packs)
|
||||
(when-not new-account?
|
||||
(universal-links/process-stored-event)))))
|
||||
|
||||
(rf/defn set-node-info
|
||||
{:events [:node-info-fetched]}
|
||||
[{:keys [db]} node-info]
|
||||
{:db (assoc db :node-info node-info)})
|
||||
|
||||
(rf/defn login-node-signal
|
||||
[{{:onboarding-2/keys [recovered-account? new-account?] :as db} :db :as cofx}
|
||||
[{{:onboarding/keys [recovered-account? new-account?] :as db} :db :as cofx}
|
||||
{:keys [settings account ensUsernames error]}]
|
||||
(log/debug "[signals] node.login" "error" error)
|
||||
(if error
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
key-uid
|
||||
(fn [result]
|
||||
(let [{:keys [error]} (transforms/json->clj result)]
|
||||
(rf/dispatch [:onboarding-2/on-delete-profile-success key-uid])
|
||||
(rf/dispatch [:onboarding/on-delete-profile-success key-uid])
|
||||
(log/info "profile deleted: error" error)))))}])
|
||||
|
||||
(defn show-confirmation
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
(ns status-im2.contexts.profile.recover.effects
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.profile/restore-and-login
|
||||
(fn [request]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/restore-account-and-login request)))
|
||||
@@ -1,24 +1,18 @@
|
||||
(ns status-im2.contexts.profile.recover.events
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im2.contexts.profile.config :as profile.config]
|
||||
status-im2.contexts.profile.recover.effects
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::restore-profile-and-login
|
||||
(fn [request]
|
||||
;;"node.login" signal will be triggered as a callback
|
||||
(native-module/restore-account-and-login request)))
|
||||
|
||||
(rf/defn recover-profile-and-login
|
||||
{:events [:profile.recover/recover-and-login]}
|
||||
[{:keys [db]} {:keys [display-name password image-path color seed-phrase]}]
|
||||
{:db
|
||||
(assoc db :onboarding-2/recovered-account? true)
|
||||
(assoc db :onboarding/recovered-account? true)
|
||||
|
||||
::restore-profile-and-login
|
||||
:effects.profile/restore-and-login
|
||||
(merge (profile.config/create)
|
||||
{:displayName display-name
|
||||
:mnemonic (security/safe-unmask-data seed-phrase)
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
|
||||
(defn rpc->profiles-overview
|
||||
[{:keys [customizationColor keycard-pairing] :as profile}]
|
||||
(-> profile
|
||||
(dissoc :customizationColor)
|
||||
(assoc :customization-color (keyword customizationColor))
|
||||
(assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile)))
|
||||
(assoc :keycard-pairing (when-not (string/blank? keycard-pairing) keycard-pairing))))
|
||||
(if (map? profile)
|
||||
(-> profile
|
||||
(dissoc :customizationColor)
|
||||
(assoc :customization-color (keyword customizationColor))
|
||||
(assoc :ens-name? (utils.ens/is-valid-eth-name? (:name profile)))
|
||||
(assoc :keycard-pairing (when-not (string/blank? keycard-pairing) keycard-pairing)))
|
||||
profile))
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects/push-notifications-local-present-ios
|
||||
(fn [{:keys [title message user-info body-type]}]
|
||||
(when (not= body-type "message")
|
||||
(pn-ios/present-local-notification title
|
||||
message
|
||||
(bean/->js (merge user-info
|
||||
{:notificationType
|
||||
"local-notification"}))))))
|
||||
(fn [{:keys [title message user-info body-type]}]
|
||||
(when (not= body-type "message")
|
||||
(pn-ios/present-local-notification title
|
||||
message
|
||||
(bean/->js (merge user-info
|
||||
{:notificationType
|
||||
"local-notification"}))))))
|
||||
|
||||
(rf/reg-fx :effects/push-notifications-local-present-android
|
||||
(fn [notification]
|
||||
(native-module.pn/present-local-notification notification)))
|
||||
(fn [notification]
|
||||
(native-module.pn/present-local-notification notification)))
|
||||
|
||||
@@ -145,7 +145,6 @@
|
||||
[status-im2.contexts.quo-preview.settings.settings-item :as settings-item]
|
||||
[status-im2.contexts.quo-preview.share.qr-code :as qr-code]
|
||||
[status-im2.contexts.quo-preview.share.share-qr-code :as share-qr-code]
|
||||
[status-im2.contexts.quo-preview.status-link-preview.community :as status-preview-community]
|
||||
[status-im2.contexts.quo-preview.style :as style]
|
||||
[status-im2.contexts.quo-preview.switcher.group-messaging-card :as group-messaging-card]
|
||||
[status-im2.contexts.quo-preview.switcher.switcher-cards :as switcher-cards]
|
||||
@@ -325,10 +324,7 @@
|
||||
:component url-preview-list/view}
|
||||
{:name :link-preview
|
||||
:options {:insets {:top? true}}
|
||||
:component link-preview/view}
|
||||
{:name :status-preview-community
|
||||
:options {:insets {:top true}}
|
||||
:component status-preview-community/view}]
|
||||
:component link-preview/view}]
|
||||
:list-items [{:name :account
|
||||
:component account-item/view}
|
||||
{:name :account-list-card
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[react-native.core :as rn]
|
||||
[react-native.permissions :as permissions]
|
||||
[reagent.core :as reagent]
|
||||
[status-im2.common.alert.events :as alert]
|
||||
[status-im2.common.alert.effects :as alert.effects]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.quo-preview.preview :as preview]
|
||||
[utils.i18n :as i18n]
|
||||
@@ -35,7 +35,7 @@
|
||||
:on-denied
|
||||
#(js/setTimeout
|
||||
(fn []
|
||||
(alert/show-popup
|
||||
(alert.effects/show-popup
|
||||
(i18n/label :t/audio-recorder-error)
|
||||
(i18n/label
|
||||
:t/audio-recorder-permissions-error)))
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
(ns status-im2.contexts.quo-preview.status-link-preview.community
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[reagent.core :as reagent]
|
||||
[status-im2.common.resources :as resources]
|
||||
[status-im2.contexts.quo-preview.preview :as preview]))
|
||||
|
||||
(def descriptor
|
||||
[{:type :text :key :title}
|
||||
{:type :text :key :description}
|
||||
{:type :boolean :key :loading?}
|
||||
{:type :text :key :members-count}
|
||||
{:type :text :key :active-members-count}])
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [state (reagent/atom
|
||||
{:title "Doodles"
|
||||
:description "Coloring the world with joy • ᴗ •"
|
||||
:members-count 24
|
||||
:active-members-count 12
|
||||
:link "https://status.app/community-link"
|
||||
:loading? false})]
|
||||
(fn []
|
||||
[preview/preview-container
|
||||
{:state state
|
||||
:descriptor descriptor}
|
||||
[quo/status-link-preview-community
|
||||
{:title (:title @state)
|
||||
:description (:description @state)
|
||||
:icon (resources/get-mock-image :status-logo)
|
||||
:banner (resources/get-mock-image :status-logo)
|
||||
:loading? (:loading? @state)
|
||||
:members-count (int (:members-count @state))
|
||||
:loading-message (:loading-message @state)
|
||||
:active-members-count (int (:active-members-count @state))
|
||||
:on-clear #(js/alert "Clear button pressed")}]])))
|
||||
@@ -0,0 +1,32 @@
|
||||
(ns status-im2.contexts.shell.jump-to.effects
|
||||
(:require
|
||||
[status-im2.config :as config]
|
||||
[status-im2.contexts.shell.jump-to.animation :as animation]
|
||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]
|
||||
[status-im2.contexts.shell.jump-to.state :as state]
|
||||
[status-im2.contexts.shell.jump-to.utils :as shell.utils]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.shell/change-tab
|
||||
(fn [stack-id]
|
||||
(when (some #(= stack-id %) shell.constants/stacks-ids)
|
||||
(animation/bottom-tab-on-press stack-id false))))
|
||||
|
||||
(rf/reg-fx :effects.shell/navigate-to-jump-to
|
||||
(fn []
|
||||
(animation/close-home-stack false)
|
||||
(when-not config/shell-navigation-disabled?
|
||||
(some-> ^js @state/jump-to-list-ref
|
||||
(.scrollToOffset #js {:y 0 :animated false})))))
|
||||
|
||||
;; Note - pop-to-root resets currently opened screens to `close-screen-without-animation`.
|
||||
;; This might take some time. So don't directly merge the effect of `pop-to-root` and
|
||||
;; `navigate-to` for the floating screen. Because it might close even the currently opened screen.
|
||||
;; https://github.com/status-im/status-mobile/pull/16438#issuecomment-1623954774
|
||||
(rf/reg-fx :effects.shell/pop-to-root
|
||||
(fn []
|
||||
(shell.utils/reset-floating-screens)))
|
||||
|
||||
(rf/reg-fx :effects.shell/reset-state
|
||||
(fn []
|
||||
(reset! state/floating-screens-state {})))
|
||||
@@ -1,48 +1,15 @@
|
||||
(ns status-im2.contexts.shell.jump-to.events
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.data-store.switcher-cards :as switcher-cards-store]
|
||||
[status-im.utils.core :as utils]
|
||||
[status-im2.config :as config]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.shell.jump-to.animation :as animation]
|
||||
[status-im2.contexts.shell.jump-to.constants :as shell.constants]
|
||||
[status-im2.contexts.shell.jump-to.state :as state]
|
||||
status-im2.contexts.shell.jump-to.effects
|
||||
[status-im2.contexts.shell.jump-to.utils :as shell.utils]
|
||||
[status-im2.navigation.state :as navigation.state]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
;;;; Effects
|
||||
|
||||
;; Navigation
|
||||
(re-frame/reg-fx
|
||||
:shell/change-tab-fx
|
||||
(fn [stack-id]
|
||||
(when (some #(= stack-id %) shell.constants/stacks-ids)
|
||||
(animation/bottom-tab-on-press stack-id false))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:shell/navigate-to-jump-to-fx
|
||||
(fn []
|
||||
(animation/close-home-stack false)
|
||||
(when-not config/shell-navigation-disabled?
|
||||
(some-> ^js @state/jump-to-list-ref
|
||||
(.scrollToOffset #js {:y 0 :animated false})))))
|
||||
|
||||
;; Note - pop-to-root resets currently opened screens to `close-screen-without-animation`.
|
||||
;; This might take some time. So don't directly merge the effect of `pop-to-root` and
|
||||
;; `navigate-to` for the floating screen. Because it might close even the currently opened screen.
|
||||
;; https://github.com/status-im/status-mobile/pull/16438#issuecomment-1623954774
|
||||
(re-frame/reg-fx
|
||||
:shell/pop-to-root-fx
|
||||
(fn []
|
||||
(shell.utils/reset-floating-screens)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:shell/reset-state
|
||||
(fn []
|
||||
(reset! state/floating-screens-state {})))
|
||||
|
||||
;;;; Events
|
||||
|
||||
;; Switcher
|
||||
@@ -105,13 +72,13 @@
|
||||
[:shell/switcher-cards (:card-id card-data)]
|
||||
switcher-card)}
|
||||
(when config/shell-navigation-disabled?
|
||||
{:shell/change-tab-fx (cond
|
||||
(#{shell.constants/one-to-one-chat-card
|
||||
shell.constants/private-group-chat-card}
|
||||
card-type)
|
||||
:chats-stack
|
||||
{:effects.shell/change-tab (cond
|
||||
(#{shell.constants/one-to-one-chat-card
|
||||
shell.constants/private-group-chat-card}
|
||||
card-type)
|
||||
:chats-stack
|
||||
|
||||
:else :communities-stack)}))
|
||||
:else :communities-stack)}))
|
||||
(switcher-cards-store/upsert-switcher-card-rpc switcher-card)))))
|
||||
|
||||
(rf/defn close-switcher-card
|
||||
@@ -152,7 +119,7 @@
|
||||
shell.constants/close-screen-without-animation))
|
||||
|
||||
:dispatch [:set-view-id :shell]})
|
||||
{:shell/navigate-to-jump-to-fx nil})))
|
||||
{:effects.shell/navigate-to-jump-to nil})))
|
||||
|
||||
(rf/defn change-shell-status-bar-style
|
||||
{:events [:change-shell-status-bar-style]}
|
||||
@@ -246,10 +213,10 @@
|
||||
(conj {:ms (* 2 shell.constants/shell-animation-time)
|
||||
:dispatch [:shell/add-switcher-card screen-id id]}))}
|
||||
(when (and id (not hidden-screen?))
|
||||
{:shell/change-tab-fx (if (or (= screen-id shell.constants/community-screen)
|
||||
community-id)
|
||||
:communities-stack
|
||||
:chats-stack)})))
|
||||
{:effects.shell/change-tab (if (or (= screen-id shell.constants/community-screen)
|
||||
community-id)
|
||||
:communities-stack
|
||||
:chats-stack)})))
|
||||
|
||||
(rf/defn floating-screen-closed
|
||||
{:events [:shell/floating-screen-closed]}
|
||||
|
||||
@@ -1,34 +1,28 @@
|
||||
(ns status-im2.contexts.wallet.account.tabs.view
|
||||
(:require
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[status-im2.common.resources :as resources]
|
||||
[status-im2.contexts.wallet.account.tabs.about.view :as about]
|
||||
[status-im2.contexts.wallet.account.tabs.dapps.view :as dapps]
|
||||
[status-im2.contexts.wallet.common.activity-tab.view :as activity]
|
||||
[status-im2.contexts.wallet.common.collectibles-tab.view :as collectibles]
|
||||
[status-im2.contexts.wallet.common.empty-tab.view :as empty-tab]
|
||||
[status-im2.contexts.wallet.common.temp :as temp]
|
||||
[status-im2.contexts.wallet.common.token-value.view :as token-value]
|
||||
[utils.i18n :as i18n]))
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [selected-tab theme]}]
|
||||
(case selected-tab
|
||||
:assets [rn/flat-list
|
||||
{:render-fn token-value/view
|
||||
:data temp/tokens
|
||||
:content-container-style {:padding-horizontal 8}}]
|
||||
:collectibles [collectibles/view]
|
||||
:activity [activity/view]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
:image (resources/get-image
|
||||
(quo.theme/theme-value :no-permissions-light
|
||||
:no-permissions-dark
|
||||
theme))}]
|
||||
:dapps [dapps/view]
|
||||
[about/view]))
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
(defn view
|
||||
[{:keys [selected-tab]}]
|
||||
(let [tokens (filter identity (rf/sub [:wallet/account-token-values]))]
|
||||
(case selected-tab
|
||||
:assets [rn/flat-list
|
||||
{:render-fn token-value/view
|
||||
:data tokens
|
||||
:content-container-style {:padding-horizontal 8}}]
|
||||
:collectibles [collectibles/view]
|
||||
:activity [activity/view]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
:placeholder? true}]
|
||||
:dapps [dapps/view]
|
||||
[about/view])))
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn header
|
||||
[{:keys [name description collection-image-url]}]
|
||||
[{:keys [name description] :as _collectible-details} collection-image-url]
|
||||
[rn/view {:style style/header}
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
@@ -112,9 +112,11 @@
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [collectible-details (rf/sub [:wallet/last-collectible-details])
|
||||
{:keys [name description preview-url traits id]} collectible-details
|
||||
chain-id (get-in id [:contract-id :chain-id])]
|
||||
(let [collectible (rf/sub [:wallet/last-collectible-details])
|
||||
{:keys [collectible-data preview-url
|
||||
collection-data]} collectible
|
||||
{:keys [traits description]} collectible-data
|
||||
chain-id (rf/sub [:wallet/last-collectible-chain-id])]
|
||||
[scroll-page/scroll-page
|
||||
{:navigate-back? true
|
||||
:height 148
|
||||
@@ -129,7 +131,7 @@
|
||||
[rn/image
|
||||
{:source preview-url
|
||||
:style style/preview}]]
|
||||
[header collectible-details]
|
||||
[header collectible-data (:image-url collection-data)]
|
||||
[cta-buttons]
|
||||
[tabs]
|
||||
[info chain-id]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns status-im2.contexts.wallet.common.utils
|
||||
(:require [clojure.string :as string]
|
||||
[status-im2.constants :as constants]
|
||||
[utils.money :as money]
|
||||
[utils.number]))
|
||||
|
||||
(defn get-first-name
|
||||
@@ -23,7 +24,7 @@
|
||||
(let [path (get-derivation-path number-of-accounts)]
|
||||
(format-derivation-path path)))
|
||||
|
||||
(defn- calculate-raw-balance
|
||||
(defn calculate-raw-balance
|
||||
[raw-balance decimals]
|
||||
(if-let [n (utils.number/parse-int raw-balance nil)]
|
||||
(/ n (Math/pow 10 (utils.number/parse-int decimals)))
|
||||
@@ -36,6 +37,12 @@
|
||||
(map #(calculate-raw-balance (:raw-balance %) decimals))
|
||||
(reduce +)))
|
||||
|
||||
(defn token-value-in-chain
|
||||
[{:keys [balances-per-chain decimals]} chain-id]
|
||||
(let [balance-in-chain (get balances-per-chain chain-id)]
|
||||
(when balance-in-chain
|
||||
(calculate-raw-balance (:raw-balance balance-in-chain) decimals))))
|
||||
|
||||
(defn calculate-balance
|
||||
[tokens-in-account]
|
||||
(->> tokens-in-account
|
||||
@@ -52,3 +59,7 @@
|
||||
(= (:related-chain-id %) chain-id))
|
||||
networks)))
|
||||
(keys balances-per-chain))))
|
||||
|
||||
(defn calculate-fiat-change
|
||||
[fiat-value change-pct-24hour]
|
||||
(money/bignumber (* fiat-value (/ change-pct-24hour (+ 100 change-pct-24hour)))))
|
||||
|
||||
@@ -215,9 +215,10 @@
|
||||
(def collectibles-request-batch-size 1000)
|
||||
|
||||
(defn displayable-collectible?
|
||||
[{:keys [image-url animation-url]}]
|
||||
(or (not (string/blank? animation-url))
|
||||
(not (string/blank? image-url))))
|
||||
[collectible]
|
||||
(let [{:keys [image-url animation-url]} (:collectible-data collectible)]
|
||||
(or (not (string/blank? animation-url))
|
||||
(not (string/blank? image-url)))))
|
||||
|
||||
(defn store-collectibles
|
||||
[{:keys [db]} [collectibles]]
|
||||
@@ -243,28 +244,47 @@
|
||||
|
||||
(rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details)
|
||||
|
||||
(def collectible-data-types
|
||||
{:unique-id 0
|
||||
:header 1
|
||||
:details 2
|
||||
:community-header 3})
|
||||
|
||||
(def fetch-type
|
||||
{:never-fetch 0
|
||||
:always-fetch 1
|
||||
:fetch-if-not-cached 2
|
||||
:fetch-if-cache-old 3})
|
||||
|
||||
(def max-cache-age-seconds 3600)
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/request-collectibles
|
||||
(fn [{:keys [db]} [{:keys [start-at-index new-request?]}]]
|
||||
(let [request-id 0
|
||||
collectibles-filter nil
|
||||
data-type (collectible-data-types :header)
|
||||
fetch-criteria {:fetch-type (fetch-type :fetch-if-not-cached)
|
||||
:max-cache-age-seconds max-cache-age-seconds}
|
||||
request-params [request-id
|
||||
[(chain/chain-id db)]
|
||||
(map :address (:profile/wallet-accounts db))
|
||||
collectibles-filter
|
||||
start-at-index
|
||||
collectibles-request-batch-size]]
|
||||
{:json-rpc/call [{:method "wallet_filterOwnedCollectiblesAsync"
|
||||
:params request-params
|
||||
:on-success #()
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to request collectibles"
|
||||
{:event :wallet/request-collectibles
|
||||
:error error
|
||||
:params request-params}))}]
|
||||
:fx (if new-request?
|
||||
[[:dispatch [:wallet/clear-stored-collectibles]]]
|
||||
[])})))
|
||||
collectibles-request-batch-size
|
||||
data-type
|
||||
fetch-criteria]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_getOwnedCollectiblesAsync"
|
||||
:params request-params
|
||||
:on-success #()
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to request collectibles"
|
||||
{:event :wallet/request-collectibles
|
||||
:error error
|
||||
:params request-params}))}]]
|
||||
(when new-request?
|
||||
[:dispatch [:wallet/clear-stored-collectibles]])]})))
|
||||
|
||||
(rf/reg-event-fx :wallet/owned-collectibles-filtering-done
|
||||
(fn [_ [{:keys [message]}]]
|
||||
@@ -283,14 +303,16 @@
|
||||
(fn [_ [collectible-id]]
|
||||
(let [request-id 0
|
||||
collectible-id-converted (cske/transform-keys csk/->PascalCaseKeyword collectible-id)
|
||||
request-params [request-id [collectible-id-converted]]]
|
||||
{:json-rpc/call [{:method "wallet_getCollectiblesDetailsAsync"
|
||||
:params request-params
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to request collectible"
|
||||
{:event :wallet/get-collectible-details
|
||||
:error error
|
||||
:params request-params}))}]})))
|
||||
data-type (collectible-data-types :details)
|
||||
request-params [request-id [collectible-id-converted] data-type]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wallet_getCollectiblesByUniqueIDAsync"
|
||||
:params request-params
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to request collectible"
|
||||
{:event :wallet/get-collectible-details
|
||||
:error error
|
||||
:params request-params}))}]]]})))
|
||||
|
||||
(rf/reg-event-fx :wallet/get-collectible-details-done
|
||||
(fn [_ [{:keys [message]}]]
|
||||
|
||||
@@ -23,24 +23,27 @@
|
||||
|
||||
(deftest store-collectibles
|
||||
(testing "(displayable-collectible?) helper function"
|
||||
(let [expected-results [[true {:image-url "https://..." :animation-url "https://..."}]
|
||||
[true {:image-url "" :animation-url "https://..."}]
|
||||
[true {:image-url nil :animation-url "https://..."}]
|
||||
[true {:image-url "https://..." :animation-url ""}]
|
||||
[true {:image-url "https://..." :animation-url nil}]
|
||||
[false {:image-url "" :animation-url nil}]
|
||||
[false {:image-url nil :animation-url nil}]
|
||||
[false {:image-url nil :animation-url ""}]
|
||||
[false {:image-url "" :animation-url ""}]]]
|
||||
(let [expected-results [[true
|
||||
{:collectible-data {:image-url "https://..." :animation-url "https://..."}}]
|
||||
[true {:collectible-data {:image-url "" :animation-url "https://..."}}]
|
||||
[true {:collectible-data {:image-url nil :animation-url "https://..."}}]
|
||||
[true {:collectible-data {:image-url "https://..." :animation-url ""}}]
|
||||
[true {:collectible-data {:image-url "https://..." :animation-url nil}}]
|
||||
[false {:collectible-data {:image-url "" :animation-url nil}}]
|
||||
[false {:collectible-data {:image-url nil :animation-url nil}}]
|
||||
[false {:collectible-data {:image-url nil :animation-url ""}}]
|
||||
[false {:collectible-data {:image-url "" :animation-url ""}}]]]
|
||||
(doseq [[result collection] expected-results]
|
||||
(is (= result (events/displayable-collectible? collection))))))
|
||||
(testing "save-collectibles-request-details"
|
||||
(let [db {:wallet {}}
|
||||
collectibles [{:image-url "https://..." :animation-url "https://..."}
|
||||
{:image-url "" :animation-url "https://..."}
|
||||
{:image-url "" :animation-url nil}]
|
||||
expected-db {:wallet {:collectibles [{:image-url "https://..." :animation-url "https://..."}
|
||||
{:image-url "" :animation-url "https://..."}]}}
|
||||
collectibles [{:collectible-data {:image-url "https://..." :animation-url "https://..."}}
|
||||
{:collectible-data {:image-url "" :animation-url "https://..."}}
|
||||
{:collectible-data {:image-url "" :animation-url nil}}]
|
||||
expected-db {:wallet {:collectibles [{:collectible-data
|
||||
{:image-url "https://..." :animation-url "https://..."}}
|
||||
{:collectible-data
|
||||
{:image-url "" :animation-url "https://..."}}]}}
|
||||
effects (events/store-collectibles {:db db} [collectibles])
|
||||
result-db (:db effects)]
|
||||
(is (= result-db expected-db)))))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user