diff --git a/android/app/build.gradle b/android/app/build.gradle index 367dd49cfc..d606b22b89 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -80,6 +80,8 @@ project.ext.react = [ nodeExecutableAndArgs: ["node", "--max-old-space-size=16384"], entryFile: "index.android.js", bundleInPr: true, + bundleCommand: "ram-bundle", + bundleConfig: "packager/config.js" ] apply from: "../../node_modules/react-native/react.gradle" diff --git a/clj-rn.conf.edn b/clj-rn.conf.edn index 3e478ac9e8..55455b90ff 100644 --- a/clj-rn.conf.edn +++ b/clj-rn.conf.edn @@ -46,7 +46,6 @@ "hi-base32" "react-native-mail" "react-native-shake"] - ;; Desktop modules :desktop-modules ["realm" "react-native-languages" diff --git a/components/src/status_im/ui/components/react.cljs b/components/src/status_im/ui/components/react.cljs index d2488fcc16..ab30eb2d83 100644 --- a/components/src/status_im/ui/components/react.cljs +++ b/components/src/status_im/ui/components/react.cljs @@ -1,7 +1,6 @@ (ns status-im.ui.components.react (:require-macros [status-im.utils.views :as views]) - (:require [clojure.string :as string] - [goog.object :as object] + (:require [goog.object :as object] [reagent.core :as reagent] [status-im.ui.components.styles :as styles] [status-im.utils.utils :as utils] @@ -17,31 +16,42 @@ (or (object/get js-dependencies/react-native name) {}) #js {})) +(defn lazy-get-react-property [name] + (let [react-property (atom nil)] + (fn [] + (if @react-property + @react-property + (reset! react-property (get-react-property name)))))) + (defn adapt-class [class] (when class (reagent/adapt-react-class class))) (defn get-class [name] - (adapt-class (get-react-property name))) + (let [react-class (atom nil)] + (fn [] + (if @react-class + @react-class + (reset! react-class + (adapt-class (get-react-property name))))))) (def native-modules (.-NativeModules js-dependencies/react-native)) (def device-event-emitter (.-DeviceEventEmitter js-dependencies/react-native)) -(def dismiss-keyboard! js-dependencies/dismiss-keyboard) -(def back-handler (get-react-property "BackHandler")) + +(defn dismiss-keyboard! [] ((js-dependencies/dismiss-keyboard))) (def splash-screen (.-SplashScreen native-modules)) ;; React Components (def app-registry (get-react-property "AppRegistry")) -(def app-state (get-react-property "AppState")) -(def net-info (get-react-property "NetInfo")) -(def view (get-class "View")) +(def app-state (lazy-get-react-property "AppState")) +(def net-info (lazy-get-react-property "NetInfo")) +(def view ((get-class "View"))) (def safe-area-view (get-class "SafeAreaView")) (def progress-bar (get-class "ProgressBarAndroid")) (def status-bar-class (when-not platform/desktop? (get-react-property "StatusBar"))) -(def status-bar (get-class (if platform/desktop? "View" "StatusBar"))) (def scroll-view (get-class "ScrollView")) (def web-view (get-class "WebView")) @@ -49,11 +59,12 @@ (def refresh-control (get-class "RefreshControl")) -(def text-class (get-class "Text")) +(def text-class ((get-class "Text"))) (def text-input-class (get-class "TextInput")) (def image-class (get-class "Image")) -(def picker-class (get-class "Picker")) -(def picker-item-class (adapt-class (.-Item (get-react-property "Picker")))) +(def picker-obj (lazy-get-react-property "Picker")) +(defn picker-class [] (adapt-class (picker-obj))) +(defn picker-item-class [] (adapt-class (.-Item (picker-obj)))) (defn valid-source? [source] (or (not (map? source)) @@ -63,30 +74,34 @@ (defn image [{:keys [source] :as props}] (when (valid-source? source) - [image-class props])) + (let [source (if (fn? source) (source) source)] + [(image-class) (assoc props :source source)]))) -(def switch (get-class "Switch")) -(def check-box (get-class "CheckBox")) +(def switch-class (get-class "Switch")) + +(defn switch [props] + [(switch-class) props]) (def touchable-highlight-class (get-class "TouchableHighlight")) (def touchable-without-feedback-class (get-class "TouchableWithoutFeedback")) (def touchable-opacity (get-class "TouchableOpacity")) -(def activity-indicator (get-class "ActivityIndicator")) +(def activity-indicator-class (get-class "ActivityIndicator")) + +(defn activity-indicator [props] + [(activity-indicator-class) props]) (def modal (get-class "Modal")) -(def pan-responder (.-PanResponder js-dependencies/react-native)) -(def animated (.-Animated js-dependencies/react-native)) -(def animated-view (reagent/adapt-react-class (.-View animated))) -(def animated-text (reagent/adapt-react-class (.-Text animated))) +(def pan-responder (lazy-get-react-property "PanResponder")) +(def animated (lazy-get-react-property "Animated")) +(defn animated-view [] + (reagent/adapt-react-class (.-View (animated)))) -(def dimensions (.-Dimensions js-dependencies/react-native)) -(def keyboard (.-Keyboard js-dependencies/react-native)) -(def linking (.-Linking js-dependencies/react-native)) +(def dimensions (lazy-get-react-property "Dimensions")) +(def keyboard (lazy-get-react-property "Keyboard")) +(def linking (lazy-get-react-property "Linking")) (def desktop-notification (.-DesktopNotification (.-NativeModules js-dependencies/react-native))) -(def slider (get-class "Slider")) - (def max-font-size-multiplier 1.25) (defn prepare-text-props [props] @@ -122,7 +137,7 @@ (defn text-input [options text] - [text-input-class + [(text-input-class) (merge {:underline-color-android :transparent :max-font-size-multiplier max-font-size-multiplier @@ -145,30 +160,30 @@ :style style}])) (defn touchable-highlight [props content] - [touchable-highlight-class + [(touchable-highlight-class) (merge {:underlay-color :transparent} props) content]) (defn touchable-without-feedback [props content] - [touchable-without-feedback-class + [(touchable-without-feedback-class) props content]) (defn get-dimensions [name] - (js->clj (.get dimensions name) :keywordize-keys true)) + (js->clj (.get (dimensions) name) :keywordize-keys true)) (defn list-item [component] (reagent/as-element component)) (defn value->picker-item [{:keys [value label]}] - [picker-item-class {:value (or value "") :label (or label value "")}]) + [(picker-item-class) {:value (or value "") :label (or label value "")}]) (defn picker [{:keys [style on-change selected enabled data]}] (into - [picker-class (merge (when style {:style style}) - (when enabled {:enabled enabled}) - (when on-change {:on-value-change on-change}) - (when selected {:selected-value selected}))] + [(picker-class) (merge (when style {:style style}) + (when enabled {:enabled enabled}) + (when on-change {:on-value-change on-change}) + (when selected {:selected-value selected}))] (map value->picker-item data))) ;; Image picker @@ -184,7 +199,7 @@ ([images-fn] (show-image-picker images-fn nil)) ([images-fn media-type] - (let [image-picker (.-default image-picker-class)] + (let [image-picker (.-default (image-picker-class))] (-> image-picker (.openPicker (clj->js {:multiple false :mediaType (or media-type "any")})) (.then images-fn) @@ -210,7 +225,7 @@ (defn keyboard-avoiding-view [props & children] (let [view-element (if platform/ios? - [keyboard-avoiding-view-class (merge {:behavior :padding} props)] + [(keyboard-avoiding-view-class) (merge {:behavior :padding} props)] [view props])] (vec (concat view-element children)))) @@ -309,7 +324,7 @@ :height 100 :z-index -1000}]) children (conj children bottom-background)] - (apply vector safe-area-view props children)))) + (apply vector (safe-area-view) props children)))) (defmethod create-main-screen-view :default [_] view) diff --git a/ios/StatusIm.xcodeproj/project.pbxproj b/ios/StatusIm.xcodeproj/project.pbxproj index a3d6e24e16..6159dd1a87 100644 --- a/ios/StatusIm.xcodeproj/project.pbxproj +++ b/ios/StatusIm.xcodeproj/project.pbxproj @@ -1837,7 +1837,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -o errexit\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --max-old-space-size=16384 \"\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "set -o errexit\nexport BUNDLE_COMMAND=\"ram-bundle\"\nexport BUNDLE_CONFIG=\"packager/config.js\"\nexport NODE_BINARY=\"node\"\nexport NODE_ARGS=\" --max-old-space-size=16384 \"\n\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; }; 2EAC54E16AB243C3EBBFE1BA /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; diff --git a/packager/config.js b/packager/config.js new file mode 100644 index 0000000000..6293e12ff3 --- /dev/null +++ b/packager/config.js @@ -0,0 +1,35 @@ +const modulePaths = require('./modulePaths'); +const resolve = require('path').resolve; +const fs = require('fs'); +const { getDefaultConfig } = require("metro-config"); + +// Update the following line if the root folder of your app is somewhere else. +const ROOT_FOLDER = resolve(__dirname, '..'); + +module.exports = (async () => { + const { + resolver: { sourceExts, assetExts } + } = await getDefaultConfig(); + return { + transformer: { + babelTransformerPath: require.resolve("react-native-svg-transformer"), + getTransformOptions: async () => { + const moduleMap = {}; + modulePaths.forEach(path => { + if (fs.existsSync(path)) { + moduleMap[resolve(path)] = true; + } + }); + return { + preloadedModules: moduleMap, + transform: { inlineRequires: { blacklist: moduleMap } }, + } + }, + }, + projectRoot:ROOT_FOLDER, + resolver: { + assetExts: assetExts.filter(ext => ext !== "svg"), + sourceExts: [...sourceExts, "svg"] + } + }; +})(); diff --git a/packager/modulePaths.js b/packager/modulePaths.js new file mode 100644 index 0000000000..b8f5f3a1dd --- /dev/null +++ b/packager/modulePaths.js @@ -0,0 +1,415 @@ +module.exports = [ + "node_modules/react-native/Libraries/Core/InitializeCore.js", + "index.android.js", + "index.ios.js", + "node_modules/react-native-config/index.js", + "node_modules/react-native/Libraries/react-native/react-native-implementation.js", + "node_modules/react-native/Libraries/BatchedBridge/NativeModules.js", + "node_modules/invariant/browser.js", + "node_modules/react-native/Libraries/BatchedBridge/BatchedBridge.js", + "node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js", + "node_modules/react-native/Libraries/Utilities/stringifySafe.js", + "node_modules/react-native/Libraries/Utilities/defineLazyObjectProperty.js", + "node_modules/react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.js", + "node_modules/react-native/Libraries/vendor/emitter/EventSubscriptionVendor.js", + "node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js", + "node_modules/react-native/Libraries/vendor/emitter/EmitterSubscription.js", + "node_modules/react-native/Libraries/vendor/emitter/EventSubscription.js", + "node_modules/react-native/Libraries/ReactNative/UIManager.js", + "node_modules/react-native/Libraries/Utilities/Platform.android.js", + "node_modules/react-native/Libraries/ReactNative/UIManagerProperties.js", + "node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js", + "node_modules/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js", + "node_modules/react-native/Libraries/react-native/React.js", + "node_modules/react/index.js", + "node_modules/object-assign/index.js", + "node_modules/react/cjs/react.production.min.js", + "node_modules/react/node_modules/prop-types/checkPropTypes.js", + "node_modules/react/node_modules/prop-types/lib/ReactPropTypesSecret.js", + "node_modules/react-native/Libraries/ReactNative/requireNativeComponent.js", + "node_modules/react-native/Libraries/Renderer/shims/createReactNativeComponentClass.js", + "node_modules/react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js", + "node_modules/react-native/Libraries/ReactNative/getNativeComponentAttributes.js", + "node_modules/react-native/node_modules/fbjs/lib/warning.js", + "node_modules/@babel/runtime/helpers/objectSpread.js", + "node_modules/@babel/runtime/helpers/defineProperty.js", + "node_modules/react-native/Libraries/Components/View/ReactNativeStyleAttributes.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js", + "node_modules/react-native/node_modules/prop-types/index.js", + "node_modules/react-native/node_modules/prop-types/factoryWithTypeCheckers.js", + "node_modules/react-native/node_modules/prop-types/lib/ReactPropTypesSecret.js", + "node_modules/react-native/node_modules/prop-types/checkPropTypes.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js", + "node_modules/react-native/Libraries/Color/normalizeColor.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js", + "node_modules/react-native/Libraries/Utilities/deprecatedPropType.js", + "node_modules/react-native/Libraries/Text/TextStylePropTypes.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js", + "node_modules/react-native/Libraries/StyleSheet/processTransform.js", + "node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js", + "node_modules/react-native/Libraries/StyleSheet/processColor.js", + "node_modules/react-native/Libraries/Image/AssetRegistry.js", + "node_modules/react-native/Libraries/Utilities/PixelRatio.js", + "node_modules/react-native/Libraries/Utilities/Dimensions.js", + "node_modules/react-native/Libraries/Utilities/DeviceInfo.js", + "node_modules/react-native/Libraries/Components/View/View.js", + "node_modules/react-native/Libraries/Components/View/ViewNativeComponent.js", + "node_modules/react-native/Libraries/Text/TextAncestor.js", + "node_modules/react-native/Libraries/StyleSheet/StyleSheet.js", + "node_modules/react-native/Libraries/StyleSheet/flattenStyle.js", + "node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js", + "node_modules/react-native/Libraries/vendor/core/merge.js", + "node_modules/react-native/Libraries/vendor/core/mergeInto.js", + "node_modules/react-native/Libraries/vendor/core/mergeHelpers.js", + "node_modules/react-native/Libraries/Components/View/ReactNativeViewAttributes.js", + "node_modules/react-native/Libraries/Components/Touchable/Touchable.js", + "node_modules/react-native/node_modules/fbjs/lib/keyMirror.js", + "node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js", + "node_modules/react-native/Libraries/Renderer/shims/ReactNative.js", + "node_modules/react-native/Libraries/Core/setUpGlobals.js", + "node_modules/react-native/Libraries/Core/polyfillES6Collections.js", + "node_modules/react-native/Libraries/vendor/core/_shouldPolyfillES6Collection.js", + "node_modules/react-native/Libraries/Utilities/PolyfillFunctions.js", + "node_modules/react-native/Libraries/Core/setUpSystrace.js", + "node_modules/react-native/Libraries/Core/setUpErrorHandling.js", + "node_modules/react-native/Libraries/Core/ExceptionsManager.js", + "node_modules/stacktrace-parser/index.js", + "node_modules/stacktrace-parser/lib/stacktrace-parser.js", + "node_modules/react-native/Libraries/Network/fetch.js", + "node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js", + "node_modules/react-native/Libraries/Core/checkNativeVersion.js", + "node_modules/react-native/Libraries/Core/ReactNativeVersionCheck.js", + "node_modules/react-native/Libraries/Core/ReactNativeVersion.js", + "node_modules/react-native/Libraries/Core/polyfillPromise.js", + "node_modules/react-native/Libraries/Promise.js", + "node_modules/promise/setimmediate/done.js", + "node_modules/promise/setimmediate/core.js", + "node_modules/promise/setimmediate/es6-extensions.js", + "node_modules/promise/setimmediate/rejection-tracking.js", + "node_modules/react-native/Libraries/Core/setUpRegeneratorRuntime.js", + "node_modules/regenerator-runtime/runtime.js", + "node_modules/react-native/Libraries/Core/setUpTimers.js", + "node_modules/react-native/Libraries/Core/Timers/JSTimers.js", + "node_modules/react-native/node_modules/fbjs/lib/ExecutionEnvironment.js", + "node_modules/react-native/Libraries/Core/setUpXHR.js", + "node_modules/react-native/Libraries/Blob/BlobManager.js", + "node_modules/react-native/Libraries/Blob/Blob.js", + "node_modules/react-native/Libraries/Blob/BlobRegistry.js", + "node_modules/event-target-shim/lib/event-target.js", + "node_modules/event-target-shim/lib/commons.js", + "node_modules/event-target-shim/lib/custom-event-target.js", + "node_modules/event-target-shim/lib/event-wrapper.js", + "node_modules/react-native/Libraries/Network/FormData.js", + "node_modules/base64-js/index.js", + "node_modules/react-native/Libraries/WebSocket/WebSocket.js", + "node_modules/react-native/Libraries/WebSocket/WebSocketEvent.js", + "node_modules/react-native/Libraries/Blob/File.js", + "node_modules/react-native/Libraries/Core/setUpAlert.js", + "node_modules/react-native/Libraries/Core/setUpGeolocation.js", + "node_modules/react-native/Libraries/Utilities/logError.js", + "node_modules/react-native/Libraries/Core/setUpBatchedBridge.js", + "node_modules/react-native/Libraries/Utilities/RCTLog.js", + "node_modules/react-native/Libraries/Utilities/infoLog.js", + "node_modules/react-native/Libraries/Core/setUpSegmentFetcher.js", + "node_modules/react-native/Libraries/AppState/AppState.js", + "node_modules/react-native/Libraries/JSInspector/JSInspector.js", + "node_modules/react-native/Libraries/JSInspector/NetworkAgent.js", + "node_modules/react-native/Libraries/JSInspector/InspectorAgent.js", + "node_modules/react-native/Libraries/EventEmitter/RCTEventEmitter.js", + "node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js", + "node_modules/react-native/Libraries/Components/TextInput/TextInputState.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js", + "node_modules/react-native/Libraries/Animated/src/Animated.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedValue.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedWithChildren.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedNode.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedValueXY.js", + "node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js", + "node_modules/react-native/Libraries/Animated/src/Easing.js", + "node_modules/react-native/Libraries/Animated/src/AnimatedEvent.js", + "node_modules/react-native/Libraries/Animated/src/createAnimatedComponent.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedProps.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedStyle.js", + "node_modules/react-native/Libraries/Animated/src/nodes/AnimatedTransform.js", + "node_modules/react-native/Libraries/Components/Keyboard/Keyboard.js", + "node_modules/react-native/Libraries/Utilities/dismissKeyboard.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js", + "node_modules/react-native/Libraries/Components/View/PlatformViewPropTypes.android.js", + "node_modules/react-native/Libraries/Animated/src/components/AnimatedText.js", + "node_modules/react-native/Libraries/Text/Text.js", + "node_modules/react-native/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js", + "node_modules/react-native/Libraries/Animated/src/components/AnimatedView.js", + "node_modules/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js", + "node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js", + "node_modules/react-native/Libraries/Utilities/warnOnce.js", + "node_modules/react-native/Libraries/ReactNative/AppContainer.js", + "node_modules/react-native/Libraries/ReactNative/I18nManager.js", + "node_modules/react-native/Libraries/Interaction/PanResponder.js", + "node_modules/react-native/Libraries/ReactNative/AppRegistry.js", + "node_modules/react-native/Libraries/ReactNative/renderApplication.js", + "node_modules/react-native/Libraries/Utilities/BackHandler.android.js", + "node_modules/react-native/Libraries/BugReporting/BugReporting.js", + "node_modules/react-native/Libraries/Utilities/SceneTracker.js", + "node_modules/react-native/Libraries/Linking/Linking.js", + "node_modules/react-native/Libraries/Network/NetInfo.js", + "node_modules/react-native/Libraries/Share/Share.js", + "node_modules/react-native-fs/FS.common.js", + "node_modules/react-native-keychain/index.js", + "node_modules/fbjs/lib/warning.js", + "node_modules/fbjs/lib/emptyFunction.js", + "node_modules/fbjs/lib/invariant.js", + "node_modules/fbjs/lib/emptyObject.js", + "node_modules/realm/lib/index.js", + "node_modules/realm/lib/user-methods.js", + "node_modules/realm/lib/errors.js", + "node_modules/realm/lib/permission-api.js", + "node_modules/realm/lib/extensions.js", + "node_modules/realm/lib/collection-methods.js", + "node_modules/create-react-class/index.js", + "node_modules/create-react-class/factory.js", + "node_modules/prop-types/index.js", + "node_modules/prop-types/factoryWithTypeCheckers.js", + "node_modules/prop-types/lib/ReactPropTypesSecret.js", + "node_modules/prop-types/checkPropTypes.js", + "node_modules/react-native-securerandom/index.js", + "node_modules/i18n-js/app/assets/javascripts/i18n.js", + "node_modules/react-native-languages/index.js", + "node_modules/react-native-camera/src/index.js", + "node_modules/react-native-camera/src/Camera.js", + "node_modules/react-native-camera/node_modules/prop-types/index.js", + "node_modules/react-native-camera/node_modules/prop-types/factoryWithTypeCheckers.js", + "node_modules/react-native-camera/node_modules/prop-types/lib/ReactPropTypesSecret.js", + "node_modules/react-native-camera/node_modules/prop-types/checkPropTypes.js", + "node_modules/react-native-camera/src/RNCamera.js", + "node_modules/react-native-camera/src/FaceDetector.js", + "node_modules/react-native-svg/index.js", + "node_modules/react-native-svg/elements/Rect.js", + "node_modules/react-native-svg/lib/extract/extractProps.js", + "node_modules/react-native-svg/lib/extract/extractFill.js", + "node_modules/react-native-svg/lib/extract/extractBrush.js", + "node_modules/react-native-svg/lib/extract/extractColor.js", + "node_modules/react-native-svg/lib/extract/extractOpacity.js", + "node_modules/react-native-svg/lib/extract/extractStroke.js", + "node_modules/react-native-svg/lib/extract/extractLengthList.js", + "node_modules/react-native-svg/lib/extract/extractClipPath.js", + "node_modules/react-native-svg/lib/extract/extractResponder.js", + "node_modules/react-native-svg/lib/extract/extractTransform.js", + "node_modules/react-native-svg/lib/Matrix2D.js", + "node_modules/react-native-svg/lib/extract/transform.js", + "node_modules/react-native-svg/elements/Shape.js", + "node_modules/react-native-svg/lib/SvgTouchableMixin.js", + "node_modules/react-native-svg/elements/Circle.js", + "node_modules/react-native-svg/elements/Ellipse.js", + "node_modules/react-native-svg/elements/Polygon.js", + "node_modules/react-native-svg/elements/Path.js", + "node_modules/react-native-svg/lib/extract/extractPolyPoints.js", + "node_modules/react-native-svg/elements/Polyline.js", + "node_modules/react-native-svg/elements/Line.js", + "node_modules/react-native-svg/elements/Svg.js", + "node_modules/react-native-svg/lib/extract/extractViewBox.js", + "node_modules/react-native-svg/elements/G.js", + "node_modules/react-native-svg/lib/extract/extractText.js", + "node_modules/react-native-svg/elements/Text.js", + "node_modules/react-native-svg/elements/TSpan.js", + "node_modules/react-native-svg/elements/TextPath.js", + "node_modules/react-native-svg/elements/Use.js", + "node_modules/react-native-svg/elements/Image.js", + "node_modules/react-native-svg/elements/Symbol.js", + "node_modules/react-native-svg/elements/Defs.js", + "node_modules/react-native-svg/elements/LinearGradient.js", + "node_modules/react-native-svg/lib/extract/extractGradient.js", + "node_modules/react-native-svg/lib/units.js", + "node_modules/react-native-svg/elements/RadialGradient.js", + "node_modules/react-native-svg/elements/Stop.js", + "node_modules/react-native-svg/elements/ClipPath.js", + "node_modules/react-native-svg/elements/Pattern.js", + "node_modules/react-native-svg/elements/Mask.js", + "node_modules/react-native-firebase/dist/index.js", + "node_modules/react-native-firebase/dist/modules/core/firebase.js", + "node_modules/react-native-firebase/dist/utils/apps.js", + "node_modules/react-native-firebase/dist/modules/core/app.js", + "node_modules/react-native-firebase/dist/utils/internals.js", + "node_modules/react-native-firebase/dist/modules/admob/index.js", + "node_modules/react-native-firebase/dist/utils/ModuleBase.js", + "node_modules/react-native-firebase/dist/utils/native.js", + "node_modules/react-native-firebase/dist/utils/events.js", + "node_modules/react-native-firebase/dist/utils/emitter/EventEmitter.js", + "node_modules/react-native-firebase/dist/utils/emitter/EventSubscriptionVendor.js", + "node_modules/react-native-firebase/dist/utils/emitter/EmitterSubscription.js", + "node_modules/react-native-firebase/dist/utils/emitter/EventSubscription.js", + "node_modules/react-native-firebase/dist/utils/log.js", + "node_modules/react-native-firebase/dist/modules/admob/Interstitial.js", + "node_modules/react-native-firebase/dist/modules/admob/AdRequest.js", + "node_modules/react-native-firebase/dist/utils/index.js", + "node_modules/react-native-firebase/dist/modules/admob/RewardedVideo.js", + "node_modules/react-native-firebase/dist/modules/admob/VideoOptions.js", + "node_modules/react-native-firebase/dist/modules/admob/Banner.js", + "node_modules/react-native-firebase/dist/modules/admob/AdMobComponent.js", + "node_modules/react-native-firebase/node_modules/prop-types/index.js", + "node_modules/react-native-firebase/node_modules/prop-types/factoryWithTypeCheckers.js", + "node_modules/react-native-firebase/node_modules/prop-types/lib/ReactPropTypesSecret.js", + "node_modules/react-native-firebase/node_modules/prop-types/checkPropTypes.js", + "node_modules/react-native-firebase/dist/modules/admob/EventTypes.js", + "node_modules/react-native-firebase/dist/modules/admob/NativeExpress.js", + "node_modules/react-native-firebase/dist/modules/auth/index.js", + "node_modules/react-native-firebase/dist/modules/auth/User.js", + "node_modules/react-native-firebase/dist/modules/auth/phone/ConfirmationResult.js", + "node_modules/react-native-firebase/dist/modules/auth/phone/PhoneAuthListener.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/EmailAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/PhoneAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/GoogleAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/GithubAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/OAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/TwitterAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/auth/providers/FacebookAuthProvider.js", + "node_modules/react-native-firebase/dist/modules/analytics/index.js", + "node_modules/react-native-firebase/dist/modules/config/index.js", + "node_modules/react-native-firebase/dist/modules/crashlytics/index.js", + "node_modules/react-native-firebase/dist/modules/database/index.js", + "node_modules/react-native-firebase/dist/modules/database/Reference.js", + "node_modules/react-native-firebase/dist/modules/database/Query.js", + "node_modules/react-native-firebase/dist/modules/database/DataSnapshot.js", + "node_modules/react-native-firebase/dist/modules/database/OnDisconnect.js", + "node_modules/react-native-firebase/dist/utils/ReferenceBase.js", + "node_modules/react-native-firebase/dist/utils/SyncTree.js", + "node_modules/react-native-firebase/dist/modules/database/transaction.js", + "node_modules/react-native-firebase/dist/modules/firestore/index.js", + "node_modules/react-native-firebase/dist/modules/firestore/CollectionReference.js", + "node_modules/react-native-firebase/dist/modules/firestore/DocumentReference.js", + "node_modules/react-native-firebase/dist/modules/firestore/DocumentSnapshot.js", + "node_modules/react-native-firebase/dist/modules/firestore/FieldPath.js", + "node_modules/react-native-firebase/dist/modules/firestore/Path.js", + "node_modules/react-native-firebase/dist/modules/firestore/Blob.js", + "node_modules/react-native-firebase/dist/utils/Base64.js", + "node_modules/react-native-firebase/dist/modules/firestore/GeoPoint.js", + "node_modules/react-native-firebase/dist/modules/firestore/FieldValue.js", + "node_modules/react-native-firebase/dist/modules/firestore/Query.js", + "node_modules/react-native-firebase/dist/modules/firestore/QuerySnapshot.js", + "node_modules/react-native-firebase/dist/modules/firestore/DocumentChange.js", + "node_modules/react-native-firebase/dist/modules/firestore/WriteBatch.js", + "node_modules/react-native-firebase/dist/modules/firestore/TransactionHandler.js", + "node_modules/react-native-firebase/dist/modules/firestore/Transaction.js", + "node_modules/react-native-firebase/dist/modules/functions/index.js", + "node_modules/react-native-firebase/dist/modules/functions/HttpsError.js", + "node_modules/react-native-firebase/dist/modules/iid/index.js", + "node_modules/react-native-firebase/dist/modules/invites/index.js", + "node_modules/react-native-firebase/dist/modules/invites/Invitation.js", + "node_modules/react-native-firebase/dist/modules/invites/AndroidInvitation.js", + "node_modules/react-native-firebase/dist/modules/links/index.js", + "node_modules/react-native-firebase/dist/modules/links/DynamicLink.js", + "node_modules/react-native-firebase/dist/modules/links/AnalyticsParameters.js", + "node_modules/react-native-firebase/dist/modules/links/AndroidParameters.js", + "node_modules/react-native-firebase/dist/modules/links/IOSParameters.js", + "node_modules/react-native-firebase/dist/modules/links/ITunesParameters.js", + "node_modules/react-native-firebase/dist/modules/links/NavigationParameters.js", + "node_modules/react-native-firebase/dist/modules/links/SocialParameters.js", + "node_modules/react-native-firebase/dist/modules/messaging/index.js", + "node_modules/react-native-firebase/dist/modules/messaging/RemoteMessage.js", + "node_modules/react-native-firebase/dist/modules/notifications/index.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidAction.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidRemoteInput.js", + "node_modules/react-native-firebase/dist/modules/notifications/types.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidChannel.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidChannelGroup.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidNotifications.js", + "node_modules/react-native-firebase/dist/modules/notifications/IOSNotifications.js", + "node_modules/react-native-firebase/dist/modules/notifications/Notification.js", + "node_modules/react-native-firebase/dist/modules/notifications/AndroidNotification.js", + "node_modules/react-native-firebase/dist/modules/notifications/IOSNotification.js", + "node_modules/react-native-firebase/dist/modules/perf/index.js", + "node_modules/react-native-firebase/dist/modules/perf/Trace.js", + "node_modules/react-native-firebase/dist/modules/perf/HttpMetric.js", + "node_modules/react-native-firebase/dist/modules/storage/index.js", + "node_modules/react-native-firebase/dist/modules/storage/reference.js", + "node_modules/react-native-firebase/dist/modules/storage/task.js", + "node_modules/react-native-firebase/dist/modules/utils/index.js", + "node_modules/react-native-firebase/dist/version.js", + "node_modules/react-navigation/src/react-navigation.js", + "node_modules/react-navigation/src/createNavigationContainer.js", + "node_modules/react-navigation/src/NavigationActions.js", + "node_modules/react-navigation/src/getNavigation.js", + "node_modules/react-navigation/src/routers/getNavigationActionCreators.js", + "node_modules/react-navigation/src/utils/invariant.js", + "node_modules/react-navigation/src/getChildNavigation.js", + "node_modules/react-navigation/src/getChildEventSubscriber.js", + "node_modules/react-navigation/src/getChildRouter.js", + "node_modules/react-navigation/src/utils/docsUrl.js", + "node_modules/react-navigation/src/routers/pathUtils.js", + "node_modules/path-to-regexp/index.js", + "node_modules/path-to-regexp/node_modules/isarray/index.js", + "node_modules/react-lifecycles-compat/react-lifecycles-compat.cjs.js", + "node_modules/react-navigation/src/StateUtils.js", + "node_modules/react-navigation/src/navigators/createNavigator.js", + "node_modules/react-navigation/src/navigators/createKeyboardAwareNavigator.js", + "node_modules/react-navigation/src/views/NavigationContext.js", + "node_modules/create-react-context/lib/index.js", + "node_modules/create-react-context/lib/implementation.js", + "node_modules/gud/index.js", + "node_modules/react-navigation-stack/dist/index.js", + "node_modules/react-navigation-stack/dist/navigators/createContainedStackNavigator.js", + "node_modules/react-navigation-stack/dist/navigators/createStackNavigator.js", + "node_modules/react-navigation-stack/dist/views/StackView/StackView.js", + "node_modules/react-navigation-stack/dist/views/StackView/StackViewLayout.js", + "node_modules/react-navigation-stack/dist/utils/clamp.js", + "node_modules/react-navigation-stack/dist/views/StackView/StackViewCard.js", + "node_modules/react-navigation-stack/dist/views/StackView/createPointerEventsContainer.js", + "node_modules/react-navigation-stack/dist/utils/invariant.js", + "node_modules/react-native-screens/src/screens.native.js", + "node_modules/react-navigation-stack/dist/views/Header/Header.js", + "node_modules/react-navigation-stack/dist/views/Header/HeaderTitle.js", + "node_modules/react-navigation-stack/dist/views/Header/HeaderBackButton.js", + "node_modules/react-navigation-stack/dist/views/TouchableItem.js", + "node_modules/react-navigation-stack/dist/views/assets/back-icon.png", + "node_modules/react-navigation-stack/dist/views/Header/ModularHeaderBackButton.js", + "node_modules/react-navigation-stack/dist/views/Header/HeaderStyleInterpolator.js", + "node_modules/react-navigation-stack/dist/utils/getSceneIndicesForInterpolationInputRange.js", + "node_modules/react-navigation-stack/dist/views/StackView/StackViewTransitionConfigs.js", + "node_modules/react-navigation-stack/dist/views/StackView/StackViewStyleInterpolator.js", + "node_modules/react-navigation-stack/dist/utils/ReactNativeFeatures.js", + "node_modules/react-navigation-stack/dist/views/Transitioner.js", + "node_modules/react-navigation-stack/dist/views/ScenesReducer.js", + "node_modules/react-navigation-stack/dist/utils/shallowEqual.js", + "node_modules/react-navigation/src/navigators/createContainedSwitchNavigator.js", + "node_modules/react-navigation/src/navigators/createSwitchNavigator.js", + "node_modules/react-navigation/src/routers/SwitchRouter.js", + "node_modules/react-navigation/src/routers/getScreenForRouteName.js", + "node_modules/react-is/index.js", + "node_modules/react-is/cjs/react-is.production.min.js", + "node_modules/react-navigation/src/routers/createConfigGetter.js", + "node_modules/react-navigation/src/routers/validateScreenOptions.js", + "node_modules/react-navigation/src/routers/StackActions.js", + "node_modules/react-navigation/src/routers/validateRouteConfigMap.js", + "node_modules/react-navigation/src/views/SwitchView/SwitchView.js", + "node_modules/react-navigation/src/views/SceneView.js", + "node_modules/react-navigation-drawer/dist/index.js", + "node_modules/react-navigation-drawer/dist/navigators/createDrawerNavigator.js", + "node_modules/react-navigation-drawer/dist/routers/DrawerRouter.js", + "node_modules/react-navigation-drawer/dist/routers/DrawerActions.js", + "node_modules/react-navigation-drawer/dist/views/DrawerView.js", + "node_modules/react-native-drawer-layout-polyfill/dist/index.android.js", + "node_modules/react-navigation-drawer/dist/views/DrawerSidebar.js", + "node_modules/react-navigation-drawer/dist/utils/invariant.js", + "node_modules/react-navigation-drawer/dist/views/DrawerNavigatorItems.js", + "node_modules/react-navigation-drawer/dist/views/TouchableItem.js", + "node_modules/react-navigation-tabs/src/index.js", + "node_modules/react-navigation-tabs/src/navigators/createBottomTabNavigator.js", + "node_modules/react-navigation-tabs/src/utils/createTabNavigator.js", + "node_modules/react-navigation-tabs/src/views/BottomTabBar.js", + "node_modules/react-navigation-tabs/src/views/CrossFadeIcon.js", + "node_modules/react-navigation-tabs/src/utils/withDimensions.js", + "node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js", + "node_modules/react-navigation-tabs/src/views/ResourceSavingScene.js", + "node_modules/react-navigation/src/routers/StackRouter.js", + "node_modules/react-navigation/src/routers/KeyGenerator.js", + "node_modules/react-navigation/src/routers/TabRouter.js", + "node_modules/react-navigation/src/utils/withDefaultValue.js", + "node_modules/react-navigation/src/views/NavigationEvents.js", + "node_modules/react-navigation/src/views/withNavigation.js", + "node_modules/react-navigation/src/views/withOrientation.js", + "resources/images/ui/dapp-store.png"]; diff --git a/react-native/src/desktop/status_im/react_native/js_dependencies.cljs b/react-native/src/desktop/status_im/react_native/js_dependencies.cljs index 6c1476b538..ae6eb8d308 100644 --- a/react-native/src/desktop/status_im/react_native/js_dependencies.cljs +++ b/react-native/src/desktop/status_im/react_native/js_dependencies.cljs @@ -1,37 +1,38 @@ -(ns status-im.react-native.js-dependencies) +(ns status-im.react-native.js-dependencies + (:require-macros [status-im.utils.js-require :as js-require])) -(def config (js/require "react-native-config")) -(def fs (js/require "react-native-fs")) -(def http-bridge (js/require "react-native-http-bridge")) -(def keychain (js/require "react-native-keychain")) -(def qr-code (js/require "react-native-qrcode")) +(def config (js-require/js-require "react-native-config")) +(def fs (js-require/js-require "react-native-fs")) +(def http-bridge (js-require/js-require "react-native-http-bridge")) +(def keychain (js-require/js-require "react-native-keychain")) +(def qr-code (js-require/js-require "react-native-qrcode")) (def react-native (js/require "react-native")) (def realm (js/require "realm")) (def webview-bridge (js/require "react-native-webview-bridge")) (def webview #js {:WebView #js {}}) -(def secure-random (.-generateSecureRandom (js/require "react-native-securerandom"))) -(def EventEmmiter (js/require "react-native/Libraries/vendor/emitter/EventEmitter")) -(def fetch (.-default (js/require "react-native-fetch-polyfill"))) +(def securerandom (js-require/js-require "react-native-securerandom")) +(defn secure-random [] (.-generateSecureRandom (securerandom))) +(def fetch-polyfill (js-require/js-require "react-native-fetch-polyfill")) +(defn fetch [] (.-default (fetch-polyfill))) (def i18n (js/require "i18n-js")) (def react-native-languages (.-default (js/require "react-native-languages"))) (def desktop-linking (.-DesktopLinking (.-NativeModules react-native))) (def desktop-menu (js/require "react-native-desktop-menu")) (def desktop-config (js/require "react-native-desktop-config")) (def desktop-shortcuts (js/require "react-native-desktop-shortcuts")) -(def react-native-firebase #js {}) -(def camera #js {:default #js {:constants {:Aspect "Portrait"}}}) -(def status-keycard #js {:default #js {}}) -(def dialogs #js {}) -(def dismiss-keyboard #js {}) -(def image-crop-picker #js {}) -(def image-resizer #js {}) -(def nfc #js {}) +(def react-native-firebase (fn [] #js {})) +(def camera (fn [] #js {:default #js {:constants {:Aspect "Portrait"}}})) +(def status-keycard (fn [] #js {:default #js {}})) +(def dialogs (fn [] #js {})) +(def dismiss-keyboard (fn [] #js {})) +(def image-crop-picker (fn [] #js {})) +(def image-resizer (fn [] #js {})) (def svg #js {}) -(def snoopy #js {}) -(def snoopy-filter #js {}) -(def snoopy-bars #js {}) -(def snoopy-buffer #js {}) -(def background-timer #js {:setTimeout (fn [cb ms] (js/setTimeout cb ms))}) +(def snoopy (fn [] #js {})) +(def snoopy-filter (fn [] #js {})) +(def snoopy-bars (fn [] #js {})) +(def snoopy-buffer (fn [] #js {})) +(def background-timer (fn [] #js {:setTimeout (fn [cb ms] (js/setTimeout cb ms))})) (def react-navigation (js/require "react-navigation")) -(def react-native-shake #js {}) -(def react-native-mail #js {:mail (fn [])}) +(def react-native-shake (fn [] #js {})) +(def react-native-mail (fn [] #js {:mail (fn [])})) diff --git a/react-native/src/mobile/status_im/react_native/js_dependencies.cljs b/react-native/src/mobile/status_im/react_native/js_dependencies.cljs index 127683847d..c9f14f99c4 100644 --- a/react-native/src/mobile/status_im/react_native/js_dependencies.cljs +++ b/react-native/src/mobile/status_im/react_native/js_dependencies.cljs @@ -1,35 +1,39 @@ -(ns status-im.react-native.js-dependencies) +(ns status-im.react-native.js-dependencies + (:require-macros [status-im.utils.js-require :as js-require])) -(def config (js/require "react-native-config")) -(def fs (js/require "react-native-fs")) -(def http-bridge (js/require "react-native-http-bridge")) -(def keychain (js/require "react-native-keychain")) -(def qr-code (js/require "react-native-qrcode")) +(def config (js-require/js-require "react-native-config")) +(def fs (js-require/js-require "react-native-fs")) +(def http-bridge (js-require/js-require "react-native-http-bridge")) +(def keychain (js-require/js-require "react-native-keychain")) +(def qr-code (js-require/js-require "react-native-qrcode")) (def react-native (js/require "react-native")) -(def status-keycard (js/require "react-native-status-keycard")) +(def status-keycard (js-require/js-require "react-native-status-keycard")) (def realm (js/require "realm")) -(def webview-bridge (js/require "react-native-webview-bridge")) -(def webview (js/require "react-native-webview")) -(def secure-random (.-generateSecureRandom (js/require "react-native-securerandom"))) -(def EventEmmiter (js/require "react-native/Libraries/vendor/emitter/EventEmitter")) -(def fetch (.-default (js/require "react-native-fetch-polyfill"))) +(def webview-bridge (js-require/js-require "react-native-webview-bridge")) +(def webview (js-require/js-require "react-native-webview")) +(def securerandom (js-require/js-require "react-native-securerandom")) +(defn secure-random [] (.-generateSecureRandom (securerandom))) +(def fetch-polyfill (js-require/js-require "react-native-fetch-polyfill")) +(defn fetch [] (.-default (fetch-polyfill))) (def i18n (js/require "i18n-js")) (def react-native-languages (.-default (js/require "react-native-languages"))) -(def camera (js/require "react-native-camera")) -(def dialogs (js/require "react-native-dialogs")) -(def dismiss-keyboard (js/require "dismissKeyboard")) -(def image-crop-picker (js/require "react-native-image-crop-picker")) -(def image-resizer (js/require "react-native-image-resizer")) +(def camera (js-require/js-require "react-native-camera")) +(def dialogs (js-require/js-require "react-native-dialogs")) +(def dismiss-keyboard (js-require/js-require "dismissKeyboard")) +(def image-crop-picker (js-require/js-require "react-native-image-crop-picker")) +(def image-resizer (js-require/js-require "react-native-image-resizer")) (def svg (js/require "react-native-svg")) -(def react-native-firebase (js/require "react-native-firebase")) -(def snoopy (js/require "rn-snoopy")) -(def snoopy-filter (js/require "rn-snoopy/stream/filter")) -(def snoopy-bars (js/require "rn-snoopy/stream/bars")) -(def snoopy-buffer (js/require "rn-snoopy/stream/buffer")) -(def background-timer (.-default (js/require "react-native-background-timer"))) +(def react-native-firebase (js-require/js-require "react-native-firebase")) +(def snoopy (js-require/js-require "rn-snoopy")) +(def snoopy-filter (js-require/js-require "rn-snoopy/stream/filter")) +(def snoopy-bars (js-require/js-require "rn-snoopy/stream/bars")) +(def snoopy-buffer (js-require/js-require "rn-snoopy/stream/buffer")) +(def background-timer-class (js-require/js-require "react-native-background-timer")) +(defn background-timer [] (.-default (background-timer-class))) (def react-navigation (js/require "react-navigation")) -(def react-native-shake (js/require "react-native-shake")) -(def react-native-mail (.-default (js/require "react-native-mail"))) +(def react-native-shake (js-require/js-require "react-native-shake")) +(def mail-class (js-require/js-require "react-native-mail")) +(defn react-native-mail [] (.-default (mail-class))) (def desktop-linking #js {:addEventListener (fn [])}) (def desktop-menu #js {:addEventListener (fn [])}) (def desktop-config #js {:addEventListener (fn [])}) diff --git a/scripts/start-react-native.sh b/scripts/start-react-native.sh index 589f4c064d..bc25c03ad2 100755 --- a/scripts/start-react-native.sh +++ b/scripts/start-react-native.sh @@ -15,4 +15,4 @@ if [ ! -z "$METRO_PID" ]; then [[ $term == 'y' ]] && kill $METRO_PID fi -react-native start +react-native start --config packager/config.js diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index b90e163b99..38e7694c38 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -29,7 +29,7 @@ (reagent/create-class {:component-will-mount (fn [] - (.addListener react/keyboard + (.addListener (react/keyboard) "keyboardDidShow" (fn [e] (let [h (.. e -endCoordinates -height)] @@ -37,16 +37,16 @@ (when-not (= h @keyboard-height) (dispatch [:set :keyboard-height h]) (dispatch [:set :keyboard-max-height h]))))) - (.addListener react/keyboard + (.addListener (react/keyboard) "keyboardDidHide" (fn [_] (dispatch [:show-tab-bar]) (when-not (zero? @keyboard-height) (dispatch [:set :keyboard-height 0])))) (.hide react/splash-screen) - (.addEventListener react/app-state "change" app-state-change-handler) + (.addEventListener (react/app-state) "change" app-state-change-handler) (.addEventListener rn-dependencies/react-native-languages "change" on-languages-change) - (.addEventListener rn-dependencies/react-native-shake + (.addEventListener (rn-dependencies/react-native-shake) "ShakeEvent" on-shake)) :component-did-mount @@ -54,10 +54,10 @@ (dispatch [:set-initial-props (reagent/props this)])) :component-will-unmount (fn [] - (.stop react/http-bridge) - (.removeEventListener react/app-state "change" app-state-change-handler) + (.stop (react/http-bridge)) + (.removeEventListener (react/app-state) "change" app-state-change-handler) (.removeEventListener rn-dependencies/react-native-languages "change" on-languages-change) - (.removeEventListener rn-dependencies/react-native-shake + (.removeEventListener (rn-dependencies/react-native-shake) "ShakeEvent" on-shake)) :display-name "root" diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index ca0f7f73a1..b886aae49e 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -63,7 +63,7 @@ (defn check-if-phishing-url [{:keys [history history-index] :as browser}] (let [history-host (http/url-host (try (nth history history-index) (catch js/Error _)))] - (cond-> browser history-host (assoc :unsafe? (js-dependencies/phishing-detect history-host))))) + (cond-> browser history-host (assoc :unsafe? ((js-dependencies/phishing-detect) history-host))))) (defn- content->hash [hex] (when (and hex (not= hex "0x")) @@ -155,7 +155,7 @@ (defmethod storage-gateway :ipfs [{:keys [hash]}] - (let [base32hash (-> (.encode js-dependencies/hi-base32 (alphabase.base58/decode hash)) + (let [base32hash (-> (.encode (js-dependencies/hi-base32) (alphabase.base58/decode hash)) (string/replace #"=" "") (string/lower-case))] (str base32hash ".infura.status.im"))) diff --git a/src/status_im/chat/commands/impl/transactions.cljs b/src/status_im/chat/commands/impl/transactions.cljs index 1c31f7e32a..4fefc91f42 100644 --- a/src/status_im/chat/commands/impl/transactions.cljs +++ b/src/status_im/chat/commands/impl/transactions.cljs @@ -401,7 +401,7 @@ {:on-press on-press-handler :style transactions-styles/command-request-image-touchable :accessibility-label (request-button-label (:name command))} - [react/animated-view {:style (transactions-styles/command-request-image-view command scale-anim-val)} + [(react/animated-view) {:style (transactions-styles/command-request-image-view command scale-anim-val)} (when command-icon [react/icon command-icon transactions-styles/command-request-image])]]))}))) diff --git a/src/status_im/chat/models/input.cljs b/src/status_im/chat/models/input.cljs index 5ffa071846..11c4ada477 100644 --- a/src/status_im/chat/models/input.cljs +++ b/src/status_im/chat/models/input.cljs @@ -21,7 +21,7 @@ (string/replace text #":([a-z_\-+0-9]*):" (fn [[original emoji-id]] - (if-let [emoji-map (object/get (object/get dependencies/emojis "lib") emoji-id)] + (if-let [emoji-map (object/get (object/get (dependencies/emojis) "lib") emoji-id)] (object/get emoji-map "char") original))))) diff --git a/src/status_im/chat/models/message.cljs b/src/status_im/chat/models/message.cljs index 0b1e067613..bad02941fb 100644 --- a/src/status_im/chat/models/message.cljs +++ b/src/status_im/chat/models/message.cljs @@ -365,8 +365,17 @@ (def ^:private transport-keys [:content :content-type :message-type :clock-value :timestamp]) +(defn remove-icon + "Coin's icon's resource is represented as a function, + can't be properly de/serialised and has to be removed." + [message] + (cond-> message + (get-in message [:content :params :coin :icon :source]) + (update-in [:content :params :coin] dissoc :icon))) + (fx/defn upsert-and-send [{:keys [now] :as cofx} {:keys [chat-id from] :as message}] - (let [send-record (protocol/map->Message (select-keys message transport-keys)) + (let [message (remove-icon message) + send-record (protocol/map->Message (select-keys message transport-keys)) old-message-id (transport.utils/old-message-id send-record) wrapped-record (if (= (:message-type send-record) :group-user-message) (wrap-group-message cofx chat-id send-record) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index be7433df80..66d4858225 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -222,8 +222,14 @@ (def ^:const status-create-address "status_createaddress") -(def ^:const event-transfer-hash - (ethereum/sha3 "Transfer(address,address,uint256)")) +(def event-transfer-hash + (let [hash (atom nil)] + (fn [] + (if @hash + @hash + (reset! + hash + (ethereum/sha3 "Transfer(address,address,uint256)")))))) (def regx-emoji #"^((?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])+$") (def regx-rtl-characters #"[^\u0591-\u06EF\u06FA-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC]*?[\u0591-\u06EF\u06FA-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC]") diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index 6fc2566fde..78790dabc4 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -66,7 +66,7 @@ (upsert-contact contact) (mailserver/upsert-mailserver-topic {:chat-ids [public-key] - :topic transport.topic/discovery-topic-hash + :topic (transport.topic/discovery-topic-hash) :fetch? false}) (send-contact-request contact) (mailserver/process-next-messages-request))))) diff --git a/src/status_im/contact/db.cljs b/src/status_im/contact/db.cljs index cc2fcf9026..e73f8d666c 100644 --- a/src/status_im/contact/db.cljs +++ b/src/status_im/contact/db.cljs @@ -66,7 +66,7 @@ 128 public-key nil)] (when normalized-key - (subs (.sha3 js-dependencies/Web3.prototype normalized-key #js {:encoding "hex"}) 26)))) + (subs (.sha3 (js-dependencies/web3-prototype) normalized-key #js {:encoding "hex"}) 26)))) (defn public-key->new-contact [public-key] {:name (gfycat/generate-gfy public-key) diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index 472e9298b8..3a497eb484 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -5,7 +5,8 @@ [status-im.constants :as constants] [status-im.data-store.realm.core :as core] [status-im.utils.core :as utils] - [status-im.js-dependencies :as dependencies])) + [status-im.js-dependencies :as dependencies] + [taoensso.timbre :as log])) (defn- transform-message [{:keys [content] :as message}] (when-let [parsed-content (utils/safe-read-message-content content)] @@ -78,7 +79,7 @@ (assoc cofx :get-stored-messages get-by-chat-id))) (defn- sha3 [s] - (.sha3 dependencies/Web3.prototype s)) + (.sha3 (dependencies/web3-prototype) s)) (re-frame/reg-cofx :data-store/get-referenced-messages diff --git a/src/status_im/data_store/realm/core.cljs b/src/status_im/data_store/realm/core.cljs index 4c434fb484..13091b9a2e 100644 --- a/src/status_im/data_store/realm/core.cljs +++ b/src/status_im/data_store/realm/core.cljs @@ -154,7 +154,7 @@ (open-realm (last schemas) file-name encryption-key)) (defn keccak512-array [key] - (.array (.-keccak512 js-dependencies/js-sha3) key)) + (.array (.-keccak512 (js-dependencies/js-sha3)) key)) (defn merge-Uint8Arrays [arr1 arr2] (let [arr1-length (.-length arr1) @@ -165,8 +165,9 @@ arr)) (defn db-encryption-key [password encryption-key] - (let [password-array (.encode - (new (.-TextEncoder js-dependencies/text-encoding)) + (let [TextEncoder (.-TextEncoder (js-dependencies/text-encoding)) + password-array (.encode + (new TextEncoder) password)] (keccak512-array (merge-Uint8Arrays encryption-key password-array)))) diff --git a/src/status_im/data_store/realm/schemas/account/migrations.cljs b/src/status_im/data_store/realm/schemas/account/migrations.cljs index 80852662a6..d88f34ed40 100644 --- a/src/status_im/data_store/realm/schemas/account/migrations.cljs +++ b/src/status_im/data_store/realm/schemas/account/migrations.cljs @@ -191,7 +191,7 @@ "status-im.transport.message.protocol")) (defn sha3 [s] - (.sha3 dependencies/Web3.prototype s)) + (.sha3 (dependencies/web3-prototype) s)) (defn old-message-id "Calculates the same `message-id` as was used in `0.9.31`" diff --git a/src/status_im/desktop/core.cljs b/src/status_im/desktop/core.cljs index c5961f4817..80198a4b37 100644 --- a/src/status_im/desktop/core.cljs +++ b/src/status_im/desktop/core.cljs @@ -24,14 +24,14 @@ (reagent/create-class {:component-will-mount (fn [] - (.addEventListener react/app-state "change" app-state-change-handler)) + (.addEventListener (react/app-state) "change" app-state-change-handler)) :component-did-mount (fn [this] (re-frame/dispatch [:set-initial-props (reagent/props this)])) :component-will-unmount (fn [] - (.stop react/http-bridge) - (.removeEventListener react/app-state "change" app-state-change-handler)) + (.stop (react/http-bridge)) + (.removeEventListener (react/app-state) "change" app-state-change-handler)) :display-name "root" :reagent-render views/main}) (reagent/create-class diff --git a/src/status_im/dev_server/core.cljs b/src/status_im/dev_server/core.cljs index 27dc252408..4fed3865a4 100644 --- a/src/status_im/dev_server/core.cljs +++ b/src/status_im/dev_server/core.cljs @@ -11,14 +11,14 @@ "Status Android")) (defn respond! [request-id status-code data] - (.respond react/http-bridge + (.respond (react/http-bridge) request-id status-code "application/json" (types/clj->json data))) (defn start! [] - (.start react/http-bridge + (.start (react/http-bridge) port server-name (fn [req] @@ -33,4 +33,4 @@ (log/debug "Error: " e)))))) (defn stop! [] - (.stop react/http-bridge)) \ No newline at end of file + (.stop (react/http-bridge))) diff --git a/src/status_im/ethereum/abi_spec.cljs b/src/status_im/ethereum/abi_spec.cljs index 562d636dc6..158eff74a1 100644 --- a/src/status_im/ethereum/abi_spec.cljs +++ b/src/status_im/ethereum/abi_spec.cljs @@ -4,54 +4,54 @@ [status-im.js-dependencies :as dependencies])) ;; Utility functions for encoding -(def utils dependencies/web3-utils) +(defn utils [] (dependencies/web3-utils)) (defn right-pad [x] (let [len (count x) to-pad (- 64 (mod len 64))] (if (= 64 to-pad) x - (.rightPad utils x (+ len to-pad))))) + (.rightPad (utils) x (+ len to-pad))))) (defn left-pad [x] (let [len (count x) to-pad (- 64 (mod len 64))] (if (= 64 to-pad) x - (.leftPad utils x (+ len to-pad))))) + (.leftPad (utils) x (+ len to-pad))))) (defn to-two-complement [x] (when x - (subs (.toTwosComplement utils x) 2))) + (subs (.toTwosComplement (utils) x) 2))) (defn from-utf8 [x] (when x - (subs (.fromUtf8 utils x) 2))) + (subs (.fromUtf8 (utils) x) 2))) (defn hex-to-boolean [x] (= x "0x0")) (defn bytes-to-hex [x] (when x - (subs (.bytesToHex utils x) 2))) + (subs (.bytesToHex (utils) x) 2))) (defn number-to-hex [x] (when x - (subs (.numberToHex utils x) 2))) + (subs (.numberToHex (utils) x) 2))) (defn hex-to-utf8 [x] - (.hexToUtf8 utils (str "0x" x))) + (.hexToUtf8 (utils) (str "0x" x))) (defn hex-to-number [x] (when x (let [hex-x (str "0x" x)] (try - (.hexToNumber utils hex-x) + (.hexToNumber (utils) hex-x) (catch :default err - (.hexToNumberString utils hex-x)))))) + (.hexToNumberString (utils) hex-x)))))) (defn sha3 [s] - (.sha3 utils (str s))) + (.sha3 (utils) (str s))) (defn is-hex? [value] (when value diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index 8b7007b599..e710072849 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -49,7 +49,7 @@ (defn address? [s] (when s - (.isAddress dependencies/Web3.prototype s))) + (.isAddress (dependencies/web3-prototype) s))) (defn network->chain-id [network] (get-in network [:config :NetworkId])) @@ -70,9 +70,9 @@ (defn sha3 ([s] - (.sha3 dependencies/Web3.prototype (str s))) + (.sha3 (dependencies/web3-prototype) (str s))) ([s opts] - (.sha3 dependencies/Web3.prototype (str s) (clj->js opts)))) + (.sha3 (dependencies/web3-prototype) (str s) (clj->js opts)))) (def default-transaction-gas (money/bignumber 21000)) diff --git a/src/status_im/ethereum/eip55.cljs b/src/status_im/ethereum/eip55.cljs index ca27a39306..e52f723db4 100644 --- a/src/status_im/ethereum/eip55.cljs +++ b/src/status_im/ethereum/eip55.cljs @@ -7,15 +7,15 @@ (:require [clojure.string :as string] [status-im.js-dependencies :as dependencies])) -(def utils dependencies/web3-utils) +(defn utils [] (dependencies/web3-utils)) (defn address->checksum "Converts an arbitrary case address to one with correct checksum case." [address] (when address - (.toChecksumAddress utils address))) + (.toChecksumAddress (utils) address))) (defn valid-address-checksum? "Checks address checksum validity." [address] - (.checkAddressChecksum utils address)) + (.checkAddressChecksum (utils) address)) diff --git a/src/status_im/ethereum/macros.clj b/src/status_im/ethereum/macros.clj index d3d13989f7..2009b03b3d 100644 --- a/src/status_im/ethereum/macros.clj +++ b/src/status_im/ethereum/macros.clj @@ -4,10 +4,19 @@ (defn token-icon-path [network symbol] - (let [s (str "./resources/images/tokens/" (name network) "/" (name symbol) ".png")] + (let [s (str "./resources/images/tokens/" (name network) "/" (name symbol) ".png") + image (gensym)] (if (.exists (io/file s)) - `(js/require ~s) - `(js/require "./resources/images/tokens/default-token.png")))) + `(let [~image (atom nil)] + (fn [] + (or @~image + (reset! ~image (js/require ~s))))) + `(let [~image (atom nil)] + (fn [] + (or + @~image + (reset! ~image + (js/require "./resources/images/tokens/default-token.png")))))))) (defn- token->icon [network {:keys [icon symbol]}] ;; Tokens can define their own icons. @@ -21,10 +30,19 @@ (mapv #(assoc-in % [:icon :source] (token->icon network %)) tokens)) (defn network->icon [network] - (let [s (str "./resources/images/tokens/" (name network) "/0-native.png")] + (let [s (str "./resources/images/tokens/" (name network) "/0-native.png") + image (gensym)] (if (.exists (io/file s)) - `(js/require ~s) - `(js/require "./resources/images/tokens/default-native.png")))) + `(let [~image (atom nil)] + (fn [] + (or @~image + (reset! ~image (js/require ~s))))) + `(let [~image (atom nil)] + (fn [] + (or + @~image + (reset! ~image + (js/require "./resources/images/tokens/default-native.png")))))))) (defmacro resolve-native-currency-icons "In react-native arguments to require must be static strings. diff --git a/src/status_im/ethereum/tokens.cljs b/src/status_im/ethereum/tokens.cljs index 0e57a69fa5..361e1404b6 100644 --- a/src/status_im/ethereum/tokens.cljs +++ b/src/status_im/ethereum/tokens.cljs @@ -7,10 +7,12 @@ {:border-color color :border-width 1 :border-radius 32}) (def default-native-currency - {:name "Native" - :symbol :ETH - :decimals 18 - :icon {:source (js/require "./resources/images/tokens/default-native.png")}}) + (memoize + (fn [] + {:name "Native" + :symbol :ETH + :decimals 18 + :icon {:source (js/require "./resources/images/tokens/default-native.png")}}))) (def all-native-currencies (ethereum.macros/resolve-native-currency-icons @@ -40,7 +42,7 @@ (set (map #(-> % val :symbol) all-native-currencies))) (defn native-currency [chain] - (-> (get all-native-currencies chain default-native-currency))) + (-> (get all-native-currencies chain (default-native-currency)))) (defn ethereum? [symbol] (native-currency-symbols symbol)) diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index bd40019d0e..bbf0c67e76 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -184,7 +184,7 @@ (def CUD-url "https://chaos-unicorn-day.org") (defn open-chaos-unicorn-day-link [] - (.openURL react/linking CUD-url)) + (.openURL (react/linking) CUD-url)) (handlers/register-handler-fx :accounts.ui/chaos-mode-switched diff --git a/src/status_im/extensions/capacities/components.cljs b/src/status_im/extensions/capacities/components.cljs index 258daf3de1..5fa75f0a47 100644 --- a/src/status_im/extensions/capacities/components.cljs +++ b/src/status_im/extensions/capacities/components.cljs @@ -47,8 +47,8 @@ [tooltip/tooltip error (styles/error error)])]) (defn touchable-opacity [{:keys [style on-press]} & children] - (into [react/touchable-opacity (merge (when on-press {:on-press #(on-press {})}) - (when style {:style style}))] children)) + (into [(react/touchable-opacity) (merge (when on-press {:on-press #(on-press {})}) + (when style {:style style}))] children)) (defn image [{:keys [source uri style]}] [react/image (merge {:style (merge {:width 100 :height 100} style)} {:source (if source source {:uri uri})})]) @@ -57,7 +57,7 @@ [react/text (merge {:style {:color colors/white :text-decoration-line :underline} :on-press (case open-in - :device #(.openURL react/linking uri) + :device #(.openURL (react/linking) uri) :status #(re-frame/dispatch [:browser.ui/open-in-status-option-selected uri]) #(re-frame/dispatch [:browser.ui/message-link-pressed uri]))} (when style {:style style})) @@ -119,7 +119,7 @@ (apply abstract-view react/view o children)) (defn scroll-view [o & children] - (apply abstract-view react/scroll-view o children)) + (apply abstract-view (react/scroll-view) o children)) (defn keyboard-avoiding-view [o & children] (apply abstract-view react/keyboard-avoiding-view o children)) @@ -158,4 +158,4 @@ :fly? :boolean :interactive? :boolean :on-change :event}} - 'map-link {:data map-link :properties {:text :string :lng :any :lat :any}}}) \ No newline at end of file + 'map-link {:data map-link :properties {:text :string :lng :any :lat :any}}}) diff --git a/src/status_im/extensions/capacities/map.cljs b/src/status_im/extensions/capacities/map.cljs index 54db3c55a7..1d4064dd7b 100644 --- a/src/status_im/extensions/capacities/map.cljs +++ b/src/status_im/extensions/capacities/map.cljs @@ -14,7 +14,9 @@ (def mapview-html (slurp "resources/mapview/mapview.html")) (def webview-class - (reagent/adapt-react-class (.-WebView js-dependencies/webview))) + (memoize + (fn [] + (reagent/adapt-react-class (.-WebView js-dependencies/webview))))) (defn map-component "creates a webview reagent component which cause webview to be updated only when style changes. @@ -32,7 +34,7 @@ false))) :reagent-render (fn [opts] - [webview-class opts])})) + [(webview-class) opts])})) (defn- on-map-message [map-event on-change] (let [data (-> map-event @@ -69,7 +71,7 @@ :on-should-start-load-with-request #(let [url (.-url %)] (if (string/starts-with? url "file") true - (do (.openURL react/linking url) false))) + (do (.openURL (react/linking) url) false))) :ref #(reset! webview %) :on-message #(when on-change (on-map-message % on-change)) @@ -78,4 +80,4 @@ (if (map? marker) (str "update(" (types/clj->json (assoc marker :fly fly? :interactive interactive?)) ");") (str "init(" (types/clj->json {:interactive interactive?}) ");")))} - webview])) \ No newline at end of file + webview])) diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index bd7b5ef9ac..f2aac1fa13 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -220,7 +220,7 @@ :db (assoc db :group/selected-contacts #{})} (mailserver/upsert-mailserver-topic {:chat-ids [chat-id] - :topic transport.topic/discovery-topic-hash + :topic (transport.topic/discovery-topic-hash) :fetch? false}) (mailserver/process-next-messages-request)))) @@ -257,7 +257,7 @@ :events [event]}} (mailserver/upsert-mailserver-topic {:chat-ids [chat-id] - :topic transport.topic/discovery-topic-hash + :topic (transport.topic/discovery-topic-hash) :fetch false}) (mailserver/process-next-messages-request))))) diff --git a/src/status_im/hardwallet/card.cljs b/src/status_im/hardwallet/card.cljs index 26fec3b934..d893314018 100644 --- a/src/status_im/hardwallet/card.cljs +++ b/src/status_im/hardwallet/card.cljs @@ -2,11 +2,11 @@ (:require [re-frame.core :as re-frame] [status-im.react-native.js-dependencies :as js-dependencies] [status-im.utils.config :as config] - [status-im.utils.platform :as platform] - [taoensso.timbre :as log])) + [status-im.utils.platform :as platform])) -(defonce keycard (.-default js-dependencies/status-keycard)) -(defonce event-emitter (.-DeviceEventEmitter js-dependencies/react-native)) +(defn keycard [] (.-default (js-dependencies/status-keycard))) +(defn event-emitter [] + (.-DeviceEventEmitter js-dependencies/react-native)) (defn- error-object->map [object] {:code (.-code object) @@ -15,24 +15,24 @@ (defn check-nfc-support [] (when (and config/hardwallet-enabled? platform/android?) - (.. keycard + (.. (keycard) nfcIsSupported (then #(re-frame/dispatch [:hardwallet.callback/check-nfc-support-success %]))))) (defn check-nfc-enabled [] (when (and config/hardwallet-enabled? platform/android?) - (.. keycard + (.. (keycard) nfcIsEnabled (then #(re-frame/dispatch [:hardwallet.callback/check-nfc-enabled-success %]))))) (defn open-nfc-settings [] (when platform/android? - (.openNfcSettings keycard))) + (.openNfcSettings (keycard)))) (defn remove-event-listeners [] (doseq [event ["keyCardOnConnected" "keyCardOnDisconnected"]] - (.removeAllListeners event-emitter event))) + (.removeAllListeners (event-emitter) event))) (defn register-card-events [] (when (and config/hardwallet-enabled?) @@ -41,38 +41,38 @@ (re-frame/dispatch [:hardwallet.callback/on-register-card-events {:on-card-connected - (.addListener event-emitter + (.addListener (event-emitter) "keyCardOnConnected" #(re-frame/dispatch [:hardwallet.callback/on-card-connected %])) :on-card-disconnected - (.addListener event-emitter + (.addListener (event-emitter) "keyCardOnDisconnected" #(re-frame/dispatch [:hardwallet.callback/on-card-disconnected %]))}]))) (defn get-application-info [{:keys [pairing on-success]}] - (.. keycard + (.. (keycard) (getApplicationInfo (str pairing)) (then #(re-frame/dispatch [:hardwallet.callback/on-get-application-info-success % on-success])) (catch #(re-frame/dispatch [:hardwallet.callback/on-get-application-info-error (error-object->map %)])))) (defn install-applet [] (when config/hardwallet-enabled? - (.. keycard + (.. (keycard) installApplet (then #(re-frame/dispatch [:hardwallet.callback/on-install-applet-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-install-applet-error (error-object->map %)]))))) (defn init-card [pin] (when config/hardwallet-enabled? - (.. keycard + (.. (keycard) (init pin) (then #(re-frame/dispatch [:hardwallet.callback/on-init-card-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-init-card-error (error-object->map %)]))))) (defn install-applet-and-init-card [pin] (when config/hardwallet-enabled? - (.. keycard + (.. (keycard) (installAppletAndInitCard pin) (then #(re-frame/dispatch [:hardwallet.callback/on-install-applet-and-init-card-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-install-applet-and-init-card-error (error-object->map %)]))))) @@ -80,7 +80,7 @@ (defn pair [{:keys [password]}] (when password - (.. keycard + (.. (keycard) (pair password) (then #(re-frame/dispatch [:hardwallet.callback/on-pairing-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-pairing-error (error-object->map %)]))))) @@ -88,7 +88,7 @@ (defn generate-mnemonic [{:keys [pairing words]}] (when pairing - (.. keycard + (.. (keycard) (generateMnemonic pairing words) (then #(re-frame/dispatch [:hardwallet.callback/on-generate-mnemonic-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-generate-mnemonic-error (error-object->map %)]))))) @@ -96,7 +96,7 @@ (defn generate-and-load-key [{:keys [mnemonic pairing pin]}] (when pairing - (.. keycard + (.. (keycard) (generateAndLoadKey mnemonic pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-generate-and-load-key-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-generate-and-load-key-error (error-object->map %)]))))) @@ -104,7 +104,7 @@ (defn unblock-pin [{:keys [puk new-pin pairing]}] (when (and pairing new-pin puk) - (.. keycard + (.. (keycard) (unblockPin pairing puk new-pin) (then #(re-frame/dispatch [:hardwallet.callback/on-unblock-pin-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-unblock-pin-error (error-object->map %)]))))) @@ -112,7 +112,7 @@ (defn verify-pin [{:keys [pin pairing]}] (when (and pairing (not-empty pin)) - (.. keycard + (.. (keycard) (verifyPin pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-verify-pin-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-verify-pin-error (error-object->map %)]))))) @@ -120,7 +120,7 @@ (defn change-pin [{:keys [current-pin new-pin pairing]}] (when (and pairing current-pin new-pin) - (.. keycard + (.. (keycard) (changePin pairing current-pin new-pin) (then #(re-frame/dispatch [:hardwallet.callback/on-change-pin-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-change-pin-error (error-object->map %)]))))) @@ -128,28 +128,28 @@ (defn unpair [{:keys [pin pairing]}] (when (and pairing pin) - (.. keycard + (.. (keycard) (unpair pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-unpair-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-unpair-error (error-object->map %)]))))) (defn delete [] - (.. keycard + (.. (keycard) (delete) (then #(re-frame/dispatch [:hardwallet.callback/on-delete-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-delete-error (error-object->map %)])))) (defn remove-key [{:keys [pin pairing]}] - (.. keycard + (.. (keycard) (removeKey pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-remove-key-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-remove-key-error (error-object->map %)])))) (defn remove-key-with-unpair [{:keys [pin pairing]}] - (.. keycard + (.. (keycard) (removeKeyWithUnpair pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-remove-key-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-remove-key-error (error-object->map %)])))) @@ -157,7 +157,7 @@ (defn unpair-and-delete [{:keys [pin pairing]}] (when (and pairing pin) - (.. keycard + (.. (keycard) (unpairAndDelete pairing pin) (then #(re-frame/dispatch [:hardwallet.callback/on-delete-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-delete-error (error-object->map %)]))))) @@ -165,7 +165,7 @@ (defn get-keys [{:keys [pairing pin on-success]}] (when (and pairing (not-empty pin)) - (.. keycard + (.. (keycard) (getKeys pairing pin) (then #(re-frame/dispatch [(or on-success :hardwallet.callback/on-get-keys-success) %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-get-keys-error (error-object->map %)]))))) @@ -173,7 +173,7 @@ (defn sign [{:keys [pairing pin hash]}] (when (and pairing pin hash) - (.. keycard + (.. (keycard) (sign pairing pin hash) (then #(re-frame/dispatch [:hardwallet.callback/on-sign-success %])) (catch #(re-frame/dispatch [:hardwallet.callback/on-sign-error (error-object->map %)]))))) diff --git a/src/status_im/ios/core.cljs b/src/status_im/ios/core.cljs index 89efceb78d..f2b12b7792 100644 --- a/src/status_im/ios/core.cljs +++ b/src/status_im/ios/core.cljs @@ -27,21 +27,21 @@ (reagent/create-class {:component-will-mount (fn [] - (.addListener react/keyboard + (.addListener (react/keyboard) "keyboardWillShow" (fn [e] (let [h (.. e -endCoordinates -height)] (when-not (= h @keyboard-height) (dispatch [:set :keyboard-height h]) (dispatch [:set :keyboard-max-height h]))))) - (.addListener react/keyboard + (.addListener (react/keyboard) "keyboardWillHide" #(when-not (= 0 @keyboard-height) (dispatch [:set :keyboard-height 0]))) (.hide react/splash-screen) - (.addEventListener react/app-state "change" app-state-change-handler) + (.addEventListener (react/app-state) "change" app-state-change-handler) (.addEventListener rn-dependencies/react-native-languages "change" on-languages-change) - (.addEventListener rn-dependencies/react-native-shake + (.addEventListener (rn-dependencies/react-native-shake) "ShakeEvent" on-shake)) :component-did-mount @@ -49,10 +49,10 @@ (dispatch [:set-initial-props (reagent/props this)])) :component-will-unmount (fn [] - (.stop react/http-bridge) - (.removeEventListener react/app-state "change" app-state-change-handler) + (.stop (react/http-bridge)) + (.removeEventListener (react/app-state) "change" app-state-change-handler) (.removeEventListener rn-dependencies/react-native-languages "change" on-languages-change) - (.removeEventListener rn-dependencies/react-native-shake + (.removeEventListener (rn-dependencies/react-native-shake) "ShakeEvent" on-shake)) :display-name "root" diff --git a/src/status_im/js_dependencies.cljs b/src/status_im/js_dependencies.cljs index 7d6598a437..f430913941 100644 --- a/src/status_im/js_dependencies.cljs +++ b/src/status_im/js_dependencies.cljs @@ -1,12 +1,14 @@ -(ns status-im.js-dependencies) +(ns status-im.js-dependencies + (:require-macros [status-im.utils.js-require :as js-require])) -(def Chance (js/require "chance")) -(def emojis (js/require "emojilib")) -(def phishing-detect (js/require "eth-phishing-detect")) -(def homoglyph-finder (js/require "homoglyph-finder")) -(def identicon-js (js/require "identicon.js")) -(def Web3 (js/require "web3")) -(def text-encoding (js/require "text-encoding")) -(def js-sha3 (js/require "js-sha3")) -(def web3-utils (js/require "web3-utils")) -(def hi-base32 (js/require "hi-base32")) +(def Chance (js-require/js-require "chance")) +(def emojis (js-require/js-require "emojilib")) +(def phishing-detect (js-require/js-require "eth-phishing-detect")) +(def homoglyph-finder (js-require/js-require "homoglyph-finder")) +(def identicon-js (js-require/js-require "identicon.js")) +(def Web3 (js-require/js-require "web3")) +(defn web3-prototype [] (.-prototype (Web3))) +(def text-encoding (js-require/js-require "text-encoding")) +(def js-sha3 (js-require/js-require "js-sha3")) +(def web3-utils (js-require/js-require "web3-utils")) +(def hi-base32 (js-require/js-require "hi-base32")) diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index dc12ed416d..aadff3eba1 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -517,7 +517,7 @@ [{:keys [db] :as cofx} chat-id] (let [{:keys [public?] :as chat} (get-in db [:chats chat-id]) topic (if (and chat (not public?)) - transport.topic/discovery-topic-hash + (transport.topic/discovery-topic-hash) (get-in db [:transport/chats chat-id :topic])) {:keys [chat-ids] :as mailserver-topic} (update (get-in db [:mailserver/topics topic]) :chat-ids diff --git a/src/status_im/native_module/impl/module.cljs b/src/status_im/native_module/impl/module.cljs index be17b21280..cf73522fc4 100644 --- a/src/status_im/native_module/impl/module.cljs +++ b/src/status_im/native_module/impl/module.cljs @@ -5,7 +5,7 @@ [clojure.string :as string] [status-im.utils.platform :as platform])) -(def status +(defn status [] (when (exists? (.-NativeModules rn-dependencies/react-native)) (.-Status (.-NativeModules rn-dependencies/react-native)))) @@ -20,20 +20,20 @@ (defn stop-node [] (reset! node-started false) - (when status - (.stopNode status))) + (when (status) + (.stopNode (status)))) (defn node-ready [] (reset! node-started true)) (defn start-node [config] - (when status - (.startNode status config))) + (when (status) + (.startNode (status) config))) (defonce account-creation? (atom false)) (defn create-account [password on-result] - (when status + (when (status) (let [callback (fn [data] (reset! account-creation? false) (on-result data))] @@ -41,132 +41,132 @@ (fn [creation?] (if-not creation? (do - (.createAccount status password callback) + (.createAccount (status) password callback) true) false)))))) (defn send-data-notification [{:keys [data-payload tokens] :as m} on-result] - (when status - (.sendDataNotification status data-payload tokens on-result))) + (when (status) + (.sendDataNotification (status) data-payload tokens on-result))) (defn send-logs [dbJson js-logs callback] - (when status - (.sendLogs status dbJson js-logs callback))) + (when (status) + (.sendLogs (status) dbJson js-logs callback))) (defn add-peer [enode on-result] - (when (and @node-started status) - (.addPeer status enode on-result))) + (when (and @node-started (status)) + (.addPeer (status) enode on-result))) (defn recover-account [passphrase password on-result] - (when (and @node-started status) - (.recoverAccount status passphrase password on-result))) + (when (and @node-started (status)) + (.recoverAccount (status) passphrase password on-result))) (defn login [address password on-result] - (when (and @node-started status) - (.login status address password on-result))) + (when (and @node-started (status)) + (.login (status) address password on-result))) (defn verify [address password on-result] - (when (and @node-started status) - (.verify status address password on-result))) + (when (and @node-started (status)) + (.verify (status) address password on-result))) (defn login-with-keycard [whisper-private-key encryption-public-key on-result] - (when (and @node-started status) - (.loginWithKeycard status whisper-private-key encryption-public-key on-result))) + (when (and @node-started (status)) + (.loginWithKeycard (status) whisper-private-key encryption-public-key on-result))) (defn set-soft-input-mode [mode] - (when status - (.setSoftInputMode status mode))) + (when (status) + (.setSoftInputMode (status) mode))) (defn clear-web-data [] - (when status - (.clearCookies status) - (.clearStorageAPIs status))) + (when (status) + (.clearCookies (status)) + (.clearStorageAPIs (status)))) (defn call-rpc [payload callback] - (when (and @node-started status) - (.callRPC status payload callback))) + (when (and @node-started (status)) + (.callRPC (status) payload callback))) (defn call-private-rpc [payload callback] - (when (and @node-started status) - (.callPrivateRPC status payload callback))) + (when (and @node-started (status)) + (.callPrivateRPC (status) payload callback))) (defn sign-message [rpcParams callback] - (when (and @node-started status) - (.signMessage status rpcParams callback))) + (when (and @node-started (status)) + (.signMessage (status) rpcParams callback))) (defn hash-transaction [rpcParams callback] - (when (and @node-started status) - (.hashTransaction status rpcParams callback))) + (when (and @node-started (status)) + (.hashTransaction (status) rpcParams callback))) (defn hash-message [message callback] - (when (and @node-started status) - (.hashMessage status message callback))) + (when (and @node-started (status)) + (.hashMessage (status) message callback))) (defn hash-typed-data [data callback] - (when (and @node-started status) - (.hashTypedData status data callback))) + (when (and @node-started (status)) + (.hashTypedData (status) data callback))) (defn sign-typed-data [data password callback] - (when (and @node-started status) - (.signTypedData status data password callback))) + (when (and @node-started (status)) + (.signTypedData (status) data password callback))) (defn send-transaction [rpcParams password callback] - (when (and @node-started status) - (.sendTransaction status rpcParams password callback))) + (when (and @node-started (status)) + (.sendTransaction (status) rpcParams password callback))) (defn send-transaction-with-signature [rpcParams sig callback] - (when (and @node-started status) - (.sendTransactionWithSignature status rpcParams sig callback))) + (when (and @node-started (status)) + (.sendTransactionWithSignature (status) rpcParams sig callback))) (defn close-application [] - (.closeApplication status)) + (.closeApplication (status))) (defn connection-change [{:keys [type expensive?]}] - (.connectionChange status type expensive?)) + (.connectionChange (status) type expensive?)) (defn app-state-change [state] - (.appStateChange status state)) + (.appStateChange (status) state)) (defn get-device-UUID [callback] (.getDeviceUUID - status + (status) (fn [UUID] (callback (string/upper-case UUID))))) (defn set-blank-preview-flag [flag] - (.setBlankPreviewFlag status flag)) + (.setBlankPreviewFlag (status) flag)) (defn extract-group-membership-signatures [signature-pairs callback] - (when status - (.extractGroupMembershipSignatures status signature-pairs callback))) + (when (status) + (.extractGroupMembershipSignatures (status) signature-pairs callback))) (defn sign-group-membership [content callback] - (when status - (.signGroupMembership status content callback))) + (when (status) + (.signGroupMembership (status) content callback))) (defn enable-installation [installation-id callback] - (when status - (.enableInstallation status installation-id callback))) + (when (status) + (.enableInstallation (status) installation-id callback))) (defn disable-installation [installation-id callback] - (when status - (.disableInstallation status installation-id callback))) + (when (status) + (.disableInstallation (status) installation-id callback))) (defn is24Hour [] - (when status - (.-is24Hour status))) + (when (status) + (.-is24Hour (status)))) (defn update-mailservers [enodes on-result] - (when status - (.updateMailservers status enodes on-result))) + (when (status) + (.updateMailservers (status) enodes on-result))) (defn chaos-mode-update [on on-result] - (when status - (.chaosModeUpdate status on on-result))) + (when (status) + (.chaosModeUpdate (status) on on-result))) (defn get-nodes-from-contract [rpc-endpoint contract-address on-result] - (when status - (.getNodesFromContract status rpc-endpoint contract-address on-result))) + (when (status) + (.getNodesFromContract (status) rpc-endpoint contract-address on-result))) (defn rooted-device? [callback] (cond @@ -181,8 +181,8 @@ ;; we check root on android platform/android? - (if status - (.isDeviceRooted status callback) + (if (status) + (.isDeviceRooted (status) callback) ;; if module isn't initialized we return true to avoid degrading security (callback true)) diff --git a/src/status_im/network/net_info.cljs b/src/status_im/network/net_info.cljs index 72fe5e35aa..078ed2c719 100644 --- a/src/status_im/network/net_info.cljs +++ b/src/status_im/network/net_info.cljs @@ -4,8 +4,8 @@ [status-im.utils.platform :as platform])) (defn is-connected? [callback] - (when react-components/net-info - (.then (.fetch (.-isConnected react-components/net-info)) + (when (react-components/net-info) + (.then (.fetch (.-isConnected (react-components/net-info))) (fn [is-connected?] (log/debug "Is connected?" is-connected?) (callback is-connected?))))) @@ -16,21 +16,21 @@ on-success #(callback {:type (:type info) :expensive? %})] (if platform/ios? (on-success false) - (.. react-components/net-info + (.. (react-components/net-info) isConnectionExpensive (then on-success) (catch (fn [error] (log/warn "isConnectionExpensive: " error)))))))) (defn net-info [callback] - (when react-components/net-info - (.then (.getConnectionInfo react-components/net-info) + (when (react-components/net-info) + (.then (.getConnectionInfo (react-components/net-info)) (wrap-net-info callback)))) (defn add-connection-listener [listener] - (when react-components/net-info - (.addEventListener (.-isConnected react-components/net-info) "connectionChange" listener))) + (when (react-components/net-info) + (.addEventListener (.-isConnected (react-components/net-info)) "connectionChange" listener))) (defn add-net-info-listener [listener] - (when react-components/net-info - (.addEventListener react-components/net-info "connectionChange" + (when (react-components/net-info) + (.addEventListener (react-components/net-info) "connectionChange" (wrap-net-info listener)))) diff --git a/src/status_im/notifications/background.cljs b/src/status_im/notifications/background.cljs index cbb8facd44..50044927b1 100644 --- a/src/status_im/notifications/background.cljs +++ b/src/status_im/notifications/background.cljs @@ -9,7 +9,7 @@ [status-im.utils.platform :as platform])) (when-not platform/desktop? - (def firebase (object/get rn/react-native-firebase "default"))) + (def firebase (object/get (rn/react-native-firebase) "default"))) (defn message-handler-fn [] ;; message-js is firebase.messaging.RemoteMessage: https://github.com/invertase/react-native-firebase-docs/blob/master/docs/messaging/reference/RemoteMessage.md diff --git a/src/status_im/notifications/core.cljs b/src/status_im/notifications/core.cljs index fe63755412..0a8a094ff0 100644 --- a/src/status_im/notifications/core.cljs +++ b/src/status_im/notifications/core.cljs @@ -22,13 +22,13 @@ (when-not platform/desktop? - (def firebase (object/get rn/react-native-firebase "default"))) + (defn firebase [] (object/get (rn/react-native-firebase) "default"))) ;; NOTE: Only need to explicitly request permissions on iOS. (defn request-permissions [] (if platform/desktop? (re-frame/dispatch [:notifications.callback/request-notifications-permissions-granted {}]) - (-> (.requestPermission (.messaging firebase)) + (-> (.requestPermission (.messaging (firebase))) (.then (fn [_] (log/debug "notifications-granted") @@ -52,7 +52,7 @@ (= (.-length to) pn-pubkey-hash-length))))) (defn sha3 [s] - (.sha3 dependencies/Web3.prototype s)) + (.sha3 (dependencies/web3-prototype) s)) (defn anonymize-pubkey [pubkey] @@ -163,12 +163,14 @@ (when-let [msg-id (:id decoded-payload)] ;; We must prefix the notification ID, otherwise it will ;; cause a crash in iOS - {:notificationId (str "hash:" msg-id)})))] + {:notificationId (str "hash:" msg-id)}))) + firebase (firebase)] (firebase.notifications.Notification. native-notification (.notifications firebase)))) (defn display-notification [{:keys [title body] :as params}] - (let [notification (build-notification params)] + (let [notification (build-notification params) + firebase (firebase)] (when platform/android? (.. notification (-android.setChannelId channel-id) @@ -185,14 +187,15 @@ (log/debug "Display Notification error" title body error)))))) (defn get-fcm-token [] - (-> (.getToken (.messaging firebase)) + (-> (.getToken (.messaging (firebase))) (.then (fn [x] (log/debug "get-fcm-token:" x) (re-frame/dispatch [:notifications.callback/get-fcm-token-success x]))))) (defn create-notification-channel [] - (let [channel (firebase.notifications.Android.Channel. + (let [firebase (firebase) + channel (firebase.notifications.Android.Channel. channel-id channel-name firebase.notifications.Android.Importance.High)] @@ -272,7 +275,7 @@ It is only needed to handle PNs from legacy clients (which use firebase.notifications API)" (log/debug "Handle initial push notifications") - (.. firebase + (.. (firebase) notifications getInitialNotification (then (fn [event] @@ -282,7 +285,7 @@ (defn setup-token-refresh-callback [] (.onTokenRefresh - (.messaging firebase) + (.messaging (firebase)) (fn [x] (log/debug "onTokenRefresh:" x) (re-frame/dispatch [:notifications.callback/get-fcm-token-success x])))) @@ -294,7 +297,7 @@ "we can remove this method" (log/debug "calling onNotification") (.onNotification - (.notifications firebase) + (.notifications (firebase)) (fn [message-js] (log/debug "handle-on-notification-callback called") (let [decoded-payload (decode-notification-payload message-js)] @@ -306,7 +309,7 @@ (defn setup-on-message-callback [] (log/debug "calling onMessage") (.onMessage - (.messaging firebase) + (.messaging (firebase)) (fn [message-js] (log/debug "handle-on-message-callback called") (let [decoded-payload (decode-notification-payload message-js)] @@ -318,7 +321,7 @@ (defn setup-on-notification-opened-callback [] (log/debug "setup-on-notification-opened-callback") - (.. firebase + (.. (firebase) notifications (onNotificationOpened handle-notification-open-event))) diff --git a/src/status_im/privacy_policy/core.cljs b/src/status_im/privacy_policy/core.cljs index 7172090d8d..897fc38bd3 100644 --- a/src/status_im/privacy_policy/core.cljs +++ b/src/status_im/privacy_policy/core.cljs @@ -6,7 +6,7 @@ (def ^:const privacy-policy-link "https://www.iubenda.com/privacy-policy/45710059") (defn open-privacy-policy-link! [] - (.openURL react/linking privacy-policy-link)) + (.openURL (react/linking) privacy-policy-link)) (re-frame/reg-fx :privacy-policy/open-privacy-policy-link diff --git a/src/status_im/react_native/resources.cljs b/src/status_im/react_native/resources.cljs index eed19d8698..c097b1fee4 100644 --- a/src/status_im/react_native/resources.cljs +++ b/src/status_im/react_native/resources.cljs @@ -1,19 +1,27 @@ -(ns status-im.react-native.resources) +(ns status-im.react-native.resources + (:require-macros [status-im.utils.js-require :as js-require])) (def ui - {:empty-hashtags (js/require "./resources/images/ui/empty-hashtags.png") - :empty-recent (js/require "./resources/images/ui/empty-recent.png") - :analytics-image (js/require "./resources/images/ui/analytics-image.png") - :welcome-image (js/require "./resources/images/ui/welcome-image.png") - :lock (js/require "./resources/images/ui/lock.png") - :tribute-to-talk (js/require "./resources/images/ui/tribute-to-talk.png") - :wallet-welcome (js/require "./resources/images/ui/wallet-welcome.png") - :hardwallet-card (js/require "./resources/images/ui/hardwallet-card.png") - :secret-keys (js/require "./resources/images/ui/secret-keys.png") - :keycard-lock (js/require "./resources/images/ui/keycard-lock.png") - :hold-card-animation (try (js/require "./resources/images/ui/hold-card-animation.gif") - (catch :default e)) - :warning-sign (js/require "./resources/images/ui/warning-sign.png") - :phone-nfc-on (js/require "./resources/images/ui/phone-nfc-on.png") - :phone-nfc-off (js/require "./resources/images/ui/phone-nfc-off.png") - :dapp-store (js/require "./resources/images/ui/dapp-store.png")}) + {:empty-hashtags (js-require/js-require "./resources/images/ui/empty-hashtags.png") + :empty-recent (js-require/js-require "./resources/images/ui/empty-recent.png") + :analytics-image (js-require/js-require "./resources/images/ui/analytics-image.png") + :welcome-image (js-require/js-require "./resources/images/ui/welcome-image.png") + :lock (js-require/js-require "./resources/images/ui/lock.png") + :tribute-to-talk (js-require/js-require "./resources/images/ui/tribute-to-talk.png") + :wallet-welcome (js-require/js-require "./resources/images/ui/wallet-welcome.png") + :hardwallet-card (js-require/js-require "./resources/images/ui/hardwallet-card.png") + :secret-keys (js-require/js-require "./resources/images/ui/secret-keys.png") + :keycard-lock (js-require/js-require "./resources/images/ui/keycard-lock.png") + :hold-card-animation (js-require/js-require "./resources/images/ui/hold-card-animation.gif") + :warning-sign (js-require/js-require "./resources/images/ui/warning-sign.png") + :phone-nfc-on (js-require/js-require "./resources/images/ui/phone-nfc-on.png") + :phone-nfc-off (js-require/js-require "./resources/images/ui/phone-nfc-off.png") + :dapp-store (js-require/js-require "./resources/images/ui/dapp-store.png")}) + +(def loaded-images (atom {})) + +(defn get-image [k] + (if (contains? @loaded-images k) + (get @loaded-images k) + (get (swap! loaded-images assoc k + ((get ui k))) k))) diff --git a/src/status_im/transport/message/protocol.cljs b/src/status_im/transport/message/protocol.cljs index dba4e60ff4..4b08213b00 100644 --- a/src/status_im/transport/message/protocol.cljs +++ b/src/status_im/transport/message/protocol.cljs @@ -86,7 +86,7 @@ topics (db :mailserver/topics) topic-hash (if (contains? topics partitioned-topic-hash) partitioned-topic-hash - transport.topic/discovery-topic-hash)] + (transport.topic/discovery-topic-hash))] {:shh/post [{:web3 web3 :success-event success-event :message (merge {:sig (accounts.db/current-public-key cofx) diff --git a/src/status_im/transport/partitioned_topic.cljs b/src/status_im/transport/partitioned_topic.cljs index ce6a6ae9d5..34e3aa3729 100644 --- a/src/status_im/transport/partitioned_topic.cljs +++ b/src/status_im/transport/partitioned_topic.cljs @@ -38,7 +38,7 @@ utils/get-topic)) (def discovery-topic constants/contact-discovery) -(def discovery-topic-hash (utils/get-topic constants/contact-discovery)) +(defn discovery-topic-hash [] (utils/get-topic constants/contact-discovery)) (defn public-key->discovery-topic [public-key] @@ -50,10 +50,10 @@ [public-key] (if config/partitioned-topic-enabled? (partitioned-topic-hash public-key) - discovery-topic-hash)) + (discovery-topic-hash))) (defn discovery-topics [public-key] - [(partitioned-topic-hash public-key) discovery-topic-hash]) + [(partitioned-topic-hash public-key) (discovery-topic-hash)]) (defn contains-topic? [available-topics topic] diff --git a/src/status_im/transport/utils.cljs b/src/status_im/transport/utils.cljs index 70f3911b04..560d20fadd 100644 --- a/src/status_im/transport/utils.cljs +++ b/src/status_im/transport/utils.cljs @@ -4,18 +4,18 @@ [status-im.js-dependencies :as dependencies])) (defn from-utf8 [s] - (.fromUtf8 dependencies/Web3.prototype s)) + (.fromUtf8 (dependencies/web3-prototype) s)) (defn to-ascii [s] - (.toAscii dependencies/Web3.prototype s)) + (.toAscii (dependencies/web3-prototype) s)) (defn to-utf8 [s] (try - (.toUtf8 dependencies/Web3.prototype (str s)) + (.toUtf8 (dependencies/web3-prototype) (str s)) (catch :default err nil))) (defn sha3 [s] - (.sha3 dependencies/Web3.prototype s)) + (.sha3 (dependencies/web3-prototype) s)) (defn old-message-id [message] diff --git a/src/status_im/tribute_to_talk/db.cljs b/src/status_im/tribute_to_talk/db.cljs index c17887dfb8..e84538913c 100644 --- a/src/status_im/tribute_to_talk/db.cljs +++ b/src/status_im/tribute_to_talk/db.cljs @@ -2,17 +2,17 @@ (:require [status-im.ethereum.core :as ethereum] [status-im.js-dependencies :as dependencies])) -(def utils dependencies/web3-utils) +(defn utils [] (dependencies/web3-utils)) (defn to-wei [s] (when s - (.toWei utils s))) + (.toWei (utils) s))) (defn from-wei [s] (when s - (.fromWei utils s))) + (.fromWei (utils) s))) (defn get-settings [db] diff --git a/src/status_im/ui/components/animation.cljs b/src/status_im/ui/components/animation.cljs index 2c8b715fc2..aa8aae183c 100644 --- a/src/status_im/ui/components/animation.cljs +++ b/src/status_im/ui/components/animation.cljs @@ -6,31 +6,31 @@ ([anim callback] (.start anim callback))) (defn anim-loop [animation] - (.loop react/animated animation)) + (.loop (react/animated) animation)) (defn interpolate [anim-value config] (.interpolate anim-value (clj->js config))) (defn timing [anim-value config] - (.timing react/animated anim-value (clj->js config))) + (.timing (react/animated) anim-value (clj->js config))) (defn spring [anim-value config] - (.spring react/animated anim-value (clj->js config))) + (.spring (react/animated) anim-value (clj->js config))) (defn decay [anim-value config] - (.decay react/animated anim-value (clj->js config))) + (.decay (react/animated) anim-value (clj->js config))) (defn anim-sequence [animations] - (.sequence react/animated (clj->js animations))) + (.sequence (react/animated) (clj->js animations))) (defn parallel [animations] - (.parallel react/animated (clj->js animations))) + (.parallel (react/animated) (clj->js animations))) (defn anim-delay [duration] - (.delay react/animated duration)) + (.delay (react/animated) duration)) (defn event [config] - (.event react/animated (clj->js [nil, config]))) + (.event (react/animated) (clj->js [nil, config]))) (defn add-listener [anim-value listener] (.addListener anim-value listener)) diff --git a/src/status_im/ui/components/bottom_bar/core.cljs b/src/status_im/ui/components/bottom_bar/core.cljs index 8db2c0a87e..f73eebf5d1 100644 --- a/src/status_im/ui/components/bottom_bar/core.cljs +++ b/src/status_im/ui/components/bottom_bar/core.cljs @@ -107,7 +107,7 @@ (when platform/iphone-x? [react/view {:style tabs.styles/ios-titles-cover}])] - [react/safe-area-view {:flex 1}]]) + [(react/safe-area-view) {:flex 1}]]) (defn tabs-animation-wrapper-android [keyboard-shown? view-id content] @@ -134,13 +134,13 @@ :enter-pin-settings} view-id) (if platform/ios? [tabs-animation-wrapper-ios - [react/animated-view + [(react/animated-view) {:style (tabs.styles/animated-container visible? keyboard-shown?)} [tabs tab]]] [tabs-animation-wrapper-android keyboard-shown? view-id - [react/animated-view + [(react/animated-view) {:style (tabs.styles/animated-container visible? keyboard-shown?)} [tabs tab]]])))})) @@ -156,12 +156,12 @@ (when platform/android? (reset! listeners - [(.addListener react/keyboard "keyboardDidShow" + [(.addListener (react/keyboard) "keyboardDidShow" (fn [] (reset! keyboard-shown? true) (animate visible? disappearance-duration 0))) - (.addListener react/keyboard "keyboardDidHide" + (.addListener (react/keyboard) "keyboardDidHide" (fn [] (reset! keyboard-shown? false) (animate visible? appearance-duration diff --git a/src/status_im/ui/components/bottom_sheet/view.cljs b/src/status_im/ui/components/bottom_sheet/view.cljs index b49ec219ad..1a422fc746 100644 --- a/src/status_im/ui/components/bottom_sheet/view.cljs +++ b/src/status_im/ui/components/bottom_sheet/view.cljs @@ -80,7 +80,7 @@ (defn swipe-pan-responder [opts] (.create - react/pan-responder + (react/pan-responder) (clj->js {:onMoveShouldSetPanResponder (fn [_ state] (or (< 10 (js/Math.abs (.-dx state))) @@ -110,8 +110,8 @@ {:on-press #(cancel opts on-cancel) :style styles/container} - [react/animated-view (styles/shadow opacity-value)]] - [react/animated-view + [(react/animated-view) (styles/shadow opacity-value)]] + [(react/animated-view) {:style (styles/content-container height bottom-value)} [react/view styles/content-header [react/view styles/handle]] diff --git a/src/status_im/ui/components/camera.cljs b/src/status_im/ui/components/camera.cljs index 092b98fb4a..2eeae1cd7c 100644 --- a/src/status_im/ui/components/camera.cljs +++ b/src/status_im/ui/components/camera.cljs @@ -4,10 +4,10 @@ [clojure.walk :as walk] [status-im.react-native.js-dependencies :as js-dependecies])) -(def default-camera (.-default js-dependecies/camera)) +(defn default-camera [] (.-default (js-dependecies/camera))) (defn constants [t] - (-> default-camera + (-> (default-camera) (object/get "constants") (object/get t) (js->clj) @@ -18,15 +18,15 @@ (def torch-modes (constants "TorchMode")) (defn set-torch [state] - (set! (.-torchMode default-camera) (get torch-modes state))) + (set! (.-torchMode (default-camera)) (get torch-modes state))) (defn request-access-ios [then else] - (-> (.checkVideoAuthorizationStatus default-camera) + (-> (.checkVideoAuthorizationStatus (default-camera)) (.then (fn [allowed?] (if allowed? (then) (else)))) (.catch else))) (defn camera [props] - (reagent/create-element default-camera (clj->js (merge {:inverted true} props)))) + (reagent/create-element (default-camera) (clj->js (merge {:inverted true} props)))) (defn get-qr-code-data [code] (.-data code)) diff --git a/src/status_im/ui/components/connectivity/view.cljs b/src/status_im/ui/components/connectivity/view.cljs index efdf5b9097..6fc4db486e 100644 --- a/src/status_im/ui/components/connectivity/view.cljs +++ b/src/status_im/ui/components/connectivity/view.cljs @@ -53,13 +53,13 @@ :top -3 :height 3 :background-color colors/white}} - [react/animated-view {:style (animated-bar-style blue-bar-left-margin - parent-width - colors/blue)}] - [react/animated-view {:style (assoc (animated-bar-style white-bar-left-margin - parent-width - colors/white) - :left (* 0.15 parent-width))}]])) + [(react/animated-view) {:style (animated-bar-style blue-bar-left-margin + parent-width + colors/blue)}] + [(react/animated-view) {:style (assoc (animated-bar-style white-bar-left-margin + parent-width + colors/white) + :left (* 0.15 parent-width))}]])) (defonce show-connected? (reagent/atom true)) @@ -108,15 +108,15 @@ connected? connecting? loading-indicator?] :as opts}] (when (or (not connected?) @show-connected?) - [react/animated-view {:style (styles/text-wrapper - (assoc opts - :height anim-height - :background-color (if connected? - colors/green - colors/gray) - :opacity anim-opacity - :modal? (= view-id :chat-modal))) - :accessibility-label :connection-status-text} + [(react/animated-view) {:style (styles/text-wrapper + (assoc opts + :height anim-height + :background-color (if connected? + colors/green + colors/gray) + :opacity anim-opacity + :modal? (= view-id :chat-modal))) + :accessibility-label :connection-status-text} (when connecting? [react/activity-indicator {:animated true :color colors/white diff --git a/src/status_im/ui/components/dialog.cljs b/src/status_im/ui/components/dialog.cljs index 2d16845153..7181054df4 100644 --- a/src/status_im/ui/components/dialog.cljs +++ b/src/status_im/ui/components/dialog.cljs @@ -1,10 +1,10 @@ (ns status-im.ui.components.dialog (:require [status-im.react-native.js-dependencies :as rn-dependencies])) -(def dialogs (.-default rn-dependencies/dialogs)) +(defn dialogs [] (.-default (rn-dependencies/dialogs))) (defn show [{:keys [title options cancel-text on-cancel]}] - (.. dialogs + (.. (dialogs) (showPicker title nil (clj->js {:items (mapv #(select-keys % [:label]) options) :negativeText cancel-text @@ -20,4 +20,4 @@ (filter #(= label (:label %))) first :action)] - (action))))))))) \ No newline at end of file + (action))))))))) diff --git a/src/status_im/ui/components/icons/vector_icons.cljs b/src/status_im/ui/components/icons/vector_icons.cljs index b913e47bd2..c96490b7f4 100644 --- a/src/status_im/ui/components/icons/vector_icons.cljs +++ b/src/status_im/ui/components/icons/vector_icons.cljs @@ -258,8 +258,8 @@ [name {:keys [color container-style accessibility-label width height] :or {accessibility-label :icon}}] ^{:key name} - [react/animated-view {:style container-style - :accessibility-label accessibility-label} + [(react/animated-view) {:style container-style + :accessibility-label accessibility-label} (if-let [icon-fn (get icons name)] (let [icon-vec (icon-fn (match-color color))] (if width diff --git a/src/status_im/ui/components/list/views.cljs b/src/status_im/ui/components/list/views.cljs index 5d2ab85a79..96643df582 100644 --- a/src/status_im/ui/components/list/views.cljs +++ b/src/status_im/ui/components/list/views.cljs @@ -62,7 +62,7 @@ (defn item-image [{:keys [source style image-style]}] [react/view {:style style} - [react/image {:source source + [react/image {:source (if (fn? source) (source) source) :style (merge styles/item-image image-style)}]]) (defn item-primary @@ -220,7 +220,7 @@ [{:keys [data] :as props}] {:pre [(or (nil? data) (sequential? data))]} - [flat-list-class + [(flat-list-class) (merge (base-list-props props) props {:data (wrap-data data)})]) @@ -251,7 +251,7 @@ See https://facebook.github.io/react-native/docs/sectionlist.html" [{:keys [sections render-section-header-fn render-section-footer-fn] :as props :or {render-section-header-fn default-render-section-header}}] - [section-list-class + [(section-list-class) (merge (base-list-props props) props (when render-section-footer-fn @@ -310,7 +310,7 @@ swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?) swipe-pan-handler (responder/pan-handlers swipe-pan-responder)] [react/view swipe-pan-handler - [react/animated-view {:style {:flex 1 :right offset-x}} + [(react/animated-view) {:style {:flex 1 :right offset-x}} body [react/touchable-highlight {:style styles/delete-icon-highlight :on-press on-delete} diff --git a/src/status_im/ui/components/list_selection.cljs b/src/status_im/ui/components/list_selection.cljs index b3911d9d13..49ca9cbd3d 100644 --- a/src/status_im/ui/components/list_selection.cljs +++ b/src/status_im/ui/components/list_selection.cljs @@ -41,13 +41,13 @@ :options [{:label (i18n/label :t/browsing-open-in-status) :action #(re-frame/dispatch [:browser.ui/open-in-status-option-selected link])} {:label (i18n/label (platform-web-browser)) - :action #(.openURL react/linking (http/normalize-url link))}] + :action #(.openURL (react/linking) (http/normalize-url link))}] :cancel-text (i18n/label :t/browsing-cancel)})) (defn browse-in-web-browser [link] (show {:title (i18n/label :t/browsing-title) :options [{:label (i18n/label (platform-web-browser)) - :action #(.openURL react/linking (http/normalize-url link))}] + :action #(.openURL (react/linking) (http/normalize-url link))}] :cancel-text (i18n/label :t/browsing-cancel)})) (defn browse-dapp [link] diff --git a/src/status_im/ui/components/permissions.cljs b/src/status_im/ui/components/permissions.cljs index 18b9fb5bea..9d97784918 100644 --- a/src/status_im/ui/components/permissions.cljs +++ b/src/status_im/ui/components/permissions.cljs @@ -4,7 +4,7 @@ [status-im.ui.components.camera :as camera] [status-im.react-native.js-dependencies :as js-dependencies])) -(def permissions-class (.-PermissionsAndroid js-dependencies/react-native)) +(defn permissions-class [] (.-PermissionsAndroid js-dependencies/react-native)) (def permissions-map {:read-external-storage "android.permission.READ_EXTERNAL_STORAGE" @@ -22,7 +22,7 @@ :as options}] (if platform/android? (let [permissions (mapv #(get permissions-map %) permissions)] - (-> (.requestMultiple permissions-class (clj->js permissions)) + (-> (.requestMultiple (permissions-class) (clj->js permissions)) (.then #(if (all-granted? (js->clj %)) (on-allowed) (on-denied))) diff --git a/src/status_im/ui/components/qr_code_viewer/views.cljs b/src/status_im/ui/components/qr_code_viewer/views.cljs index 5c8d13075f..71ba0a31d9 100644 --- a/src/status_im/ui/components/qr_code_viewer/views.cljs +++ b/src/status_im/ui/components/qr_code_viewer/views.cljs @@ -8,16 +8,16 @@ (defn qr-code [props] (reagent/create-element - rn-dependencies/qr-code + (rn-dependencies/qr-code) (clj->js (merge {:inverted true} props)))) (defview qr-code-viewer-component [{:keys [style hint-style footer-style footer-button value hint legend]}] (letsubs [{:keys [width]} [:dimensions/window] {:keys [disabled?]} [:tribute-to-talk/ui]] - [react/scroll-view {:content-container-style {:align-items :center - :margin-top 16 - :justify-content :center} - :style (merge {:flex 1} style)} + [(react/scroll-view) {:content-container-style {:align-items :center + :margin-top 16 + :justify-content :center} + :style (merge {:flex 1} style)} (when-not disabled? [react/view {:style {:margin-horizontal 16}} [tr-to-talk/enabled-note]]) diff --git a/src/status_im/ui/components/svgimage.cljs b/src/status_im/ui/components/svgimage.cljs index 0b34cdeb4a..ce6669e961 100644 --- a/src/status_im/ui/components/svgimage.cljs +++ b/src/status_im/ui/components/svgimage.cljs @@ -43,7 +43,7 @@ (fn [] [react/view {:style style :on-layout #(reset! width (-> % .-nativeEvent .-layout .-width))} - [react/web-view + [(react/web-view) {:java-script-enabled false :third-party-cookies-enabled false :scroll-enabled false diff --git a/src/status_im/ui/components/tooltip/views.cljs b/src/status_im/ui/components/tooltip/views.cljs index 4c33086d8c..b333c007a7 100644 --- a/src/status_im/ui/components/tooltip/views.cljs +++ b/src/status_im/ui/components/tooltip/views.cljs @@ -14,7 +14,7 @@ opacity-value (animation/create-value 0)] {:component-did-mount (animations/animate-tooltip bottom-value bottom-anim-value opacity-value 10)} [react/view (merge styles/tooltip-container container-style) - [react/animated-view {:style (styles/tooltip-animated bottom-anim-value opacity-value)} + [(react/animated-view) {:style (styles/tooltip-animated bottom-anim-value opacity-value)} [react/view (styles/tooltip-text-container color) [react/text {:style (styles/tooltip-text font-size)} label]] [vector-icons/icon :icons/tooltip-triangle {:color color :style styles/tooltip-triangle}]]])) @@ -24,7 +24,7 @@ opacity-value (animation/create-value 0)] {:component-did-mount (animations/animate-tooltip -150 bottom-anim-value opacity-value -10)} [react/view styles/bottom-tooltip-container - [react/animated-view {:style (styles/tooltip-animated bottom-anim-value opacity-value)} + [(react/animated-view) {:style (styles/tooltip-animated bottom-anim-value opacity-value)} [vector-icons/icon :icons/tooltip-triangle {:color colors/gray :style styles/tooltip-triangle :container-style {:transform [{:rotate "180deg"}]}}] diff --git a/src/status_im/ui/components/webview_bridge.cljs b/src/status_im/ui/components/webview_bridge.cljs index 6adf70751f..b33bfb3eaf 100644 --- a/src/status_im/ui/components/webview_bridge.cljs +++ b/src/status_im/ui/components/webview_bridge.cljs @@ -6,9 +6,11 @@ [status-im.utils.config :as config])) (def webview-bridge-class - (reagent/adapt-react-class (.-default js-dependencies/webview-bridge))) + (memoize + (fn [] + (reagent/adapt-react-class (.-default (js-dependencies/webview-bridge)))))) -(def module (.-WebViewBridgeModule (.-NativeModules js-dependencies/react-native))) +(defn module [] (.-WebViewBridgeModule (.-NativeModules js-dependencies/react-native))) (defn webview-bridge [{:keys [dapp? dapp-name] :as opts}] (if (and config/cached-webviews-enabled? platform/android? dapp?) @@ -19,10 +21,10 @@ ;; unfortunately it's impossible to pass some initial params ;; to view, that's why we have to pass dapp-name to the module ;; before showing webview - (.setCurrentDapp module dapp-name + (.setCurrentDapp (module) dapp-name (fn [] (reset! dapp-name-sent? true)))) :reagent-render (fn [opts] (when @dapp-name-sent? - [webview-bridge-class opts]))})) - [webview-bridge-class opts])) + [(webview-bridge-class) opts]))})) + [(webview-bridge-class) opts])) diff --git a/src/status_im/ui/screens/about_app/views.cljs b/src/status_im/ui/screens/about_app/views.cljs index 987e3826be..96687b47fc 100644 --- a/src/status_im/ui/screens/about_app/views.cljs +++ b/src/status_im/ui/screens/about_app/views.cljs @@ -45,7 +45,7 @@ [react/view {:flex 1} [status-bar/status-bar] [toolbar/simple-toolbar (i18n/label :t/about-app)] - [react/scroll-view + [(react/scroll-view) [react/view [profile.components/settings-item-separator] diff --git a/src/status_im/ui/screens/accounts/create/views.cljs b/src/status_im/ui/screens/accounts/create/views.cljs index eb3f3071a7..8587acdeb8 100644 --- a/src/status_im/ui/screens/accounts/create/views.cljs +++ b/src/status_im/ui/screens/accounts/create/views.cljs @@ -54,7 +54,7 @@ [react/text {:style styles/account-creating-text} (i18n/label :t/creating-your-account)]]]) (when (#{:enter-password :confirm-password :enter-name} step) - [react/scroll-view {:flex 1} + [(react/scroll-view) {:flex 1} [react/view {:style styles/logo-container} [components.common/logo styles/logo]] ^{:key (str "step" step)} diff --git a/src/status_im/ui/screens/accounts/login/views.cljs b/src/status_im/ui/screens/accounts/login/views.cljs index cf517bdaf6..27c79451f4 100644 --- a/src/status_im/ui/screens/accounts/login/views.cljs +++ b/src/status_im/ui/screens/accounts/login/views.cljs @@ -64,7 +64,7 @@ [react/keyboard-avoiding-view {:style ast/accounts-view} [status-bar/status-bar] [login-toolbar can-navigate-back?] - [react/scroll-view styles/login-view + [(react/scroll-view) styles/login-view [react/view styles/login-badge-container [account-login-badge photo-path name] [react/view {:style styles/password-container diff --git a/src/status_im/ui/screens/bootnodes_settings/edit_bootnode/views.cljs b/src/status_im/ui/screens/bootnodes_settings/edit_bootnode/views.cljs index e6500681b9..166356869c 100644 --- a/src/status_im/ui/screens/bootnodes_settings/edit_bootnode/views.cljs +++ b/src/status_im/ui/screens/bootnodes_settings/edit_bootnode/views.cljs @@ -45,7 +45,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label (if id :t/bootnode-details :t/add-bootnode))] - [react/scroll-view {:keyboard-should-persist-taps :handled} + [(react/scroll-view) {:keyboard-should-persist-taps :handled} [react/view styles/edit-bootnode-view [text-input/text-input-with-label {:label (i18n/label :t/name) diff --git a/src/status_im/ui/screens/browser/open_dapp/views.cljs b/src/status_im/ui/screens/browser/open_dapp/views.cljs index 2623cab0b5..38d1b14fab 100644 --- a/src/status_im/ui/screens/browser/open_dapp/views.cljs +++ b/src/status_im/ui/screens/browser/open_dapp/views.cljs @@ -31,7 +31,7 @@ :image [react/view styles/browser-icon-container [vector-icons/icon :main-icons/browser {:color colors/gray}]]}]]) -(def dapp-image-data {:image (:dapp-store resources/ui) :width 768 :height 333}) +(def dapp-image-data {:image (resources/get-image :dapp-store) :width 768 :height 333}) (def dapp-image (components.common/image-contain nil dapp-image-data)) (def privacy-otions-visible? (reagent/atom true)) @@ -95,7 +95,7 @@ [components/separator] (if (empty? browsers) [list-header true] - [react/scroll-view + [(react/scroll-view) [list-header false] [list/flat-list {:data browsers :footer [react/view @@ -103,4 +103,4 @@ :align-self :stretch}}] :key-fn :browser-id :end-fill-color colors/white - :render-fn list-item}]])])) \ No newline at end of file + :render-fn list-item}]])])) diff --git a/src/status_im/ui/screens/browser/permissions/views.cljs b/src/status_im/ui/screens/browser/permissions/views.cljs index b408e2d267..358c270046 100644 --- a/src/status_im/ui/screens/browser/permissions/views.cljs +++ b/src/status_im/ui/screens/browser/permissions/views.cljs @@ -74,8 +74,8 @@ (when @current-permission (let [{:keys [title description icon]} @current-permission] [react/view styles/permissions-panel-container - [react/animated-view {:style (styles/permissions-panel-background alpha-value)}] - [react/animated-view {:style (styles/permissions-panel bottom-anim-value)} + [(react/animated-view) {:style (styles/permissions-panel-background alpha-value)}] + [(react/animated-view) {:style (styles/permissions-panel bottom-anim-value)} [react/view styles/permissions-panel-icons-container (if dapp? [chat-icon.screen/dapp-icon-permission dapp 48] diff --git a/src/status_im/ui/screens/browser/site_blocked/views.cljs b/src/status_im/ui/screens/browser/site_blocked/views.cljs index 3be32a8fa0..556f741fdd 100644 --- a/src/status_im/ui/screens/browser/site_blocked/views.cljs +++ b/src/status_im/ui/screens/browser/site_blocked/views.cljs @@ -9,16 +9,16 @@ (:require-macros [status-im.utils.views :as views])) (views/defview view [{:keys [can-go-back?]}] - [react/scroll-view {:keyboard-should-persist-taps :always - :bounces false - :content-container-style styles/container} + [(react/scroll-view) {:keyboard-should-persist-taps :always + :bounces false + :content-container-style styles/container} [react/view styles/container-root-view [vector-icons/icon :main-icons/info {:color colors/red}] [react/text {:style styles/title-text} (i18n/label :t/browsing-site-blocked-title)] [react/nested-text {:style styles/description-text} (i18n/label :t/browsing-site-blocked-description1) - [{:on-press #(.openURL react/linking "status-im://chat/public/status") + [{:on-press #(.openURL (react/linking) "status-im://chat/public/status") :style styles/chat-link-text} "#status"] (i18n/label :t/browsing-site-blocked-description2)] diff --git a/src/status_im/ui/screens/chat/bottom_info.cljs b/src/status_im/ui/screens/chat/bottom_info.cljs index a106a04288..c24e9d21f7 100644 --- a/src/status_im/ui/screens/chat/bottom_info.cljs +++ b/src/status_im/ui/screens/chat/bottom_info.cljs @@ -37,7 +37,7 @@ :display-name "container" :reagent-render (fn [height & children] - [react/animated-view {:style (styles/bottom-info-container height)} + [(react/animated-view) {:style (styles/bottom-info-container height)} (into [react/view] children)])}))) (defn- message-status-row [{:keys [photo-path name]} {:keys [public-key status]}] diff --git a/src/status_im/ui/screens/chat/input/animations/expandable.cljs b/src/status_im/ui/screens/chat/input/animations/expandable.cljs index af39add55c..fcccb46516 100644 --- a/src/status_im/ui/screens/chat/input/animations/expandable.cljs +++ b/src/status_im/ui/screens/chat/input/animations/expandable.cljs @@ -31,9 +31,9 @@ bottom (+ input-height chat-input-margin) max-height (- chat-layout-height (when platform/ios? keyboard-height) input-height top-offset)] [react/view style/overlap-container - [react/animated-view {:style (style/expandable-container anim-value bottom max-height)} - (into [react/scroll-view {:keyboard-should-persist-taps :always - :on-content-size-change #(expandable-view-on-update anim-value %2) - :bounces false}] + [(react/animated-view) {:style (style/expandable-container anim-value bottom max-height)} + (into [(react/scroll-view) {:keyboard-should-persist-taps :always + :on-content-size-change #(expandable-view-on-update anim-value %2) + :bounces false}] (when (or input-focused? (not messages-focused?)) elements))]]))) diff --git a/src/status_im/ui/screens/chat/input/input.cljs b/src/status_im/ui/screens/chat/input/input.cljs index 3608befad0..c33cc8685c 100644 --- a/src/status_im/ui/screens/chat/input/input.cljs +++ b/src/status_im/ui/screens/chat/input/input.cljs @@ -113,7 +113,7 @@ on-update (input-helper-view-on-update {:opacity-value opacity-value :placeholder placeholder})] {:component-did-update on-update} - [react/animated-view {:style (style/input-helper-view width opacity-value)} + [(react/animated-view) {:style (style/input-helper-view width opacity-value)} [react/text {:style (style/input-helper-text width)} placeholder]])) @@ -131,7 +131,7 @@ set-container-width-fn #(reagent/set-state component {:container-width %}) {:keys [width]} (reagent/state component)] [react/view {:style style/input-root} - [react/animated-view {:style style/input-animated} + [(react/animated-view) {:style style/input-animated} [invisible-input {:set-layout-width-fn set-layout-width-fn}] (if platform/desktop? [basic-text-input-desktop {:set-container-width-fn set-container-width-fn @@ -156,7 +156,7 @@ (defview reply-message [from message-text] (letsubs [username [:contacts/contact-name-by-identity from] current-public-key [:account/public-key]] - [react/scroll-view {:style style/reply-message-content} + [(react/scroll-view) {:style style/reply-message-content} (chat-utils/format-reply-author from username current-public-key style/reply-message-author) [react/text {:style (message-style/style-message-text false)} message-text]])) diff --git a/src/status_im/ui/screens/chat/input/suggestions.cljs b/src/status_im/ui/screens/chat/input/suggestions.cljs index b4091ec20b..136ab0e4a3 100644 --- a/src/status_im/ui/screens/chat/input/suggestions.cljs +++ b/src/status_im/ui/screens/chat/input/suggestions.cljs @@ -19,8 +19,8 @@ (letsubs [available-commands [:chats/available-commands]] [expandable/expandable-view {:key :suggestions} [react/view - [react/scroll-view {:keyboard-should-persist-taps :always - :bounces false} + [(react/scroll-view) {:keyboard-should-persist-taps :always + :bounces false} (when (seq available-commands) (map-indexed (fn [i {:keys [type] :as command}] diff --git a/src/status_im/ui/screens/chat/message/datemark.cljs b/src/status_im/ui/screens/chat/message/datemark.cljs index c373a81902..a400e1cb1c 100644 --- a/src/status_im/ui/screens/chat/message/datemark.cljs +++ b/src/status_im/ui/screens/chat/message/datemark.cljs @@ -15,7 +15,7 @@ {:on-press (fn [_] (re-frame/dispatch [:chat.ui/set-chat-ui-props {:messages-focused? true - :show-stickers? false}]) + :show-stickers? false}]) (react/dismiss-keyboard!))} [react/view style/datemark-mobile [react/text {:style style/datemark-text} diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index fc5a94bbb9..db5e4fbda9 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -280,7 +280,7 @@ (when (= content-type constants/content-type-sticker) (re-frame/dispatch [:stickers/open-sticker-pack (:pack content)])) (re-frame/dispatch [:chat.ui/set-chat-ui-props {:messages-focused? true - :show-stickers? false}]) + :show-stickers? false}]) (when-not platform/desktop? (react/dismiss-keyboard!))))) :on-long-press #(when (or (= content-type constants/content-type-text) (= content-type constants/content-type-emoji)) diff --git a/src/status_im/ui/screens/chat/stickers/views.cljs b/src/status_im/ui/screens/chat/stickers/views.cljs index b261ab8cfe..3ff2583166 100644 --- a/src/status_im/ui/screens/chat/stickers/views.cljs +++ b/src/status_im/ui/screens/chat/stickers/views.cljs @@ -30,16 +30,16 @@ [react/view {:style {:flex 1 :align-items :center :justify-content :center}} [vector-icons/icon :stickers-icons/stickers-big {:color colors/gray}] [react/text {:style {:margin-top 8 :font-size 17}} (i18n/label :t/you-dont-have-stickers)] - [react/touchable-opacity {:on-press #(do - (re-frame/dispatch [:stickers/load-packs]) - (re-frame/dispatch [:navigate-to :stickers]))} + [(react/touchable-opacity) {:on-press #(do + (re-frame/dispatch [:stickers/load-packs]) + (re-frame/dispatch [:navigate-to :stickers]))} [react/view {:margin-top 6 :height 44 :justify-content :center} [react/text {:style {:color colors/blue}} (i18n/label :t/get-stickers)]]]]) (defn- stickers-panel [stickers window-width] [react/view {:width window-width :flex 1} - [react/scroll-view + [(react/scroll-view) [react/view {:style styles/stickers-panel} (for [{:keys [uri] :as sticker} stickers] ^{:key uri} @@ -80,12 +80,12 @@ {:component-will-update (fn [_ [_ installed-packs selected-pack]] (update-scroll-position @ref installed-packs selected-pack window-width)) :component-did-mount #(update-scroll-position @ref installed-packs selected-pack window-width)} - [react/scroll-view {:style {:flex 1} :horizontal true :paging-enabled true - :ref #(reset! ref %) - :shows-horizontal-scroll-indicator false - :on-momentum-scroll-end #(on-scroll % installed-packs window-width) - :scrollEventThrottle 8 - :on-scroll #(reset! scroll-x (.-nativeEvent.contentOffset.x %))} + [(react/scroll-view) {:style {:flex 1} :horizontal true :paging-enabled true + :ref #(reset! ref %) + :shows-horizontal-scroll-indicator false + :on-momentum-scroll-end #(on-scroll % installed-packs window-width) + :scrollEventThrottle 8 + :on-scroll #(reset! scroll-x (.-nativeEvent.contentOffset.x %))} ^{:key "recent"} [recent-stickers-panel window-width] (for [{:keys [stickers id]} installed-packs] @@ -129,8 +129,8 @@ (do (anim/set-value bottom-anim-value (styles/stickers-panel-height)) (anim/set-value alpha-value 1)))} - [react/animated-view {:style {:background-color :white :height (if input-focused? 0 bottom-anim-value) - :opacity alpha-value}} + [(react/animated-view) {:style {:background-color :white :height (if input-focused? 0 bottom-anim-value) + :opacity alpha-value}} (cond (= selected-pack :recent) [stickers-paging-panel installed-packs selected-pack] (not (seq installed-packs)) [no-stickers-yet-panel] @@ -142,7 +142,7 @@ :selected? false :background-color colors/blue} [vector-icons/icon :main-icons/add {:width 20 :height 20 :color colors/white}]] [react/view {:width 2}] - [react/scroll-view {:horizontal true :style {:padding-left 2}} + [(react/scroll-view) {:horizontal true :style {:padding-left 2}} [react/view [react/view {:style {:flex-direction :row}} [pack-icon {:id :recent :background-color colors/white} diff --git a/src/status_im/ui/screens/chat/utils.cljs b/src/status_im/ui/screens/chat/utils.cljs index bfd6c91e04..1c450df3f2 100644 --- a/src/status_im/ui/screens/chat/utils.cljs +++ b/src/status_im/ui/screens/chat/utils.cljs @@ -38,7 +38,7 @@ {:style {:color (if outgoing colors/white colors/blue) :text-decoration-line :underline} :on-press (if platform/desktop? - #(.openURL react/linking (http/normalize-url text)) + #(.openURL (react/linking) (http/normalize-url text)) #(re-frame/dispatch [:browser.ui/message-link-pressed text]))}) :tag (fn [text {:keys [outgoing]}] {:style {:color (if outgoing colors/white colors/blue) diff --git a/src/status_im/ui/screens/chat/views.cljs b/src/status_im/ui/screens/chat/views.cljs index e50e48edf8..34dca52737 100644 --- a/src/status_im/ui/screens/chat/views.cljs +++ b/src/status_im/ui/screens/chat/views.cljs @@ -108,7 +108,7 @@ (react/dismiss-keyboard!)))} (if platform/desktop? message-view - [react/animated-view {:style (style/message-view-animated opacity)} + [(react/animated-view) {:style (style/message-view-animated opacity)} message-view])]])) (defn join-chat-button [chat-id] @@ -371,10 +371,10 @@ (when (= chat-id current-chat-id) ;; this scroll-view is a hack that allows us to use on-blur and on-focus on Android ;; more details here: https://github.com/facebook/react-native/issues/11071 - [react/scroll-view {:scroll-enabled false - :style style/scroll-root - :content-container-style style/scroll-root - :keyboard-should-persist-taps :handled} + [(react/scroll-view) {:scroll-enabled false + :style style/scroll-root + :content-container-style style/scroll-root + :keyboard-should-persist-taps :handled} ^{:key current-chat-id} [react/view {:style style/chat-view :on-layout (fn [e] diff --git a/src/status_im/ui/screens/contacts_list/views.cljs b/src/status_im/ui/screens/contacts_list/views.cljs index e97b9d3939..8eb4ae5a03 100644 --- a/src/status_im/ui/screens/contacts_list/views.cljs +++ b/src/status_im/ui/screens/contacts_list/views.cljs @@ -23,7 +23,7 @@ [toolbar.view/toolbar nil toolbar.view/default-nav-back (toolbar.view/content-title (i18n/label :t/contacts))] - [react/scroll-view {:flex 1} + [(react/scroll-view) {:flex 1} [list.views/big-list-item {:style {:margin-vertical 16} :text (i18n/label :t/blocked-users) @@ -43,8 +43,8 @@ :background-color colors/white} [status-bar/status-bar] [toolbar.view/simple-toolbar (i18n/label :t/blocked-users)] - [react/scroll-view {:style {:background-color colors/white - :padding-vertical 8}} + [(react/scroll-view) {:style {:background-color colors/white + :padding-vertical 8}} [list.views/flat-list {:data blocked-contacts :key-fn :address diff --git a/src/status_im/ui/screens/desktop/main/add_new/views.cljs b/src/status_im/ui/screens/desktop/main/add_new/views.cljs index 6292e81d9e..e33dff628b 100644 --- a/src/status_im/ui/screens/desktop/main/add_new/views.cljs +++ b/src/status_im/ui/screens/desktop/main/add_new/views.cljs @@ -59,7 +59,7 @@ {:style (styles/add-contact-button-text disable?)} (i18n/label :start-chat)]]]]) (when (seq contacts) [react/text {:style styles/new-contact-subtitle} (i18n/label :or-choose-a-contact)]) - [react/scroll-view + [(react/scroll-view) [react/view {:style styles/suggested-contacts} (doall (for [c contacts] @@ -120,7 +120,7 @@ (i18n/label :new-public-group-chat)]]]]) [topic-input-placeholder] [react/text {:style styles/new-contact-subtitle} (i18n/label :selected-for-you)] - [react/scroll-view + [(react/scroll-view) [react/view {:style styles/suggested-contacts} (doall (for [topic public-chat/default-public-chats] diff --git a/src/status_im/ui/screens/desktop/main/chat/views.cljs b/src/status_im/ui/screens/desktop/main/chat/views.cljs index 0d32e115c0..507fa0cb9e 100644 --- a/src/status_im/ui/screens/desktop/main/chat/views.cljs +++ b/src/status_im/ui/screens/desktop/main/chat/views.cljs @@ -242,19 +242,19 @@ (reset! messages-to-load load-step) (reset! chat-id* chat-id)))] [react/view {:style styles/messages-view} - [react/scroll-view {:scrollEventThrottle 16 - :headerHeight styles/messages-list-vertical-padding - :footerWidth styles/messages-list-vertical-padding - :enableArrayScrollingOptimization true - :inverted true - :on-scroll (fn [e] - (let [ne (.-nativeEvent e) - y (.-y (.-contentOffset ne))] - (when (<= y 0) - (when @scroll-timer (js/clearTimeout @scroll-timer)) - (reset! scroll-timer (js/setTimeout #(re-frame/dispatch [:chat.ui/load-more-messages]) 300))) - (reset! scroll-height (+ y (.-height (.-layoutMeasurement ne)))))) - :ref #(reset! scroll-ref %)} + [(react/scroll-view) {:scrollEventThrottle 16 + :headerHeight styles/messages-list-vertical-padding + :footerWidth styles/messages-list-vertical-padding + :enableArrayScrollingOptimization true + :inverted true + :on-scroll (fn [e] + (let [ne (.-nativeEvent e) + y (.-y (.-contentOffset ne))] + (when (<= y 0) + (when @scroll-timer (js/clearTimeout @scroll-timer)) + (reset! scroll-timer (js/setTimeout #(re-frame/dispatch [:chat.ui/load-more-messages]) 300))) + (reset! scroll-height (+ y (.-height (.-layoutMeasurement ne)))))) + :ref #(reset! scroll-ref %)} [react/view (doall (for [{:keys [from content] :as message-obj} (take @messages-to-load messages)] diff --git a/src/status_im/ui/screens/desktop/main/tabs/home/views.cljs b/src/status_im/ui/screens/desktop/main/tabs/home/views.cljs index 34507dd585..ccd85acf55 100644 --- a/src/status_im/ui/screens/desktop/main/tabs/home/views.cljs +++ b/src/status_im/ui/screens/desktop/main/tabs/home/views.cljs @@ -161,7 +161,7 @@ (if logging-in? [components/activity-indicator {:animating true :color :white}] [icons/icon :main-icons/add {:style {:tint-color :white}}])]]]] - [react/scroll-view {:enableArrayScrollingOptimization true} + [(react/scroll-view) {:enableArrayScrollingOptimization true} [react/view (for [[index chat] (map-indexed vector (or all-home-items chats))] ^{:key (first chat)} diff --git a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs index 5bb2dee280..e3b7c8cdb3 100644 --- a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs +++ b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs @@ -168,7 +168,7 @@ preferred-mailserver-id) pfs? (:pfs? settings) connection-message (connection-status peers-count node-status mailserver-state disconnected)] - [react/scroll-view + [(react/scroll-view) [react/text {:style styles/advanced-settings-title} (i18n/label :advanced-settings)] @@ -225,7 +225,7 @@ (views/letsubs [installations [:pairing/installations] installation-id [:pairing/installation-id] installation-name [:pairing/installation-name]] - [react/scroll-view + [(react/scroll-view) (installations-section installation-id installation-name diff --git a/src/status_im/ui/screens/extensions/add/views.cljs b/src/status_im/ui/screens/extensions/add/views.cljs index f6581e74b9..cbefd21d5c 100644 --- a/src/status_im/ui/screens/extensions/add/views.cljs +++ b/src/status_im/ui/screens/extensions/add/views.cljs @@ -32,7 +32,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/extension) modal?] - [react/scroll-view {:keyboard-should-persist-taps :handled} + [(react/scroll-view) {:keyboard-should-persist-taps :handled} [react/view styles/wrapper [react/view {:style {:border-radius 8 :margin 10 :padding 8 :background-color colors/red}} [react/text {:style {:color colors/white}} @@ -91,7 +91,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/extension-find)] - [react/scroll-view {:keyboard-should-persist-taps :handled} + [(react/scroll-view) {:keyboard-should-persist-taps :handled} [react/view styles/wrapper [text-input/text-input-with-label {:label (i18n/label :t/extension-address) diff --git a/src/status_im/ui/screens/group/views.cljs b/src/status_im/ui/screens/group/views.cljs index da9588bc64..dbd138782a 100644 --- a/src/status_im/ui/screens/group/views.cljs +++ b/src/status_im/ui/screens/group/views.cljs @@ -90,7 +90,7 @@ (list-selection/open-share {:message (i18n/label :t/get-status-at)}))) (defn toggle-list [contacts render-function] - [react/scroll-view {:flex 1} + [(react/scroll-view) {:flex 1} (if utils.platform/desktop? (for [contact contacts] ^{:key (:public-key contact)} @@ -152,7 +152,7 @@ {:selected (count contacts) :max (dec constants/max-group-chat-participants)})] [group-name-view] - [react/scroll-view + [(react/scroll-view) [list/list-with-label {:flex 1} (i18n/label :t/members-title) [list/flat-list {:data contacts diff --git a/src/status_im/ui/screens/hardwallet/authentication_method/views.cljs b/src/status_im/ui/screens/hardwallet/authentication_method/views.cljs index 02421c8757..35ef2dac87 100644 --- a/src/status_im/ui/screens/hardwallet/authentication_method/views.cljs +++ b/src/status_im/ui/screens/hardwallet/authentication_method/views.cljs @@ -32,7 +32,7 @@ [common/separator] [react/view styles/choose-authentication-method [react/view styles/lock-image-container - [react/image {:source (:keycard-lock resources/ui) + [react/image {:source (resources/get-image :keycard-lock) :style styles/lock-image}]] [react/text {:style styles/choose-authentication-method-text :number-of-lines 3} diff --git a/src/status_im/ui/screens/hardwallet/components.cljs b/src/status_im/ui/screens/hardwallet/components.cljs index 3551aacc63..881f932e3c 100644 --- a/src/status_im/ui/screens/hardwallet/components.cljs +++ b/src/status_im/ui/screens/hardwallet/components.cljs @@ -12,9 +12,9 @@ (defview application-info [visible?] (letsubs [info [:hardwallet-application-info] error [:hardwallet-application-info-error]] - [react/modal {:visible @visible? - :transparent false - :on-request-close #()} + [(react/modal) {:visible @visible? + :transparent false + :on-request-close #()} [react/view {:padding 20 :justify-content :center} [react/text {:style {:font-size 18 diff --git a/src/status_im/ui/screens/hardwallet/connect/views.cljs b/src/status_im/ui/screens/hardwallet/connect/views.cljs index e6bc7262e0..7ffe61c505 100644 --- a/src/status_im/ui/screens/hardwallet/connect/views.cljs +++ b/src/status_im/ui/screens/hardwallet/connect/views.cljs @@ -16,7 +16,7 @@ (letsubs [card-read-in-progress? [:hardwallet/card-read-in-progress?]] [react/view styles/nfc-enabled-container [react/view - [react/image {:source (:hold-card-animation resources/ui) + [react/image {:source (resources/get-image :hold-card-animation) :style styles/phone-nfc-on-image}]] [react/view styles/turn-nfc-text-container [react/text {:style styles/status-hardwallet-text @@ -30,7 +30,7 @@ (defn nfc-disabled [] [react/view styles/nfc-disabled-container [react/view - [react/image {:source (:phone-nfc-off resources/ui) + [react/image {:source (resources/get-image :phone-nfc-off) :style styles/phone-nfc-off-image}]] [react/view styles/turn-nfc-text-container [react/text {:style styles/status-hardwallet-text @@ -59,7 +59,7 @@ [nfc-disabled])] (if (= setup-step :begin) [react/view styles/bottom-container - [react/touchable-highlight {:on-press #(.openURL react/linking "https://hardwallet.status.im")} + [react/touchable-highlight {:on-press #(.openURL (react/linking) "https://hardwallet.status.im")} [react/view styles/product-info-container [react/text {:style styles/product-info-text} (i18n/label :t/product-information)] diff --git a/src/status_im/ui/screens/hardwallet/pin/views.cljs b/src/status_im/ui/screens/hardwallet/pin/views.cljs index 75121a7df5..3adba2c40e 100644 --- a/src/status_im/ui/screens/hardwallet/pin/views.cljs +++ b/src/status_im/ui/screens/hardwallet/pin/views.cljs @@ -73,7 +73,7 @@ (defn pin-view [{:keys [pin title-label description-label step status error-label retry-counter]}] (let [enabled? (not= status :verifying)] - [react/scroll-view + [(react/scroll-view) [react/view styles/pin-container [react/view styles/center-container [react/text {:style styles/center-title-text} diff --git a/src/status_im/ui/screens/hardwallet/settings/views.cljs b/src/status_im/ui/screens/hardwallet/settings/views.cljs index abd2b321bd..68f70132d7 100644 --- a/src/status_im/ui/screens/hardwallet/settings/views.cljs +++ b/src/status_im/ui/screens/hardwallet/settings/views.cljs @@ -60,7 +60,7 @@ [react/view {:margin-top 71 :flex 1 :align-items :center} - [react/image {:source (:warning-sign resources/ui) + [react/image {:source (resources/get-image :warning-sign) :style {:width 160 :height 160}}]] [react/view {:flex 1 @@ -99,7 +99,7 @@ [react/view {:margin-top 47 :flex 1 :align-items :center} - [react/image {:source (:hardwallet-card resources/ui) + [react/image {:source (resources/get-image :hardwallet-card) :style {:width 255 :height 160}}] (when paired-on @@ -115,7 +115,7 @@ [react/view [action-row {:icon :main-icons/info :label :t/help-capitalized - :on-press #(.openURL react/linking "https://hardwallet.status.im")}] + :on-press #(.openURL (react/linking) "https://hardwallet.status.im")}] (when pairing [react/view [action-row {:icon :main-icons/add diff --git a/src/status_im/ui/screens/hardwallet/setup/views.cljs b/src/status_im/ui/screens/hardwallet/setup/views.cljs index 4b512104df..4698326749 100644 --- a/src/status_im/ui/screens/hardwallet/setup/views.cljs +++ b/src/status_im/ui/screens/hardwallet/setup/views.cljs @@ -20,15 +20,15 @@ [status-im.ui.screens.hardwallet.setup.styles :as styles] [status-im.utils.security :as security])) -(defonce event-emitter (.-DeviceEventEmitter js-dependencies/react-native)) +(defn event-emitter [] (.-DeviceEventEmitter js-dependencies/react-native)) (defview secret-keys [] (letsubs [secrets [:hardwallet-secrets]] [react/view styles/secret-keys-container - [react/scroll-view + [(react/scroll-view) [react/view styles/secret-keys-inner-container [react/view - [react/image {:source (:secret-keys resources/ui) + [react/image {:source (resources/get-image :secret-keys) :style styles/secret-keys-image-container}]] [react/view styles/secret-keys-title-container [react/text {:style styles/secret-keys-title-text @@ -235,7 +235,7 @@ error [:hardwallet-setup-error] width [:dimensions/window-width] ref (atom nil)] - [react/scroll-view + [(react/scroll-view) [react/view styles/enter-pair-code-container [react/view styles/enter-pair-code-title-container [react/view @@ -265,7 +265,7 @@ Used by 'Prepare', 'Pair', 'No slots', 'Card is linked' screens" [react/view styles/card-with-button-view-container [react/view styles/hardwallet-card-image-container - [react/image {:source (:hardwallet-card resources/ui) + [react/image {:source (resources/get-image :hardwallet-card) :style styles/hardwallet-card-image}] [react/view styles/center-text-container [react/text {:style (assoc styles/center-text :padding-horizontal 60)} @@ -282,12 +282,12 @@ (defn begin [] [react/view styles/card-blank-container - [react/scroll-view + [(react/scroll-view) [react/view styles/hardwallet-card-image-container [react/text {:style styles/card-is-empty-text} (i18n/label :t/card-is-blank)] [react/view {:margin-top 15} - [react/image {:source (:hardwallet-card resources/ui) + [react/image {:source (resources/get-image :hardwallet-card) :style styles/hardwallet-card-image}]] [react/view styles/card-is-empty-prepare-text [react/text {:style styles/center-text} @@ -323,20 +323,20 @@ :button-label :t/help-capitalized :show-icon? true :button-container-style {:background-color colors/white} - :on-press #(.openURL react/linking "https://hardwallet.status.im")}]) + :on-press #(.openURL (react/linking) "https://hardwallet.status.im")}]) (defn card-already-linked [] [card-with-button-view {:text-label :t/card-already-linked :button-label :t/help-capitalized :show-icon? true :button-container-style {:background-color colors/white} - :on-press #(.openURL react/linking "https://hardwallet.status.im")}]) + :on-press #(.openURL (react/linking) "https://hardwallet.status.im")}]) (defview error [] (letsubs [error [:hardwallet-setup-error]] [react/view styles/card-with-button-view-container [react/view styles/hardwallet-card-image-container - [react/image {:source (:hardwallet-card resources/ui) + [react/image {:source (resources/get-image :hardwallet-card) :style styles/hardwallet-card-image}] [react/view styles/center-text-container [react/text {:style styles/center-text} @@ -380,7 +380,7 @@ (.removeListener @listener))) :component-did-mount (fn [] (reset! listener - (.addListener event-emitter + (.addListener (event-emitter) "keycardInstallationProgress" (fn [params] (when @progress-bar @@ -396,10 +396,10 @@ (i18n/label :t/taking-long-hold-phone-connected)]] [react/view styles/progress-bar-container (if (contains? #{:blank :init} card-state) - [react/progress-bar {:styleAttr "Horizontal" - :indeterminate false - :progress 0 - :ref #(reset! progress-bar %)}] + [(react/progress-bar) {:styleAttr "Horizontal" + :indeterminate false + :progress 0 + :ref #(reset! progress-bar %)}] [react/activity-indicator {:animating true :size :large}])]])) diff --git a/src/status_im/ui/screens/help_center/views.cljs b/src/status_im/ui/screens/help_center/views.cljs index c185e3e89c..ace669c259 100644 --- a/src/status_im/ui/screens/help_center/views.cljs +++ b/src/status_im/ui/screens/help_center/views.cljs @@ -14,13 +14,13 @@ [status-bar/status-bar] [toolbar/simple-toolbar (i18n/label :t/help-center)] - [react/scroll-view + [(react/scroll-view) [react/view [profile.components/settings-item-separator] [profile.components/settings-item {:label-kw :t/faq :accessibility-label :faq-button - :action-fn #(.openURL react/linking + :action-fn #(.openURL (react/linking) (if platform/desktop? "https://status.im/docs/FAQ-desktop.html" "https://status.im/docs/FAQs.html"))}] diff --git a/src/status_im/ui/screens/home/animations/responder.cljs b/src/status_im/ui/screens/home/animations/responder.cljs index 99eaa2f661..d611faf03d 100644 --- a/src/status_im/ui/screens/home/animations/responder.cljs +++ b/src/status_im/ui/screens/home/animations/responder.cljs @@ -24,11 +24,11 @@ (animation/start (animation/spring animated-offset-x {:toValue to-value}))))) (defn swipe-pan-responder [animated-offset-x end-offset-x chat-id swiped?] - (.create react/pan-responder + (.create (react/pan-responder) (clj->js {:onMoveShouldSetPanResponder on-start :onPanResponderMove (on-move animated-offset-x end-offset-x swiped?) :onPanResponderRelease (on-release animated-offset-x end-offset-x chat-id swiped?) :onPanResponderTerminate (on-release animated-offset-x end-offset-x chat-id swiped?)}))) (defn pan-handlers [pan-responder] - (js->clj (.-panHandlers pan-responder))) \ No newline at end of file + (js->clj (.-panHandlers pan-responder))) diff --git a/src/status_im/ui/screens/home/filter/views.cljs b/src/status_im/ui/screens/home/filter/views.cljs index e4e767a18c..9b7f3025f3 100644 --- a/src/status_im/ui/screens/home/filter/views.cljs +++ b/src/status_im/ui/screens/home/filter/views.cljs @@ -95,7 +95,7 @@ (let [{:keys [show? height]} @search-input-state] (when (or show? search-filter) - [react/animated-view + [(react/animated-view) {:style {:height height}} [search-input search-filter {:on-cancel #(do diff --git a/src/status_im/ui/screens/home/views.cljs b/src/status_im/ui/screens/home/views.cljs index cdf81462b2..122a5f97b4 100644 --- a/src/status_im/ui/screens/home/views.cljs +++ b/src/status_im/ui/screens/home/views.cljs @@ -40,7 +40,7 @@ [react/view {:style styles/welcome-image-container} [components.common/image-contain {:container-style {}} - {:image (:welcome-image resources/ui) :width 750 :height 556}]] + {:image (resources/get-image :welcome-image) :width 750 :height 556}]] [react/i18n-text {:style styles/welcome-text :key :welcome-to-status}] [react/view [react/i18n-text {:style styles/welcome-text-description diff --git a/src/status_im/ui/screens/network_settings/edit_network/views.cljs b/src/status_im/ui/screens/network_settings/edit_network/views.cljs index ae7efb1edd..ad3af3b56e 100644 --- a/src/status_im/ui/screens/network_settings/edit_network/views.cljs +++ b/src/status_im/ui/screens/network_settings/edit_network/views.cljs @@ -33,7 +33,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/add-network)] - [react/scroll-view + [(react/scroll-view) [react/view styles/edit-network-view [text-input/text-input-with-label {:label (i18n/label :t/name) diff --git a/src/status_im/ui/screens/offline_messaging_settings/edit_mailserver/views.cljs b/src/status_im/ui/screens/offline_messaging_settings/edit_mailserver/views.cljs index 6ee23b4221..9e2aa71159 100644 --- a/src/status_im/ui/screens/offline_messaging_settings/edit_mailserver/views.cljs +++ b/src/status_im/ui/screens/offline_messaging_settings/edit_mailserver/views.cljs @@ -54,7 +54,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label (if id :t/mailserver-details :t/add-mailserver))] - [react/scroll-view {:keyboard-should-persist-taps :handled} + [(react/scroll-view) {:keyboard-should-persist-taps :handled} [react/view styles/edit-mailserver-view [text-input/text-input-with-label {:label (i18n/label :t/name) diff --git a/src/status_im/ui/screens/pairing/views.cljs b/src/status_im/ui/screens/pairing/views.cljs index 270afb8226..d1e454168e 100644 --- a/src/status_im/ui/screens/pairing/views.cljs +++ b/src/status_im/ui/screens/pairing/views.cljs @@ -146,7 +146,7 @@ :on-value-change (partial toggle-enabled! installation-id enabled?)}])]]]) (defn render-rows [installation-id installation-name installations] - [react/scroll-view {:style styles/wrapper} + [(react/scroll-view) {:style styles/wrapper} [your-device installation-id installation-name] (when (seq installations) [list/flat-list {:data installations @@ -156,7 +156,7 @@ (views/defview edit-installation-name [] [react/keyboard-avoiding-view styles/edit-installation - [react/scroll-view {:keyboard-should-persist-taps :handled} + [(react/scroll-view) {:keyboard-should-persist-taps :handled} [react/view [react/text (i18n/label :t/pairing-please-set-a-name)]] [text-input/text-input-with-label @@ -179,7 +179,7 @@ (defn info-section [] [react/view {:style styles/info-section} - [react/touchable-highlight {:on-press #(.openURL react/linking "https://status.im/tutorials/pairing.html")} + [react/touchable-highlight {:on-press #(.openURL (react/linking) "https://status.im/tutorials/pairing.html")} [react/text {:style styles/info-section-text} (i18n/label :t/learn-more)]]]) (defn installations-list [installation-id installation-name installations] @@ -197,7 +197,7 @@ [toolbar/toolbar {} toolbar/default-nav-back [toolbar/content-title (i18n/label :t/devices)]] - [react/scroll-view {:style {:background-color :white}} + [(react/scroll-view) {:style {:background-color :white}} (if (string/blank? installation-name) [edit-installation-name] [react/view diff --git a/src/status_im/ui/screens/profile/contact/views.cljs b/src/status_im/ui/screens/profile/contact/views.cljs index 10e7dd75c6..519910c953 100644 --- a/src/status_im/ui/screens/profile/contact/views.cljs +++ b/src/status_im/ui/screens/profile/contact/views.cljs @@ -82,7 +82,7 @@ [react/view profile.components.styles/profile [status-bar/status-bar] [profile-contact-toolbar] - [react/scroll-view + [(react/scroll-view) [react/view profile.components.styles/profile-form [profile.components/profile-header {:contact contact diff --git a/src/status_im/ui/screens/profile/group_chat/views.cljs b/src/status_im/ui/screens/profile/group_chat/views.cljs index ef2e102a5e..8a1031a6de 100644 --- a/src/status_im/ui/screens/profile/group_chat/views.cljs +++ b/src/status_im/ui/screens/profile/group_chat/views.cljs @@ -105,7 +105,7 @@ (if editing? [group-chat-profile-edit-toolbar] [group-chat-profile-toolbar admin?]) - [react/scroll-view + [(react/scroll-view) [react/view profile.components.styles/profile-form [profile.components/profile-header {:contact shown-chat diff --git a/src/status_im/ui/screens/profile/seed/views.cljs b/src/status_im/ui/screens/profile/seed/views.cljs index 8c19268eb6..b6d33e1aee 100644 --- a/src/status_im/ui/screens/profile/seed/views.cljs +++ b/src/status_im/ui/screens/profile/seed/views.cljs @@ -36,11 +36,11 @@ :second-word (re-frame/dispatch [:my-profile/set-step :first-word]))) (defn intro [] - [react/scroll-view {:style {:padding-horizontal 16} - :content-container-style {:align-items :center - :justify-content :center}} + [(react/scroll-view) {:style {:padding-horizontal 16} + :content-container-style {:align-items :center + :justify-content :center}} (when-not platform/desktop? - [react/image {:source (:lock resources/ui) + [react/image {:source (resources/get-image :lock) :style styles/intro-image}]) [react/i18n-text {:style styles/intro-text :key :your-data-belongs-to-you}] diff --git a/src/status_im/ui/screens/profile/tribute_to_talk/views.cljs b/src/status_im/ui/screens/profile/tribute_to_talk/views.cljs index 8133420325..045065045f 100644 --- a/src/status_im/ui/screens/profile/tribute_to_talk/views.cljs +++ b/src/status_im/ui/screens/profile/tribute_to_talk/views.cljs @@ -34,7 +34,7 @@ [react/view {:style {:flex 1 :min-height 32}}] - [react/image {:source (:tribute-to-talk resources/ui) + [react/image {:source (resources/get-image :tribute-to-talk) :style styles/intro-image}] [react/view {:style {:flex 1 :min-height 32}}] @@ -67,7 +67,7 @@ (defn number-view [numpad-symbol {:keys [on-press]}] - [react/touchable-opacity + [(react/touchable-opacity) {:on-press #(on-press numpad-symbol)} [react/view {:style styles/number-container} (if (= numpad-symbol :remove) @@ -96,7 +96,7 @@ (defn set-snt-amount [snt-amount] - [react/scroll-view + [(react/scroll-view) {:content-container-style styles/set-snt-amount-container} [react/view {:style (styles/horizontal-separator 16 32)}] [snt-amount-label snt-amount] @@ -109,7 +109,7 @@ (defn personalized-message [message] - [react/scroll-view + [(react/scroll-view) {:content-container-style styles/personalized-message-container} [react/view {:style styles/personalized-message-title} [react/nested-text {:style {:text-align :center}} @@ -219,7 +219,7 @@ (defn edit [snt-amount message fiat-value] - [react/scroll-view {:content-container-style styles/edit-container} + [(react/scroll-view) {:content-container-style styles/edit-container} [react/view {:style styles/edit-screen-top-row} [react/view {:style {:flex-direction :row :justify-content :flex-start @@ -312,8 +312,8 @@ (i18n/label :t/tribute-to-talk)] [react/text {:style styles/step-n} (i18n/label :t/learn-more)]]]) - [react/scroll-view {:content-container-style styles/learn-more-container} - [react/image {:source (:tribute-to-talk resources/ui) + [(react/scroll-view) {:content-container-style styles/learn-more-container} + [react/image {:source (resources/get-image :tribute-to-talk) :style styles/learn-more-image}] [react/text {:style styles/learn-more-title-text} (i18n/label :t/tribute-to-talk)] @@ -347,12 +347,11 @@ :t/tribute-to-talk-paywall-learn-more-3))]]]]) (defview tribute-to-talk [] - (letsubs [current-account [:account/account] - {:keys [step snt-amount editing? message + (letsubs [{:keys [step snt-amount editing? message fiat-value disable-button? state]} [:tribute-to-talk/ui]] [react/keyboard-avoiding-view {:style styles/container} - [react/safe-area-view {:style {:flex 1}} + [(react/safe-area-view) {:style {:flex 1}} [status-bar/status-bar] [toolbar/toolbar nil diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 18e8b7cf79..4b9c07d132 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -125,7 +125,7 @@ :action-fn #(re-frame/dispatch [:profile.ui/keycard-settings-button-pressed])}]) [profile.components/settings-item {:label-kw :t/notifications :accessibility-label :notifications-button - :action-fn #(.openURL react/linking "app-settings://notification/status-im")}] + :action-fn #(.openURL (react/linking) "app-settings://notification/status-im")}] [profile.components/settings-item-separator] [profile.components/settings-item {:label-kw :t/mobile-network-settings :accessibility-label :notifications-button @@ -311,7 +311,7 @@ [react/keyboard-avoiding-view {:style {:flex 1}} [status-bar/status-bar {:type :main}] [toolbar/simple-toolbar label] - [react/scroll-view + [(react/scroll-view) [view]]])) (defview my-profile [] @@ -343,8 +343,8 @@ (if editing? [my-profile-edit-toolbar on-show-edit] [my-profile-toolbar]) - [react/scroll-view {:ref #(reset! scroll %) - :keyboard-should-persist-taps :handled} + [(react/scroll-view) {:ref #(reset! scroll %) + :keyboard-should-persist-taps :handled} [react/view profile.components.styles/profile-form [profile.components/profile-header {:contact current-account diff --git a/src/status_im/ui/screens/routing/core.cljs b/src/status_im/ui/screens/routing/core.cljs index 0c435b42d3..4c8bd9bce5 100644 --- a/src/status_im/ui/screens/routing/core.cljs +++ b/src/status_im/ui/screens/routing/core.cljs @@ -85,7 +85,7 @@ active? (reagent.core/atom true)] (if platform/android? [react/view common-styles/modal - [react/modal + [(react/modal) {:transparent true :animation-type :slide :on-request-close (fn [] diff --git a/src/status_im/ui/screens/stickers/views.cljs b/src/status_im/ui/screens/stickers/views.cljs index 3fba805620..6b049a8154 100644 --- a/src/status_im/ui/screens/stickers/views.cljs +++ b/src/status_im/ui/screens/stickers/views.cljs @@ -64,7 +64,7 @@ [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/sticker-market)] - [react/scroll-view {:keyboard-should-persist-taps :handled :style {:padding 16}} + [(react/scroll-view) {:keyboard-should-persist-taps :handled :style {:padding 16}} [react/view (for [pack packs] ^{:key pack} @@ -87,7 +87,7 @@ [installed-icon] [price-badge price id owned pending])] [react/view {:style {:padding-top 8 :flex 1}} - [react/scroll-view {:keyboard-should-persist-taps :handled :style {:flex 1}} + [(react/scroll-view) {:keyboard-should-persist-taps :handled :style {:flex 1}} [react/view {:flex-direction :row :flex-wrap :wrap} (for [{:keys [uri]} stickers] ^{:key uri} diff --git a/src/status_im/ui/screens/views.cljs b/src/status_im/ui/screens/views.cljs index 795d0464f1..b9d348d179 100644 --- a/src/status_im/ui/screens/views.cljs +++ b/src/status_im/ui/screens/views.cljs @@ -15,7 +15,7 @@ [status-im.ui.screens.home.sheet.views :as home.sheet] [status-im.ui.screens.routing.core :as routing])) -(defonce rand-label (rand/id)) +(defonce rand-label (when js/goog.DEBUG (rand/id))) (defonce initial-view-id (atom nil)) diff --git a/src/status_im/ui/screens/wallet/choose_recipient/events.cljs b/src/status_im/ui/screens/wallet/choose_recipient/events.cljs index d7ad04f2da..bb0fae988a 100644 --- a/src/status_im/ui/screens/wallet/choose_recipient/events.cljs +++ b/src/status_im/ui/screens/wallet/choose_recipient/events.cljs @@ -65,7 +65,7 @@ (defn use-default-eth-gas [fx] (assoc-in fx [:db :wallet :send-transaction :gas] - ethereum/default-transaction-gas)) + (ethereum/default-transaction-gas))) (re-frame/reg-fx :resolve-address diff --git a/src/status_im/ui/screens/wallet/custom_tokens/views.cljs b/src/status_im/ui/screens/wallet/custom_tokens/views.cljs index 1112d5585d..94c48736ba 100644 --- a/src/status_im/ui/screens/wallet/custom_tokens/views.cljs +++ b/src/status_im/ui/screens/wallet/custom_tokens/views.cljs @@ -31,7 +31,7 @@ toolbar/default-nav-back [toolbar/content-title (i18n/label :t/add-custom-token)]] - [react/scroll-view {:keyboard-should-persist-taps :handled :style {:flex 1 :margin-top 8 :padding-horizontal 16}} + [(react/scroll-view) {:keyboard-should-persist-taps :handled :style {:flex 1 :margin-top 8 :padding-horizontal 16}} [react/view {:style {:flex-direction :row :justify-content :space-between :padding-vertical 10}} [react/text (i18n/label :t/contract-address)] (if in-progress? @@ -143,4 +143,4 @@ :icon-opts {:color colors/red} :label-style {:color colors/red} :cyrcle-color (colors/alpha colors/red 0.1) - :on-press #(re-frame/dispatch [:wallet.custom-token.ui/remove-pressed token true])}])]])) \ No newline at end of file + :on-press #(re-frame/dispatch [:wallet.custom-token.ui/remove-pressed token true])}])]])) diff --git a/src/status_im/ui/screens/wallet/main/views.cljs b/src/status_im/ui/screens/wallet/main/views.cljs index e4e7d02109..dcacb3bbe4 100644 --- a/src/status_im/ui/screens/wallet/main/views.cljs +++ b/src/status_im/ui/screens/wallet/main/views.cljs @@ -164,12 +164,13 @@ [react/view styles/main-section [status-bar.view/status-bar {:type :wallet-tab}] [settings/toolbar-view] - [react/scroll-view {:end-fill-color colors/white - :refresh-control - (reagent/as-element - [react/refresh-control {:on-refresh #(re-frame/dispatch [:wallet.ui/pull-to-refresh]) - :tint-color :white - :refreshing false}])} + [(react/scroll-view) {:end-fill-color + colors/white + :refresh-control + (reagent/as-element + [(react/refresh-control) {:on-refresh #(re-frame/dispatch [:wallet.ui/pull-to-refresh]) + :tint-color :white + :refreshing false}])} (if error-message [snackbar error-message] [total-section portfolio-value currency]) diff --git a/src/status_im/ui/screens/wallet/navigation.cljs b/src/status_im/ui/screens/wallet/navigation.cljs index 9f7a42e976..0347224756 100644 --- a/src/status_im/ui/screens/wallet/navigation.cljs +++ b/src/status_im/ui/screens/wallet/navigation.cljs @@ -5,10 +5,15 @@ [status-im.ui.screens.navigation :as navigation])) (def transaction-send-default - (let [symbol :ETH] - {:gas (ethereum/estimate-gas symbol) - :method constants/web3-send-transaction - :symbol symbol})) + (let [symbol :ETH + request (atom nil)] + (fn [] + (or @request + (reset! + request + {:gas (ethereum/estimate-gas symbol) + :method constants/web3-send-transaction + :symbol symbol}))))) (def transaction-request-default {:symbol :ETH}) @@ -19,7 +24,7 @@ db (-> db (assoc-in [:wallet :request-transaction] transaction-request-default) - (assoc-in [:wallet :send-transaction] transaction-send-default)))) + (assoc-in [:wallet :send-transaction] (transaction-send-default))))) (defmethod navigation/preload-data! :wallet-send-transaction [db [event]] @@ -27,7 +32,7 @@ db (do (re-frame/dispatch [:wallet/update-gas-price]) - (assoc-in db [:wallet :send-transaction] transaction-send-default)))) + (assoc-in db [:wallet :send-transaction] (transaction-send-default))))) (defmethod navigation/preload-data! :wallet-add-custom-token [db [event]] diff --git a/src/status_im/ui/screens/wallet/onboarding/views.cljs b/src/status_im/ui/screens/wallet/onboarding/views.cljs index 181473d323..be7fba0b70 100644 --- a/src/status_im/ui/screens/wallet/onboarding/views.cljs +++ b/src/status_im/ui/screens/wallet/onboarding/views.cljs @@ -119,7 +119,7 @@ (defn onboarding [] [react/view styles/root [react/view {:style styles/onboarding-image-container} - [react/image {:source (:wallet-welcome resources/ui) + [react/image {:source (resources/get-image :wallet-welcome) :style styles/onboarding-image}]] [react/text {:style styles/onboarding-title} (i18n/label :t/wallet-onboarding-title)] diff --git a/src/status_im/ui/screens/wallet/request/views.cljs b/src/status_im/ui/screens/wallet/request/views.cljs index 1f7cf0ece2..677d8f161c 100644 --- a/src/status_im/ui/screens/wallet/request/views.cljs +++ b/src/status_im/ui/screens/wallet/request/views.cljs @@ -36,7 +36,7 @@ [wallet.components/toolbar (i18n/label :t/new-request)] [react/view components.styles/flex [common/network-info {:text-color :white}] - [react/scroll-view {:ref #(reset! scroll %) :keyboardShouldPersistTaps :always} + [(react/scroll-view) {:ref #(reset! scroll %) :keyboardShouldPersistTaps :always} [react/view styles/request-details-wrapper [wallet.components/recipient-selector {:contact-only? true diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index 48d30acb1f..1adff09f35 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -73,10 +73,10 @@ bottom-value (animation/create-value -250) opacity-value (animation/create-value 0)] {:component-did-mount #(send.animations/animate-sign-panel opacity-value bottom-value)} - [react/animated-view {:style (styles/animated-sign-panel bottom-value)} + [(react/animated-view) {:style (styles/animated-sign-panel bottom-value)} (when wrong-password? [tooltip/tooltip (i18n/label :t/wrong-password) styles/password-error-tooltip]) - [react/animated-view {:style (styles/sign-panel opacity-value)} + [(react/animated-view) {:style (styles/sign-panel opacity-value)} [react/view styles/spinner-container (when spinning? [react/activity-indicator {:animating true @@ -161,10 +161,10 @@ [toolbar modal? (i18n/label :t/send-transaction)] [react/view components.styles/flex [common/network-info {:text-color :white}] - [react/scroll-view {:keyboard-should-persist-taps :always - :ref #(reset! scroll %) - :on-content-size-change #(when (and (not modal?) scroll @scroll) - (.scrollToEnd @scroll))} + [(react/scroll-view) {:keyboard-should-persist-taps :always + :ref #(reset! scroll %) + :on-content-size-change #(when (and (not modal?) scroll @scroll) + (.scrollToEnd @scroll))} (when-not online? [wallet.main.views/snackbar :t/error-cant-send-transaction-offline]) [react/view styles/send-transaction-form @@ -211,8 +211,8 @@ (reagent/create-class {:component-will-mount (fn [_] ;;NOTE(goranjovic): keyboardDidShow is for android and keyboardWillShow for ios - (.addListener react/keyboard "keyboardDidShow" handler) - (.addListener react/keyboard "keyboardWillShow" handler)) + (.addListener (react/keyboard) "keyboardDidShow" handler) + (.addListener (react/keyboard) "keyboardWillShow" handler)) :reagent-render (fn [opts] (render-send-transaction-view (assoc opts :amount-input amount-input)))}))) diff --git a/src/status_im/ui/screens/wallet/sign_message/views.cljs b/src/status_im/ui/screens/wallet/sign_message/views.cljs index 09d0436e5e..3c999dd40b 100644 --- a/src/status_im/ui/screens/wallet/sign_message/views.cljs +++ b/src/status_im/ui/screens/wallet/sign_message/views.cljs @@ -57,10 +57,10 @@ bottom-value (animation/create-value -250) opacity-value (animation/create-value 0)] {:component-did-mount #(send.animations/animate-sign-panel opacity-value bottom-value)} - [react/animated-view {:style (styles/animated-sign-panel bottom-value)} + [(react/animated-view) {:style (styles/animated-sign-panel bottom-value)} (when (:wrong-password? @value-atom) [tooltip/tooltip (i18n/label :t/wrong-password) styles/password-error-tooltip]) - [react/animated-view {:style (styles/sign-panel opacity-value)} + [(react/animated-view) {:style (styles/sign-panel opacity-value)} [react/view styles/spinner-container (when spinning? [react/activity-indicator {:animating true @@ -89,7 +89,7 @@ [wallet.components/simple-screen {:status-bar-type :modal-wallet} [toolbar true (i18n/label :t/sign-message)] [react/view components.styles/flex - [react/scroll-view + [(react/scroll-view) (when (= network-status :offline) [wallet.main.views/snackbar :t/error-cant-sign-message-offline]) [react/view styles/send-transaction-form diff --git a/src/status_im/ui/screens/wallet/transactions/views.cljs b/src/status_im/ui/screens/wallet/transactions/views.cljs index ed6acac44e..62c00f23e7 100644 --- a/src/status_im/ui/screens/wallet/transactions/views.cljs +++ b/src/status_im/ui/screens/wallet/transactions/views.cljs @@ -234,8 +234,8 @@ (defn details-action [hash url] [(actions/opts [{:label (i18n/label :t/copy-transaction-hash) :action #(react/copy-to-clipboard hash)} - {:label (i18n/label :t/open-on-etherscan) - :action #(.openURL react/linking url)}])]) + {:label (i18n/label :t/open-on-etherscan) + :action #(.openURL (react/linking) url)}])]) (defview transaction-details [] (letsubs [{:keys [hash url type confirmations confirmations-progress @@ -248,7 +248,7 @@ toolbar/default-nav-back [toolbar/content-title (i18n/label :t/transaction-details)] (when transaction [toolbar/actions (details-action hash url)])] - [react/scroll-view {:style components.styles/main-container} + [(react/scroll-view) {:style components.styles/main-container} [details-header date type amount-text currency-text] [details-confirmations confirmations confirmations-progress (= :failed type)] [react/view {:style styles/details-separator}] diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index e2af59e9cc..4743645b09 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -3,11 +3,14 @@ [status-im.utils.platform :as platform] [clojure.string :as string])) -(def config (js->clj (.-default rn-dependencies/config) :keywordize-keys true)) +(def config + (memoize + (fn [] + (js->clj (.-default (rn-dependencies/config)) :keywordize-keys true)))) (defn get-config - ([k] (get config k)) - ([k not-found] (get config k not-found))) + ([k] (get (config) k)) + ([k not-found] (get (config) k not-found))) ;; TODO(oskarth): Extend this to deal with true/false for Jenkins parameter builds (defn enabled? [v] (= "1" v)) diff --git a/src/status_im/utils/dimensions.cljs b/src/status_im/utils/dimensions.cljs index d7f185da28..32fde81084 100644 --- a/src/status_im/utils/dimensions.cljs +++ b/src/status_im/utils/dimensions.cljs @@ -3,7 +3,7 @@ [status-im.ui.components.react :as react])) (defn add-event-listener [] - (.addEventListener react/dimensions + (.addEventListener (react/dimensions) "change" #(re-frame/dispatch [:update-window-dimensions %]))) diff --git a/src/status_im/utils/email.cljs b/src/status_im/utils/email.cljs index 389571b8ef..7eff9955b2 100644 --- a/src/status_im/utils/email.cljs +++ b/src/status_im/utils/email.cljs @@ -7,7 +7,7 @@ :email/send ;; https://github.com/chirag04/react-native-mail#example (fn [[opts callback]] - (.mail dependencies/react-native-mail + (.mail (dependencies/react-native-mail) (clj->js opts) callback))) diff --git a/src/status_im/utils/fs.cljs b/src/status_im/utils/fs.cljs index 8052e9712c..440a80e3b0 100644 --- a/src/status_im/utils/fs.cljs +++ b/src/status_im/utils/fs.cljs @@ -2,21 +2,21 @@ (:require [status-im.react-native.js-dependencies :as rn-dependencies])) (defn move-file [src dst] - (.moveFile rn-dependencies/fs src dst)) + (.moveFile (rn-dependencies/fs) src dst)) (defn read-file [path encoding on-read on-error] - (-> (.readFile rn-dependencies/fs path encoding) + (-> (.readFile (rn-dependencies/fs) path encoding) (.then on-read) (.catch on-error))) (defn read-dir [path] - (.readDir rn-dependencies/fs path)) + (.readDir (rn-dependencies/fs) path)) (defn mkdir [path] - (.mkdir rn-dependencies/fs path)) + (.mkdir (rn-dependencies/fs) path)) (defn unlink [path] - (.unlink rn-dependencies/fs path)) + (.unlink (rn-dependencies/fs) path)) (defn file-exists? [path] - (.exists rn-dependencies/fs path)) + (.exists (rn-dependencies/fs) path)) diff --git a/src/status_im/utils/homoglyph.cljs b/src/status_im/utils/homoglyph.cljs index ad2dffe555..e5b26cd7a3 100644 --- a/src/status_im/utils/homoglyph.cljs +++ b/src/status_im/utils/homoglyph.cljs @@ -2,4 +2,4 @@ (:require [status-im.js-dependencies :as dependencies])) (defn matches [s1 s2] - (.isMatches dependencies/homoglyph-finder s1 s2)) + (.isMatches (dependencies/homoglyph-finder) s1 s2)) diff --git a/src/status_im/utils/http.cljs b/src/status_im/utils/http.cljs index bb19e3752e..24f5f6fd19 100644 --- a/src/status_im/utils/http.cljs +++ b/src/status_im/utils/http.cljs @@ -18,11 +18,12 @@ ([url body on-success on-error] (raw-post url body on-success on-error nil)) ([url body on-success on-error {:keys [timeout-ms]}] - (-> (rn-dependencies/fetch url - (clj->js {:method "POST" - :headers {"Cache-Control" "no-cache"} - :body body - :timeout (or timeout-ms http-request-default-timeout-ms)})) + (-> ((rn-dependencies/fetch) + url + (clj->js {:method "POST" + :headers {"Cache-Control" "no-cache"} + :body body + :timeout (or timeout-ms http-request-default-timeout-ms)})) (.then (fn [response] (-> (.text response) @@ -41,7 +42,7 @@ ([url data on-success on-error] (post url data on-success on-error nil)) ([url data on-success on-error {:keys [valid-response? timeout-ms headers]}] - (-> (rn-dependencies/fetch + (-> ((rn-dependencies/fetch) url (clj->js (merge {:method "POST" :body data @@ -81,10 +82,11 @@ ([url on-success on-error] (raw-get url on-success on-error nil)) ([url on-success on-error {:keys [timeout-ms]}] - (-> (rn-dependencies/fetch url - (clj->js {:method "GET" - :headers {"Cache-Control" "no-cache"} - :timeout (or timeout-ms http-request-default-timeout-ms)})) + (-> ((rn-dependencies/fetch) + url + (clj->js {:method "GET" + :headers {"Cache-Control" "no-cache"} + :timeout (or timeout-ms http-request-default-timeout-ms)})) (.then (fn [response] (-> (.text response) @@ -105,10 +107,11 @@ ([url on-success on-error params] (get url on-success on-error params nil)) ([url on-success on-error {:keys [valid-response? timeout-ms]} headers] - (-> (rn-dependencies/fetch url - (clj->js {:method "GET" - :headers (merge {"Cache-Control" "no-cache"} headers) - :timeout (or timeout-ms http-request-default-timeout-ms)})) + (-> ((rn-dependencies/fetch) + url + (clj->js {:method "GET" + :headers (merge {"Cache-Control" "no-cache"} headers) + :timeout (or timeout-ms http-request-default-timeout-ms)})) (.then (fn [response] (-> (.text response) diff --git a/src/status_im/utils/identicon.cljs b/src/status_im/utils/identicon.cljs index 401388fdcd..ed22d61835 100644 --- a/src/status_im/utils/identicon.cljs +++ b/src/status_im/utils/identicon.cljs @@ -9,4 +9,5 @@ :size default-size}))) ([hash options] (str "data:image/png;base64," - (str (new dependencies/identicon-js hash options))))) + (let [identicon-js (dependencies/identicon-js)] + (str (new identicon-js hash options)))))) diff --git a/src/status_im/utils/image_processing.cljs b/src/status_im/utils/image_processing.cljs index 5c5568063c..65050d7086 100644 --- a/src/status_im/utils/image_processing.cljs +++ b/src/status_im/utils/image_processing.cljs @@ -4,7 +4,7 @@ [status-im.react-native.js-dependencies :as rn-dependencies])) (defn- resize [path max-width max-height on-resize on-error] - (let [resize-fn (-> rn-dependencies/image-resizer + (let [resize-fn (-> (rn-dependencies/image-resizer) (object/get "default") (object/get "createResizedImage"))] (-> (resize-fn path max-width max-height "JPEG" 75 0 nil) diff --git a/src/status_im/utils/js_require.clj b/src/status_im/utils/js_require.clj new file mode 100644 index 0000000000..780b949abf --- /dev/null +++ b/src/status_im/utils/js_require.clj @@ -0,0 +1,9 @@ +(ns status-im.utils.js-require) + +(defmacro js-require [module-name] + (let [js-module (gensym)] + `(let [~js-module (atom nil)] + (fn [] + (if (deref ~js-module) + (deref ~js-module) + (reset! ~js-module (js/require ~module-name))))))) diff --git a/src/status_im/utils/keychain/core.cljs b/src/status_im/utils/keychain/core.cljs index a1d241cbbb..693ea853e7 100644 --- a/src/status_im/utils/keychain/core.cljs +++ b/src/status_im/utils/keychain/core.cljs @@ -37,7 +37,7 @@ ;; to an address (`server`) property. (defn enum-val [enum-name value-name] - (get-in (js->clj rn/keychain) [enum-name value-name])) + (get-in (js->clj (rn/keychain)) [enum-name value-name])) ;; We need a more strict access mode for keychain entries that save user password. ;; iOS @@ -72,13 +72,13 @@ ;; Android only (defn- secure-hardware-available? [callback] - (-> (.getSecurityLevel rn/keychain) + (-> (.getSecurityLevel (rn/keychain)) (.then (fn [level] (callback (= level keychain-secure-hardware)))))) ;; iOS only (defn- device-encrypted? [callback] (-> (.canImplyAuthentication - rn/keychain + (rn/keychain) (clj->js {:authenticationType (enum-val "ACCESS_CONTROL" "BIOMETRY_ANY_OR_DEVICE_PASSCODE")})) @@ -86,7 +86,7 @@ ;; Stores the password for the address to the Keychain (defn save-user-password [address password callback] - (-> (.setInternetCredentials rn/keychain address address password keychain-secure-hardware (clj->js keychain-restricted-availability)) + (-> (.setInternetCredentials (rn/keychain) address address password keychain-secure-hardware (clj->js keychain-restricted-availability)) (.then callback))) (defn handle-callback [callback result] @@ -97,7 +97,7 @@ ;; Gets the password for a specified address from the Keychain (defn get-user-password [address callback] (if (or platform/ios? platform/android?) - (-> (.getInternetCredentials rn/keychain address) + (-> (.getInternetCredentials (rn/keychain) address) (.then (partial handle-callback callback))) (callback))) ;; no-op for Desktop @@ -105,7 +105,7 @@ ;; (example of usage is logout or signing in w/o "save-password") (defn clear-user-password [address callback] (if (or platform/ios? platform/android?) - (-> (.resetInternetCredentials rn/keychain address) + (-> (.resetInternetCredentials (rn/keychain) address) (.then callback)) (callback true))) ;; no-op for Desktop @@ -147,14 +147,14 @@ (defn store [encryption-key] (log/debug "storing encryption key") (-> (.setGenericPassword - rn/keychain + (rn/keychain) username (.stringify js/JSON encryption-key)) (.then (constantly encryption-key)))) (defn create [] (log/debug "no key exists, creating...") - (.. (rn/secure-random key-bytes) + (.. ((rn/secure-random) key-bytes) (then bytes->js-array))) (defn handle-not-found [] @@ -174,7 +174,7 @@ (js/Promise. (fn [on-success _] (on-success (security/unmask @generic-password)))) - (.. (.getGenericPassword rn/keychain) + (.. (.getGenericPassword (rn/keychain)) (then (fn [res] (if res @@ -195,10 +195,10 @@ (defn reset [] (log/debug "resetting key...") - (.resetGenericPassword rn/keychain)) + (.resetGenericPassword (rn/keychain))) (defn set-username [] - (when platform/desktop? (.setUsername rn/keychain username))) + (when platform/desktop? (.setUsername (rn/keychain) username))) ;;;; Effects diff --git a/src/status_im/utils/money.cljs b/src/status_im/utils/money.cljs index 875be659c9..208d4c407c 100644 --- a/src/status_im/utils/money.cljs +++ b/src/status_im/utils/money.cljs @@ -30,7 +30,7 @@ (defn bignumber [n] (when n (try - (dependencies/Web3.prototype.toBigNumber (normalize (str n))) + (.toBigNumber (dependencies/web3-prototype) (normalize (str n))) (catch :default err nil)))) (defn valid? [bn] @@ -40,37 +40,42 @@ (defn str->wei [s] (when-let [ns (normalize s)] (try - (dependencies/Web3.prototype.toWei ns "ether") + (.toWei (dependencies/web3-prototype) ns "ether") (catch :default err nil)))) (defn to-decimal [s] (when s (try - (dependencies/Web3.prototype.toDecimal (normalize s)) + (.toDecimal (dependencies/web3-prototype) (normalize s)) (catch :default err nil)))) (defn from-decimal [n] (when n (str "1" (string/join (repeat n "0"))))) (def eth-units - {:wei (bignumber "1") - :kwei (bignumber (from-decimal 3)) - :mwei (bignumber (from-decimal 6)) - :gwei (bignumber (from-decimal 9)) - :szabo (bignumber (from-decimal 12)) - :finney (bignumber (from-decimal 15)) - :eth (bignumber (from-decimal 18)) - :keth (bignumber (from-decimal 21)) - :meth (bignumber (from-decimal 24)) - :geth (bignumber (from-decimal 27)) - :teth (bignumber (from-decimal 30))}) + (let [units (atom nil)] + (fn [] + (or @units + (reset! + units + {:wei (bignumber "1") + :kwei (bignumber (from-decimal 3)) + :mwei (bignumber (from-decimal 6)) + :gwei (bignumber (from-decimal 9)) + :szabo (bignumber (from-decimal 12)) + :finney (bignumber (from-decimal 15)) + :eth (bignumber (from-decimal 18)) + :keth (bignumber (from-decimal 21)) + :meth (bignumber (from-decimal 24)) + :geth (bignumber (from-decimal 27)) + :teth (bignumber (from-decimal 30))}))))) (defn wei-> [unit n] (when-let [bn (bignumber n)] - (.dividedBy bn (eth-units unit)))) + (.dividedBy bn ((eth-units) unit)))) (defn ->wei [unit n] (when-let [bn (bignumber n)] - (.times bn (eth-units unit)))) + (.times bn ((eth-units) unit)))) (defn to-fixed [bn] (when bn diff --git a/src/status_im/utils/platform.cljs b/src/status_im/utils/platform.cljs index 5cc3f167d5..2a53c208c1 100644 --- a/src/status_im/utils/platform.cljs +++ b/src/status_im/utils/platform.cljs @@ -33,9 +33,9 @@ (defn no-backup-directory [] (cond - android? (str (.-DocumentDirectoryPath rn-dependencies/fs) + android? (str (.-DocumentDirectoryPath (rn-dependencies/fs)) "/../no_backup") - ios? (.-LibraryDirectoryPath rn-dependencies/fs))) + ios? (.-LibraryDirectoryPath (rn-dependencies/fs)))) (defn android-version>= [v] (and android? (>= version v))) diff --git a/src/status_im/utils/random.cljs b/src/status_im/utils/random.cljs index 6a4bbb7a47..bc77168636 100644 --- a/src/status_im/utils/random.cljs +++ b/src/status_im/utils/random.cljs @@ -3,17 +3,20 @@ [status-im.js-dependencies :as dependencies] [status-im.utils.datetime :as datetime])) -(def chance (dependencies/Chance.)) +(defn chance [] + (let [Chance (dependencies/Chance)] + (Chance.))) (defn guid [] - (.guid chance)) + (.guid (chance))) (defn id [] - (str (datetime/timestamp) "-" (.guid chance))) + (str (datetime/timestamp) "-" (.guid (chance)))) (defn rand-gen [seed] - (dependencies/Chance. seed)) + (let [Chance (dependencies/Chance)] + (Chance. seed))) (defn seeded-rand-int [gen n] (.integer gen #js {:min 0 :max (dec n)})) diff --git a/src/status_im/utils/snoopy.cljs b/src/status_im/utils/snoopy.cljs index 8b615fe4e3..d9ea912163 100644 --- a/src/status_im/utils/snoopy.cljs +++ b/src/status_im/utils/snoopy.cljs @@ -2,10 +2,10 @@ (:require [status-im.react-native.js-dependencies :as js-dependencies] [status-im.utils.config :as config])) -(def snoopy (.-default js-dependencies/snoopy)) -(def sn-filter (.-default js-dependencies/snoopy-filter)) -(def bars (.-default js-dependencies/snoopy-bars)) -(def buffer (.-default js-dependencies/snoopy-buffer)) +(defn snoopy [] (.-default js-dependencies/snoopy)) +(defn sn-filter [] (.-default js-dependencies/snoopy-filter)) +(defn bars [] (.-default js-dependencies/snoopy-bars)) +(defn buffer [] (.-default js-dependencies/snoopy-buffer)) (defn create-filter [f] (fn [message] @@ -54,21 +54,24 @@ (defn threshold-warnings [{:keys [filter-fn label tick? print-events? threshold events threshold-message]}] - (.subscribe ((bars + (.subscribe (((bars) (fn [a] (.-length a)) threshold tick? true label threshold-message) - ((buffer) ((sn-filter (create-filter filter-fn) - print-events?) - events))))) + (((buffer)) + (((sn-filter) + (create-filter filter-fn) + print-events?) + events))))) (defn subscribe! [] (when config/rn-bridge-threshold-warnings-enabled? - (let [emitter (js-dependencies/EventEmmiter.) - events (.stream snoopy emitter)] + ;;(js-dependencies/EventEmmiter.) + (let [emitter nil + events (.stream (snoopy) emitter)] (threshold-warnings {:filter-fn (constantly true) :label "all messages" diff --git a/src/status_im/utils/universal_links/core.cljs b/src/status_im/utils/universal_links/core.cljs index 52008f1dea..429f188fa4 100644 --- a/src/status_im/utils/universal_links/core.cljs +++ b/src/status_im/utils/universal_links/core.cljs @@ -156,15 +156,15 @@ and handles incoming url if the app has been started by clicking on a link" [] (log/debug "universal-links: initializing") - (.. react/linking + (.. (react/linking) (getInitialURL) (then dispatch-url)) - (.. react/linking + (.. (react/linking) (addEventListener "url" url-event-listener))) (defn finalize "Remove event listener for url" [] (log/debug "universal-links: finalizing") - (.. react/linking + (.. (react/linking) (removeEventListener "url" url-event-listener))) diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 7be39b83b1..b6610604b0 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -74,7 +74,7 @@ (defn set-timeout [cb ms] (if platform/desktop? (js/setTimeout cb ms) - (.setTimeout rn-dependencies/background-timer cb ms))) + (.setTimeout (rn-dependencies/background-timer) cb ms))) (defn unread-messages-count "display actual # if less than 1K, round to the lowest thousand if between 1 and 10K, otherwise 10K+ for anything larger" @@ -99,14 +99,14 @@ (defn clear-timeout [id] (if platform/desktop? (js/clearTimeout id) - (.clearTimeout rn-dependencies/background-timer id))) + (.clearTimeout (rn-dependencies/background-timer) id))) (defn set-interval [cb ms] (if platform/desktop? (js/setInterval cb ms) - (.setInterval rn-dependencies/background-timer cb ms))) + (.setInterval (rn-dependencies/background-timer) cb ms))) (defn clear-interval [id] (if platform/desktop? (js/clearInterval id) - (.clearInterval rn-dependencies/background-timer id))) + (.clearInterval (rn-dependencies/background-timer) id))) diff --git a/src/status_im/utils/varint.cljs b/src/status_im/utils/varint.cljs index 9c863f95fb..f350b32ede 100644 --- a/src/status_im/utils/varint.cljs +++ b/src/status_im/utils/varint.cljs @@ -3,7 +3,7 @@ (:require [status-im.ethereum.abi-spec :as abi-spec] [status-im.js-dependencies :as dependencies])) -(def utils dependencies/web3-utils) +(defn utils [] (dependencies/web3-utils)) (def most-significant-bit 0x80) (def biggest-int-per-byte 0x7F) @@ -23,7 +23,7 @@ (defn encode-hex [num] (reduce (fn [hex current-bit] (str hex - (.leftPad utils + (.leftPad (utils) (abi-spec/number-to-hex current-bit) 2))) "" diff --git a/src/status_im/web3/core.cljs b/src/status_im/web3/core.cljs index 39d49ca32e..7cba79196a 100644 --- a/src/status_im/web3/core.cljs +++ b/src/status_im/web3/core.cljs @@ -13,14 +13,15 @@ It should be only used for internal application needs and never provided to any 3rd parties (DApps, etc)" [] - (dependencies/Web3. - #js {:sendAsync (fn [payload callback] - (status/call-private-rpc - (.stringify js/JSON payload) - (fn [response] - (if (= "" response) - (log/warn :web3-response-error) - (callback nil (.parse js/JSON response))))))})) + (let [Web3 (dependencies/Web3)] + (Web3. + #js {:sendAsync (fn [payload callback] + (status/call-private-rpc + (.stringify js/JSON payload) + (fn [response] + (if (= "" response) + (log/warn :web3-response-error) + (callback nil (.parse js/JSON response))))))}))) (defn get-web3 [cofx] (let [web3 (make-internal-web3)] diff --git a/test/cljs/status_im/react_native/js_dependencies.cljs b/test/cljs/status_im/react_native/js_dependencies.cljs index 5f0a644a53..3afee1d369 100644 --- a/test/cljs/status_im/react_native/js_dependencies.cljs +++ b/test/cljs/status_im/react_native/js_dependencies.cljs @@ -1,21 +1,18 @@ (ns status-im.react-native.js-dependencies) -(def action-button #js {:default #js {:Item #js {}}}) -(def config #js {:default #js {}}) -(def camera #js {:default #js {:constants #js {}}}) -(def dialogs #js {}) -(def dismiss-keyboard #js {}) -(def emoji-picker #js {:default #js {}}) -(def fs #js {}) -(def http-bridge #js {}) +(def action-button (fn [] #js {:default #js {:Item #js {}}})) +(def config (fn [] #js {:default #js {}})) +(def camera (fn [] #js {:default #js {:constants #js {}}})) +(def dialogs (fn [] #js {})) +(def dismiss-keyboard (fn [] #js {})) +(def emoji-picker (fn [] #js {:default #js {}})) +(def fs (fn [] #js {})) +(def http-bridge (fn [] #js {})) (def i18n #js {:locale "en"}) (def react-native-languages #js {:language "en", :addEventListener (fn []), :removeEventListener (fn [])}) -(def image-crop-picker #js {}) -(def image-resizer #js {}) -(def linear-gradient #js {}) -(def nfc #js {}) -(def orientation #js {}) -(def qr-code #js {}) +(def image-crop-picker (fn [] #js {})) +(def image-resizer (fn [] #js {})) +(def qr-code (fn [] #js {})) (def react-native #js {:NativeModules #js {} :Animated #js {:View #js {} @@ -25,33 +22,34 @@ (def realm #js {:schemaVersion (fn []) :defaultPath "/tmp/realm" :close (fn [])}) -(def vector-icons #js {:default #js {}}) -(def webview-bridge #js {:default #js {}}) -(def webview #js {:WebView #js {}}) -(def svg #js {:default #js {}}) -(def status-keycard #js {:default #js {}}) +(def vector-icons (fn [] #js {:default #js {}})) +(def webview-bridge (fn [] #js {:default #js {}})) +(def webview (fn [] #js {:WebView #js {}})) +(def svg (fn [] #js {:default #js {}})) +(def status-keycard (fn [] #js {:default #js {}})) (defrecord Notification []) -(def react-native-firebase #js {:default #js {:notifications #js {:Notification Notification}}}) +(def react-native-firebase (fn [] #js {:default #js {:notifications #js {:Notification Notification}}})) (def desktop-linking #js {:addEventListener (fn [])}) (def desktop-shortcuts #js {:addEventListener (fn [])}) -(def snoopy #js {:default #js {}}) -(def snoopy-filter #js {:default #js {}}) -(def snoopy-bars #js {:default #js {}}) -(def snoopy-buffer #js {:default #js {}}) -(def EventEmmiter #js {}) -(def fetch #js {}) +(def snoopy (fn [] #js {:default #js {}})) +(def snoopy-filter (fn [] #js {:default #js {}})) +(def snoopy-bars (fn [] #js {:default #js {}})) +(def snoopy-buffer (fn [] #js {:default #js {}})) -(def background-timer #js {:setTimeout js/setTimeout - :setInterval js/setInterval - :clearTimeout js/clearTimeout - :clearInterval js/clearInterval}) +(def fetch (fn [] #js {})) -(def keychain #js {:setGenericPassword (constantly (.resolve js/Promise true))}) -(def secure-random #(.resolve js/Promise (clj->js (range 0 %)))) +(def background-timer (fn [] #js {:setTimeout js/setTimeout + :setInterval js/setInterval + :clearTimeout js/clearTimeout + :clearInterval js/clearInterval})) + +(def keychain (fn [] #js {:setGenericPassword (constantly (.resolve js/Promise true))})) +(def secure-random (fn [] #(.resolve js/Promise (clj->js (range 0 %))))) (def react-navigation #js {:NavigationActions #js {}}) (def desktop-menu #js {}) (def desktop-config #js {}) +(def react-native-mail (fn [] #js {:mail #js {}})) diff --git a/test/cljs/status_im/test/utils/keychain/core.cljs b/test/cljs/status_im/test/utils/keychain/core.cljs index 8a2386919e..d75aeecf4b 100644 --- a/test/cljs/status_im/test/utils/keychain/core.cljs +++ b/test/cljs/status_im/test/utils/keychain/core.cljs @@ -14,7 +14,7 @@ (deftest key-does-not-exists (async done - (with-redefs [rn/keychain #js {:getGenericPassword (constantly (.resolve js/Promise nil))}] + (with-redefs [rn/keychain (fn [] #js {:getGenericPassword (constantly (.resolve js/Promise nil))})] (testing "it returns a valid key" (.. (keychain/get-encryption-key) (then (fn [k] @@ -27,7 +27,7 @@ (deftest key-does-exists (async done - (with-redefs [rn/keychain #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json (range 64 128))}))}] + (with-redefs [rn/keychain (fn [] #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json (range 64 128))}))})] (testing "it returns a valid key" (.. (keychain/get-encryption-key) (then (fn [k] @@ -40,7 +40,7 @@ (deftest key-is-weak (async done - (with-redefs [rn/keychain #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json weak-key)}))} + (with-redefs [rn/keychain (fn [] #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json weak-key)}))}) keychain/generic-password (atom nil)] (testing "it returns a valid key" (.. (keychain/get-encryption-key) @@ -55,7 +55,7 @@ (deftest safe-key-is-not-valid (async done - (with-redefs [rn/keychain #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json weak-key)}))} + (with-redefs [rn/keychain (fn [] #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password (key->json weak-key)}))}) keychain/generic-password (atom nil)] (testing "it returns a valid key" (.. (keychain/safe-get-encryption-key) @@ -69,7 +69,7 @@ (deftest safe-key-is-nil (async done - (with-redefs [rn/keychain #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password nil}))} + (with-redefs [rn/keychain (fn [] #js {:getGenericPassword (constantly (.resolve js/Promise #js {:password nil}))}) keychain/generic-password (atom nil)] (testing "it returns a valid key" (.. (keychain/safe-get-encryption-key)