Compare commits

..
22 changed files with 150 additions and 119 deletions
@@ -98,16 +98,16 @@
(update :categories <-categories-rpc)
(assoc :role-permissions?
(->> community
:tokenPermissions
:token-permissions
vals
(some role-permission?)))
(assoc :membership-permissions?
(->> community
:tokenPermissions
:token-permissions
vals
(some membership-permission?)))
(assoc :token-images
(reduce (fn [acc {sym :symbol image :image}]
(assoc acc sym image))
{}
(:communityTokensMetadata community))))))
(:tokens-metadata community))))))
+1 -2
View File
@@ -102,8 +102,7 @@
(let [current-theme-type (get-in cofx [:db :profile/profile :appearance])]
(when (and (multiaccounts.model/logged-in? db)
(= current-theme-type status-im.constants/theme-type-system))
{:profile.settings/switch-theme-fx
[(get-in db [:profile/profile :appearance]) (:view-id db)]})))
{:dispatch [:theme/switch]})))
(defn- on-biometric-auth-fail
[{:keys [code]}]
+8
View File
@@ -0,0 +1,8 @@
(ns status-im.common.theme.effects
(:require
[status-im.common.theme.core :as theme]
[utils.re-frame :as rf]))
(rf/reg-fx :theme/legacy-theme-fx
(fn [theme]
(theme/set-legacy-theme theme)))
+15 -3
View File
@@ -1,7 +1,8 @@
(ns status-im.common.theme.events
(:require
[re-frame.core :as re-frame]
[status-im.common.theme.core :as theme]))
[status-im.common.theme.core :as theme]
[status-im.common.theme.utils :as utils]))
(re-frame/reg-fx
:theme/init-theme
@@ -10,5 +11,16 @@
(re-frame/reg-event-fx
:theme/switch
(fn [{db :db} [theme]]
{:db (assoc db :theme theme)}))
(fn [{db :db} [{:keys [theme view-id theme-type]}]]
"Switches the theme and triggers related effects.
Parameters:
- theme: Optional theme keyword to apply. If not provided, defaults to the theme determined by theme-type.
- theme-type: Optional theme type to determine the theme. If not provided, defaults to the theme type from the user's profile.
- view-id: Optional view ID for updating status color. If not provided, uses the current view ID from the database."
(let [theme-type (or theme-type (get-in db [:profile/profile :appearance]))
theme (or theme (utils/theme-type->theme-value theme-type))]
{:db (assoc db :theme theme)
:fx [[:theme/legacy-theme-fx theme]
[:dispatch
[:reload-status-nav-color
(or view-id (:view-id db))]]]})))
+17
View File
@@ -0,0 +1,17 @@
(ns status-im.common.theme.utils
(:require
[status-im.common.theme.core :as theme]
[status-im.constants :as constants]))
(defn theme-type->theme-value
"Converts theme type identifier to a theme keyword.
Returns `:light` or `:dark` based on `theme-type`:
- `theme-type-light` (1): Light theme.
- `theme-type-dark` (2): Dark theme.
- `theme-type-system` (0): Uses system preference."
[theme-type]
(condp = theme-type
constants/theme-type-dark :dark
constants/theme-type-light :light
constants/theme-type-system (if (theme/device-theme-dark?) :dark :light)
:dark))
@@ -19,10 +19,10 @@
:icon-name :i/close
:right-side [{:icon-name (if light? :i/dark :i/light)
:on-press #(if light?
(rf/dispatch [:theme/switch :dark])
(rf/dispatch [:theme/switch :light]))}]
(rf/dispatch [:theme/switch {:theme :dark}])
(rf/dispatch [:theme/switch {:theme :light}]))}]
:on-press #(if (or logged-in? (not= (rf/sub [:view-id]) :quo-preview))
(rf/dispatch [:navigate-back])
(do
(rf/dispatch [:theme/switch :dark])
(rf/dispatch [:theme/switch {:theme :dark}])
(rf/dispatch [:init-root root])))}]))
@@ -50,7 +50,7 @@
(fn []
(rn/use-effect (fn []
(when @blur?
(rf/dispatch [:theme/switch :dark])))
(rf/dispatch [:theme/switch {:theme :dark}])))
[@blur?])
[preview/preview-container {:state state :descriptor descriptor}
[rn/view
@@ -377,8 +377,8 @@
(rn/use-effect (fn []
(when blur-dark-only?
(if blur?
(rf/dispatch [:theme/switch :dark])
(rf/dispatch [:theme/switch :light]))))
(rf/dispatch [:theme/switch {:theme :dark}])
(rf/dispatch [:theme/switch {:theme :light}]))))
[blur? blur-dark-only?])
[rn/view
{:style {:top (safe-area/get-top)
@@ -4,7 +4,6 @@
[native-module.core :as native-module]
[status-im.common.keychain.events :as keychain]
[status-im.config :as config]
[status-im.constants :as constants]
status-im.contexts.profile.login.effects
[status-im.contexts.profile.rpc :as profile.rpc]
[status-im.feature-flags :as ff]
@@ -80,11 +79,7 @@
[[:dispatch [:onboarding/finalize-setup]]]
:else
[[:profile.settings/switch-theme-fx
[(or (:appearance settings)
constants/theme-type-dark)
:shell-stack]]
[:dispatch [:init-root :shell-stack]]
[[:dispatch [:init-root :shell-stack]]
[:dispatch [:profile/show-testnet-mode-banner-if-enabled]]]))})))
;; login phase 2: we want to load and show chats faster, so we split login into 2 phases
@@ -1,10 +1,7 @@
(ns status-im.contexts.profile.settings.effects
(:require [native-module.core :as native-module]
[re-frame.core :as re-frame]
[react-native.platform :as platform]
[status-im.common.theme.core :as theme]
[status-im.constants :as constants]
[utils.re-frame :as rf]))
[react-native.platform :as platform]))
(re-frame/reg-fx
:profile.settings/blank-preview-flag-changed
@@ -16,15 +13,3 @@
(fn [value]
(when platform/android?
(native-module/toggle-webview-debug value))))
(re-frame/reg-fx
:profile.settings/switch-theme-fx
(fn [[theme-type view-id]]
(let [theme (if (or (= theme-type constants/theme-type-dark)
(and (= theme-type constants/theme-type-system)
(theme/device-theme-dark?)))
:dark
:light)]
(theme/set-legacy-theme theme)
(rf/dispatch [:theme/switch theme])
(rf/dispatch [:reload-status-nav-color view-id]))))
@@ -95,14 +95,7 @@
(rf/reg-event-fx :profile.settings/change-appearance
(fn [_ [theme]]
{:fx [[:dispatch [:profile.settings/profile-update :appearance theme]]
[:profile.settings/switch-theme-fx [theme :appearance]]]}))
(rf/reg-event-fx :profile.settings/switch-theme
(fn [{:keys [db]} [theme view-id]]
(let [theme (or theme
(get-in db [:profile/profile :appearance])
constants/theme-type-dark)]
{:fx [[:profile.settings/switch-theme-fx [theme view-id]]]})))
[:dispatch [:theme/switch {:theme-type theme}]]]}))
(rf/reg-fx :profile.settings/get-profile-picture
(fn [key-uid]
@@ -1,33 +1,47 @@
(ns status-im.contexts.shell.qr-reader.sheets.scanned-wallet-address
(:require
[quo.core :as quo]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[react-native.clipboard :as clipboard]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- copy-address
[address]
(clipboard/set-string address)
(rf/dispatch [:toasts/upsert
{:type :positive
:text (i18n/label :t/address-copied)}]))
#_(defn- send-to-address
[address]
(let [[_ split-address] (network-utils/split-network-full-address address)]
(rf/dispatch
[:wallet/select-send-address
{:address address
:recipient {:recipient-type :address
:label (utils/get-shortened-address split-address)}
:stack-id :wallet-select-address
:start-flow? true}])))
(defn view
[address]
(let [[_ splitted-address] (network-utils/split-network-full-address address)]
[:<>
[quo/drawer-top
{:title address
:type :address}]
[quo/action-drawer
[[{:icon :i/send
[:<>
[quo/drawer-top {:title address :type :address}]
[quo/action-drawer
[[{:icon :i/copy
:accessibility-label :send-asset
:label (i18n/label :t/copy-address)
:on-press #(copy-address address)}
;; Originally, the flow went to the send flow, but it has been removed to avoid bugs,
;; please check https://github.com/status-im/status-mobile/issues/20972 for more context
;; The previous code has been commented out to be reintroduced in the future easily.
#_{:icon :i/send
:accessibility-label :send-asset
:label (i18n/label :t/send-to-this-address)
:on-press (fn []
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient {:recipient-type :address
:label (utils/get-shortened-address
splitted-address)}
:stack-id :wallet-select-address
:start-flow? true}]))}
(when (ff/enabled? :ff/wallet.saved-addresses)
{:icon :i/save
:accessibility-label :save-address
:label (i18n/label :t/save-address)
:on-press #(js/alert "feature not implemented")})]]]]))
:on-press #(send-to-address address)}
(when (ff/enabled? :ff/wallet.saved-addresses)
{:icon :i/save
:accessibility-label :save-address
:label (i18n/label :t/save-address)
:on-press #(js/alert "feature not implemented")})]]]])
@@ -6,11 +6,12 @@
(defn collectible-balance
[collectible]
(-> collectible
:ownership
first
:balance
js/parseInt))
(let [balance (-> collectible
:ownership
first
:balance
js/parseInt)]
(if (js/Number.isNaN balance) 0 balance)))
(def supported-collectible-types
#{"image/jpeg"
@@ -5,6 +5,7 @@
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.money :as money]
[utils.re-frame :as rf]))
(defn- action-buy
@@ -21,6 +22,7 @@
{:icon :i/send
:accessibility-label :send
:label (i18n/label :t/send)
:disabled? (:disabled? send-params)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet/clean-send-data])
@@ -69,31 +71,35 @@
(defn token-value-drawer
[token watch-only? entry-point]
(let [token-symbol (:token token)
token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered
token-symbol]))
selected-account? (rf/sub [:wallet/current-viewing-account-address])
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
send-params (if selected-account?
{:token token-data
:stack-id :screen/wallet.accounts
:start-flow? true
:owners token-owners}
{:token-symbol token-symbol
:stack-id :wallet-stack
:start-flow? true
:owners token-owners})
bridge-params (if selected-account?
{:token token-data
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
:stack-id :screen/wallet.accounts
:start-flow? true
:owners token-owners}
{:token-symbol token-symbol
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
:stack-id :wallet-stack
:start-flow? true
:owners token-owners})]
(let [token-symbol (:token token)
token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered
token-symbol]))
fiat-unformatted-value (get-in token [:values :fiat-unformatted-value])
has-balance? (money/greater-than fiat-unformatted-value (money/bignumber "0"))
selected-account? (rf/sub [:wallet/current-viewing-account-address])
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
send-params (if selected-account?
{:token token-data
:stack-id :screen/wallet.accounts
:disabled? (not has-balance?)
:start-flow? true
:owners token-owners}
{:token-symbol token-symbol
:stack-id :wallet-stack
:start-flow? true
:owners token-owners})
bridge-params (if selected-account?
{:token token-data
:bridge-disabled? (or (not has-balance?)
(send-utils/bridge-disabled? token-symbol))
:stack-id :screen/wallet.accounts
:start-flow? true
:owners token-owners}
{:token-symbol token-symbol
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
:stack-id :wallet-stack
:start-flow? true
:owners token-owners})]
[quo/action-drawer
[(cond->> [(when (ff/enabled? ::ff/wallet.assets-modal-manage-tokens)
(action-manage-tokens watch-only?))
+1
View File
@@ -12,6 +12,7 @@
status-im.common.peer-stats.events
status-im.common.shared-urls.events
status-im.common.signals.events
status-im.common.theme.effects
status-im.common.theme.events
[status-im.common.toasts.events]
status-im.common.universal-links
+1 -3
View File
@@ -74,9 +74,7 @@
(let [[status-bar-theme] (get-status-nav-color root-id theme)
root (get (roots/roots status-bar-theme) root-id)]
(dismiss-all-modals)
(rf/dispatch [:profile.settings/switch-theme
(get roots/themes root-id)
root-id])
(rf/dispatch [:theme/switch {:view-id root-id}])
(reset! state/root-id (or (get-in root [:root :stack :id]) root-id))
(navigation/set-root root)
(state/navigation-state-reset [{:id root-id
-11
View File
@@ -1,19 +1,8 @@
(ns status-im.navigation.roots
(:require
[quo.foundations.colors :as colors]
[status-im.constants :as constants]
[status-im.navigation.options :as options]))
;; Theme Order for navigation roots
;; 1. Themes hardcoded in below map
;; 2. If nil or no entry in map, then theme stored in
;; [:db :profile/profile :appearance] will be used (for mulitaccounts)
;; 3). Fallback theme - Dark
(def themes
{:screen/onboarding.intro constants/theme-type-dark
:screen/profile.profiles constants/theme-type-dark
:shell-stack nil})
(defn roots-internal
[status-bar-theme]
{:screen/onboarding.intro
+3 -2
View File
@@ -12,9 +12,10 @@
[re-frame.events :as rf-events]
[re-frame.registrar :as rf-registrar]
[re-frame.subs :as rf-subs]
[taoensso.timbre :as log] ;; We must require this namespace to register the custom cljs.test
;; directive `match-strict?`.
[taoensso.timbre :as log]
test-helpers.matchers))
;; We must require `test-helpers.matchers` this namespace to register the custom cljs.test
;; directive `match-strict?`.
(defn db
"A simple wrapper to get the latest value from the app db."
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "logger-check",
"commit-sha1": "156b848c1a0b4b07b249f453f6b7b82a5592f09c",
"src-sha256": "1sq62z1zg0jnbw1yzds4f0d26kvakyqw3b1zkwpl2mhfvm344j68"
"version": "fix/token-cache-usage",
"commit-sha1": "c5991352264b881c6b34d261ca9c2748ea060d54",
"src-sha256": "1z3y4avg5nkl8xkhigs404g5vibk1nwpsclnh6gw1w6bzrjvnc71"
}
@@ -78,6 +78,7 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
def test_deep_links_communities(self):
closed_community_name, snt_community_name = "closed community", "SNT community"
self.home.navigate_back_to_home_view()
self.home.communities_tab.click()
self.home.create_community(community_type="closed")
if not self.community_view.community_options_button.is_element_displayed():
self.home.get_chat(closed_community_name, community=True).click()
+7 -3
View File
@@ -260,9 +260,12 @@ class SignInView(BaseView):
# self.next_button.click()
# self.identifiers_button.wait_and_click(30)
if enable_notifications:
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
if self.allow_button.is_element_displayed(10):
self.allow_button.click_until_presence_of_element(self.start_button)
self.enable_notifications_button.wait_and_click()
for _ in range(3):
self.allow_button.click_if_shown(sec=10)
self.enable_notifications_button.click_if_shown()
if self.start_button.is_element_displayed():
break
else:
self.maybe_later_button.click_until_presence_of_element(self.start_button)
self.cancel_button.click_if_shown() # TODO: remove when issue 20806 is fixed
@@ -294,6 +297,7 @@ class SignInView(BaseView):
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
else:
self.maybe_later_button.click_until_presence_of_element(self.start_button)
self.cancel_button.click_if_shown() # TODO: remove when issue 20806 is fixed
self.start_button.click()
self.chats_tab.wait_for_visibility_of_element(30)
self.driver.info("## Multiaccount is recovered successfully!", device=False)
+8 -1
View File
@@ -1,3 +1,5 @@
import time
import pytest
from tests import common_password
@@ -120,7 +122,12 @@ class WalletView(BaseView):
self.login_button.click()
def confirm_transaction(self):
self.confirm_button.click_until_presence_of_element(self.slide_button_track)
self.confirm_button.click()
for _ in range(3):
if self.slide_button_track.is_element_displayed():
break
time.sleep(1)
self.confirm_button.click()
self.slide_and_confirm_with_password()
def set_amount(self, amount: float):