fix: use blacklist for parallax (#18971)

This commit is contained in:
BalogunofAfrica 2024-02-29 17:13:06 +01:00 committed by GitHub
parent b1f0d1c3d7
commit ac78dea8ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 25 deletions

View File

@ -0,0 +1,18 @@
(ns status-im.common.parallax.blacklist
(:require
[native-module.core :as native-module]))
(def ^:private device-id (:device-id (native-module/get-device-model-info)))
(defn- get-model-code
[model]
(if-let [[_ code] (and model (re-find #"iPhone(\d+)" model))]
(js/parseInt code 10)
0))
(def ^:private minimum-device-code 11)
(def blacklisted?
(-> device-id
get-model-code
(< minimum-device-code)))

View File

@ -1,13 +0,0 @@
(ns status-im.common.parallax.whitelist
(:require
[clojure.string :as string]
[native-module.core :as native-module]))
(def ^:const device-id (:device-id (native-module/get-device-model-info)))
;; iPhone 14 is 15 for some reason
(def ^:const whitelist #{"iPhone11" "iPhone12" "iPhone13" "iPhone14" "iPhone15"})
(def whitelisted?
(let [device-type (first (string/split (str device-id) ","))]
(whitelist device-type)))

View File

@ -4,8 +4,8 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[status-im.common.biometric.events :as biometric] [status-im.common.biometric.events :as biometric]
[status-im.common.parallax.blacklist :as blacklist]
[status-im.common.parallax.view :as parallax] [status-im.common.parallax.view :as parallax]
[status-im.common.parallax.whitelist :as whitelist]
[status-im.common.resources :as resources] [status-im.common.resources :as resources]
[status-im.contexts.onboarding.enable-biometrics.style :as style] [status-im.contexts.onboarding.enable-biometrics.style :as style]
[status-im.navigation.state :as state] [status-im.navigation.state :as state]
@ -71,9 +71,9 @@
(let [insets (safe-area/get-insets)] (let [insets (safe-area/get-insets)]
[rn/view {:style (style/page-container insets)} [rn/view {:style (style/page-container insets)}
[page-title] [page-title]
(if whitelist/whitelisted? (if blacklist/blacklisted?
[enable-biometrics-parallax] [enable-biometrics-simple]
[enable-biometrics-simple]) [enable-biometrics-parallax])
[enable-biometrics-buttons insets]])) [enable-biometrics-buttons insets]]))
(defn view (defn view

View File

@ -4,8 +4,8 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[status-im.common.parallax.blacklist :as blacklist]
[status-im.common.parallax.view :as parallax] [status-im.common.parallax.view :as parallax]
[status-im.common.parallax.whitelist :as whitelist]
[status-im.common.resources :as resources] [status-im.common.resources :as resources]
[status-im.contexts.onboarding.enable-notifications.style :as style] [status-im.contexts.onboarding.enable-notifications.style :as style]
[status-im.contexts.shell.jump-to.utils :as shell.utils] [status-im.contexts.shell.jump-to.utils :as shell.utils]
@ -78,9 +78,9 @@
:icon-name :i/arrow-left :icon-name :i/arrow-left
:on-press #(rf/dispatch [:navigate-back-within-stack :enable-biometrics])}] :on-press #(rf/dispatch [:navigate-back-within-stack :enable-biometrics])}]
[page-title]] [page-title]]
(if whitelist/whitelisted? (if blacklist/blacklisted?
[enable-notifications-parallax] [enable-notifications-simple]
[enable-notifications-simple]) [enable-notifications-parallax])
[enable-notification-buttons {:insets insets}]])) [enable-notification-buttons {:insets insets}]]))
(defn view (defn view

View File

@ -4,8 +4,8 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[status-im.common.parallax.blacklist :as blacklist]
[status-im.common.parallax.view :as parallax] [status-im.common.parallax.view :as parallax]
[status-im.common.parallax.whitelist :as whitelist]
[status-im.common.resources :as resources] [status-im.common.resources :as resources]
[status-im.contexts.onboarding.generating-keys.style :as style] [status-im.contexts.onboarding.generating-keys.style :as style]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
@ -149,9 +149,9 @@
[] []
(let [insets (safe-area/get-insets)] (let [insets (safe-area/get-insets)]
[rn/view {:style (style/page-container insets)} [rn/view {:style (style/page-container insets)}
(if whitelist/whitelisted? (if blacklist/blacklisted?
[parallax-page insets] [:f> f-simple-page insets]
[:f> f-simple-page insets])])) [parallax-page insets])]))
(defn generating-keys (defn generating-keys
[] []