Skip to content

Commit

Permalink
Merge branch 'develop' into 17116-3
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed Dec 14, 2023
2 parents 2d2766e + b668e4d commit 63558bb
Show file tree
Hide file tree
Showing 56 changed files with 870 additions and 394 deletions.
2 changes: 1 addition & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
;; setupFilesAfterEnv.
status-im2.setup.schema-preload

quo.core-spec
;;quo.core-spec
status-im2.core-spec]
:ns-regexp "component-spec$"
:output-dir "component-spec"
Expand Down
17 changes: 10 additions & 7 deletions src/quo/components/drawers/drawer_top/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
[react-native.core :as rn]
[utils.i18n :as i18n]))

(def ^:private left-image-supported-types #{:account :keypair :default-keypair})

(defn- left-image
[{:keys [type customization-color account-avatar-emoji icon-avatar profile-picture]}]
(case type
Expand Down Expand Up @@ -165,13 +167,14 @@
button-disabled? account-avatar-emoji customization-color icon-avatar
profile-picture keycard? networks label]}]
[rn/view {:style style/container}
[rn/view {:style style/left-container}
[left-image
{:type type
:customization-color customization-color
:account-avatar-emoji account-avatar-emoji
:icon-avatar icon-avatar
:profile-picture profile-picture}]]
(when (left-image-supported-types type)
[rn/view {:style style/left-container}
[left-image
{:type type
:customization-color customization-color
:account-avatar-emoji account-avatar-emoji
:icon-avatar icon-avatar
:profile-picture profile-picture}]])
[rn/view {:style style/body-container}
[left-title
{:type type
Expand Down
2 changes: 2 additions & 0 deletions src/quo/components/list_items/token_value/component_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
(h/test "Token label renders"
(h/render [token-value/view
{:token :snt
:token-name "Status"
:state :default
:status :empty
:customization-color :blue
Expand All @@ -20,6 +21,7 @@
(h/test "Status change"
(h/render [token-value/view
{:token :snt
:token-name "Status"
:state :default
:status :positive
:customization-color :blue
Expand Down
6 changes: 3 additions & 3 deletions src/quo/components/list_items/token_value/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
[quo.components.markdown.text :as text]
[quo.components.utilities.token.view :as token]
[quo.foundations.colors :as colors]
[quo.foundations.common :as common]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[reagent.core :as reagent]))

(defn- internal-view
[]
(let [state (reagent/atom :default)]
(fn [{:keys [theme customization-color status token metrics? values on-press on-long-press]}]
(fn [{:keys [theme customization-color status token metrics? values on-press on-long-press
token-name]}]
(let [bg-opacity (case @state
:active 10
:pressed 5
Expand All @@ -36,7 +36,7 @@
:flex 1}}
[token/view {:token token :size :size-32}]
[rn/view {:style {:margin-left 8}}
[text/text {:weight :semi-bold} (common/token-label token)]
[text/text {:weight :semi-bold} token-name]
[text/text
{:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
Expand Down
31 changes: 24 additions & 7 deletions src/quo/components/utilities/token/view.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
(ns quo.components.utilities.token.view
(:require [quo.components.utilities.token.loader :as token-loader]
[react-native.core :as rn]
[schema.core :as schema]
[utils.number]))
(:require
[clojure.string :as string]
[quo.components.markdown.text :as quo]
[quo.components.utilities.token.loader :as token-loader]
[react-native.core :as rn]
[schema.core :as schema]
[utils.number]))

(def ?schema
[:=>
Expand Down Expand Up @@ -33,6 +36,18 @@

(def ^:private b64-png-image-prefix "data:image/png;base64,")

(defn temp-empty-symbol
[token size]
[rn/view
{:style (token-style {:justify-content :center
:align-items :center
:border-radius 20
:border-width 1
:border-color :grey}
size)}
[quo/text {:style {:color :grey}}
(string/capitalize (first (name token)))]])

(defn view-internal
"Render a token image.
Props:
Expand All @@ -51,8 +66,10 @@
(str b64-png-image-prefix image-source)
image-source)
source (or b64-string (token-loader/get-token-image token))]
[rn/image
{:style (token-style style size)
:source source}]))
(if source
[rn/image
{:style (token-style style size)
:source source}]
[temp-empty-symbol token size])))

(def view (schema/instrument #'view-internal ?schema))
5 changes: 0 additions & 5 deletions src/quo/foundations/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@
(def currency-label
{:eur ""
:usd "$"})

(def token-label
{:eth "Ethereum"
:snt "Status"
:dai "Dai"})
10 changes: 5 additions & 5 deletions src/status_im/ethereum/subscriptions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@

(rf/defn new-wallet-event
[cofx {:keys [type blockNumber accounts] :as event}]
(log/info "[wallet-subs] new-wallet-event"
"event-type" type
"blockNumber" blockNumber
"accounts" accounts)
(log/debug "[wallet-subs] new-wallet-event"
"event-type" type
"blockNumber" blockNumber
"accounts" accounts)
(case type
"new-transfers" (new-transfers cofx blockNumber accounts)
"recent-history-fetching" (recent-history-fetching-started cofx accounts)
Expand All @@ -85,4 +85,4 @@
"wallet-get-collectibles-details-done" {:fx [[:dispatch
[:wallet/get-collectible-details-done
event]]]}
(log/warn ::unknown-wallet-event :type type :event event)))
(log/debug ::unknown-wallet-event :type type :event event)))
20 changes: 6 additions & 14 deletions src/status_im/wallet/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,26 +1153,18 @@
#(async-storage/set-item! :invalid-ens-name-seen true)))))
nil)

(re-frame/reg-fx
::enable-local-notifications
(fn []
(native-module/start-local-notifications)))

(rf/defn initialize-wallet
{:events [:wallet-legacy/initialize-wallet]}
[{:keys [db] :as cofx} accounts tokens custom-tokens
favourites scan-all-tokens? new-account?]
(rf/merge
cofx
{:db (assoc db
:profile/wallet-accounts
(rpc->accounts accounts))
;; NOTE: Local notifications should be enabled only after wallet was started
::enable-local-notifications nil
:dispatch-n [(when (or (not (utils.mobile-sync/syncing-allowed? cofx))
(chain/binance-chain? db))
[:transaction/get-fetched-transfers])]
:dispatch [:wallet/get-accounts-success accounts]}
{:db (assoc db
:profile/wallet-accounts
(rpc->accounts accounts))
:dispatch-n [(when (or (not (utils.mobile-sync/syncing-allowed? cofx))
(chain/binance-chain? db))
[:transaction/get-fetched-transfers])]}
(check-invalid-ens)
(initialize-tokens tokens custom-tokens)
(initialize-favourites favourites)
Expand Down
10 changes: 8 additions & 2 deletions src/status_im2/common/data_store/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
[ids]
(string/join constants/chain-id-separator ids))

(defn add-keys-to-account
[account]
(assoc account :watch-only? (= (:type account) :watch)))

(defn rpc->account
[account]
(-> account
Expand All @@ -25,7 +29,8 @@
(update :prod-preferred-chain-ids chain-ids-string->set)
(update :test-preferred-chain-ids chain-ids-string->set)
(update :type keyword)
(update :color #(if (seq %) (keyword %) constants/account-default-customization-color))))
(update :color #(if (seq %) (keyword %) constants/account-default-customization-color))
add-keys-to-account))

(defn rpc->accounts
[accounts]
Expand All @@ -40,7 +45,8 @@
:test-preferred-chain-ids :testPreferredChainIds
:color :colorId})
(update :prodPreferredChainIds chain-ids-set->string)
(update :testPreferredChainIds chain-ids-set->string)))
(update :testPreferredChainIds chain-ids-set->string)
(dissoc :watch-only?)))

(defn <-rpc
[network]
Expand Down
5 changes: 4 additions & 1 deletion src/status_im2/common/pairing/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
constants/local-pairing-event-connection-success)
(= action
constants/local-pairing-action-connect))
connection-error? (and (= type
constants/local-pairing-event-connection-error))
error-on-pairing? (contains? constants/local-pairing-event-errors type)
completed-pairing? (and (= type
constants/local-pairing-event-transfer-success)
Expand All @@ -30,8 +32,9 @@
(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?)
navigate-to-syncing-devices? (and (or connection-success? connection-error?) receiver?)
user-in-syncing-devices-screen? (or (= (:view-id db) :syncing-progress)
(= (:view-id db) :profiles)
(= (:view-id db) :syncing-progress-intro))
user-in-sign-in-intro-screen? (= (:view-id db) :sign-in-intro)]
(merge {:db (cond-> db
Expand Down
4 changes: 4 additions & 0 deletions src/status_im2/contexts/chat/messages/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
[status-im2.contexts.chat.messages.navigation.view :as messages.navigation]
[utils.re-frame :as rf]))

;; NOTE(parvesh) - I am working on refactoring/optimization of the chat screen for performance
;; improvement. Please avoid refactoring these files. Also if you are not already working on bug
;; fixes related to the chat navigation bar, please skip them.
;; And ping me, so I can address them while refactoring
(defn f-chat
[{:keys [show-floating-scroll-down-button? animate-topbar-name?
big-name-visible? animate-topbar-opacity? on-end-reached? messages-list-on-layout-finished?]
Expand Down
17 changes: 12 additions & 5 deletions src/status_im2/contexts/onboarding/syncing/progress/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[react-native.core :as rn]
[status-im2.contexts.onboarding.common.background.view :as background]
[status-im2.contexts.onboarding.syncing.progress.style :as style]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand All @@ -25,12 +26,17 @@
:description-accessibility-label :progress-screen-sub-title}])

(defn try-again-button
[profile-color in-onboarding?]
[profile-color in-onboarding? logged-in?]
[quo/button
{:on-press (fn []
(rf/dispatch [:syncing/clear-states])
(rf/dispatch [:navigate-back-to
(if in-onboarding? :sign-in-intro :sign-in)]))
(cond
logged-in? (rf/dispatch [:navigate-back])
in-onboarding? (rf/dispatch [:navigate-back-to :sign-in-intro])
:else (do
(rf/dispatch [:navigate-back])
(debounce/dispatch-and-chill [:open-modal :sign-in]
1000))))
:accessibility-label :try-again-later-button
:customization-color profile-color
:container-style style/try-again-button}
Expand All @@ -39,7 +45,8 @@
(defn view
[in-onboarding?]
(let [pairing-status (rf/sub [:pairing/pairing-status])
profile-color (:color (rf/sub [:onboarding/profile]))]
profile-color (:color (rf/sub [:onboarding/profile]))
logged-in? (rf/sub [:multiaccount/logged-in?])]
[rn/view {:style (style/page-container in-onboarding?)}
(when-not in-onboarding? [background/view true])
[quo/page-nav {:type :no-title :background :blur}]
Expand All @@ -50,7 +57,7 @@
[rn/view {:style style/page-illustration}
[quo/text "[Error here]"]])
(when-not (pairing-progress pairing-status)
[try-again-button profile-color in-onboarding?])]))
[try-again-button profile-color in-onboarding? logged-in?])]))

(defn view-onboarding
[]
Expand Down
4 changes: 4 additions & 0 deletions src/status_im2/contexts/profile/login/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
;;"node.login" signal will be triggered as a callback
(native-module/login-account
(assoc (profile.config/login) :keyUid key-uid :password hashed-password))))

(rf/reg-fx :effects.profile/enable-local-notifications
(fn []
(native-module/start-local-notifications)))
48 changes: 23 additions & 25 deletions src/status_im2/contexts/profile/login/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,29 @@
current-network-config (get networks current-network)
network-id (str (get-in networks
[current-network :config :NetworkId]))]
(rf/merge cofx
(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
(fn [accounts tokens custom-tokens favourites]
(re-frame/dispatch [:wallet-legacy/initialize-wallet
accounts tokens custom-tokens favourites]))]
:check-eip1559-activation {:network-id network-id}}
(not (:universal-links/handling db))
(assoc :effects.chat/open-last-chat (get-in db [:profile/profile :key-uid]))
notifications-enabled?
(assoc :effects/push-notifications-enable nil))
(contacts/initialize-contacts)
(browser/initialize-browser)
(mobile-network/on-network-status-change)
(group-chats/get-group-chat-invitations)
(profile.settings.events/get-profile-picture)
(profile.settings.events/change-preview-privacy)
(link-preview/request-link-preview-whitelist)
(visibility-status-updates-store/fetch-visibility-status-updates-rpc)
(switcher-cards-store/fetch-switcher-cards-rpc))))
(rf/merge
cofx
(cond-> {:json-rpc/call [{:method "wakuext_startMessenger"
:on-success #(re-frame/dispatch
[:messenger-started %])
:on-error #(log/error
"failed to start messenger")}]
:check-eip1559-activation {:network-id network-id}
:effects.profile/enable-local-notifications nil
:dispatch-n [[:wallet/get-accounts]]}
(not (:universal-links/handling db))
(assoc :effects.chat/open-last-chat (get-in db [:profile/profile :key-uid]))
notifications-enabled?
(assoc :effects/push-notifications-enable nil))
(contacts/initialize-contacts)
(browser/initialize-browser)
(mobile-network/on-network-status-change)
(group-chats/get-group-chat-invitations)
(profile.settings.events/get-profile-picture)
(profile.settings.events/change-preview-privacy)
(link-preview/request-link-preview-whitelist)
(visibility-status-updates-store/fetch-visibility-status-updates-rpc)
(switcher-cards-store/fetch-switcher-cards-rpc))))

(rf/defn messenger-started
{:events [:messenger-started]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(defn view
[]
(let [state (reagent/atom {:token :snt
:token-name "Status"
:state :default
:status :empty
:customization-color :blue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
(def mock-data
[{:id 1
:type types/item
:data {:on-press (println "pressed")
:image (resources/get-mock-image :diamond)
:data {:image (resources/get-mock-image :diamond)
:image-size 21
:right-icon :i/world
:title "Trip to Bahamas"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
(assoc :test-ID stack-id
:icon icon
:icon-color-anim icon-color
;NOTE temporary use of on long press while we support old wallet
:on-long-press #(when (= stack-id :wallet-stack)
(swap! state/load-new-wallet? not)
(animation/bottom-tab-on-press stack-id true))
:on-press #(animation/bottom-tab-on-press stack-id true)
:accessibility-label (str (name stack-id) "-tab")
:customization-color customization-color))]))
Expand Down
Loading

0 comments on commit 63558bb

Please sign in to comment.