Compare commits
112
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66a69e5eaa | ||
|
|
afef011ac8 | ||
|
|
c76346f108 | ||
|
|
e4fb664fa5 | ||
|
|
c54830dd5b | ||
|
|
408f461ee8 | ||
|
|
183a78ae84 | ||
|
|
7529032c06 | ||
|
|
57069027c5 | ||
|
|
a27facbca4 | ||
|
|
fd133576b7 | ||
|
|
dcd06424f8 | ||
|
|
b4b403c5bb | ||
|
|
8fd2c75944 | ||
|
|
4e1efb512c | ||
|
|
efcf8b51a8 | ||
|
|
3d4dd1d59e | ||
|
|
a2d0121c08 | ||
|
|
5ecd471e59 | ||
|
|
a021f0a9bd | ||
|
|
541de5ac5f | ||
|
|
9ad254867e | ||
|
|
34d8c1621d | ||
|
|
124e23ed50 | ||
|
|
8e634aeb24 | ||
|
|
6ef0cfc2ca | ||
|
|
7b7cfe08dc | ||
|
|
598b985c72 | ||
|
|
fba363d9ea | ||
|
|
51541f7f0a | ||
|
|
1e37765197 | ||
|
|
90913500b4 | ||
|
|
6d74d0396e | ||
|
|
fd24a80904 | ||
|
|
ab53450ba8 | ||
|
|
813d96df10 | ||
|
|
6363756c09 | ||
|
|
5854a473f0 | ||
|
|
c2f0060a47 | ||
|
|
0fdb599d93 | ||
|
|
ef5153f138 | ||
|
|
463e8a5eec | ||
|
|
40e6c44b99 | ||
|
|
fc801213ef | ||
|
|
9e5b8b5f9c | ||
|
|
772efa90d4 | ||
|
|
8fb42d2503 | ||
|
|
2295b01bc9 | ||
|
|
2ee7db9370 | ||
|
|
27407b9cbb | ||
|
|
01a881523f | ||
|
|
3b5afb5d60 | ||
|
|
e5cee4b640 | ||
|
|
7948582e46 | ||
|
|
6c5242b3e0 | ||
|
|
60d6a5c3cc | ||
|
|
049822b5bb | ||
|
|
02c7460a24 | ||
|
|
10c6bf7156 | ||
|
|
d0d7310e82 | ||
|
|
219dd7cb46 | ||
|
|
9da0559b15 | ||
|
|
aa7db8b883 | ||
|
|
a06c5fdc02 | ||
|
|
2a515a82ce | ||
|
|
69294b196f | ||
|
|
58606dc87c | ||
|
|
bccf0f8d11 | ||
|
|
aab62dd19e | ||
|
|
fa9645d6dd | ||
|
|
614b03d701 | ||
|
|
e26d3a856d | ||
|
|
98cdf00276 | ||
|
|
eb379791c9 | ||
|
|
6bda54266b | ||
|
|
1a8bca56e0 | ||
|
|
296d868797 | ||
|
|
e002fab376 | ||
|
|
4fa9a27cd9 | ||
|
|
dbcdb18818 | ||
|
|
2009199c25 | ||
|
|
103c4b4653 | ||
|
|
0828e9aa55 | ||
|
|
0efdea6962 | ||
|
|
d4c8e48441 | ||
|
|
2931ae84ee | ||
|
|
637efa24cf | ||
|
|
c57e5cd6db | ||
|
|
604e232bda | ||
|
|
e4997a2088 | ||
|
|
459bf1621a | ||
|
|
ca9346a931 | ||
|
|
7065f4abd2 | ||
|
|
e283a72454 | ||
|
|
3c6923963d | ||
|
|
7a6714eeb2 | ||
|
|
b3bebe1859 | ||
|
|
ad546f9f14 | ||
|
|
3145ecd6bf | ||
|
|
669a232ad9 | ||
|
|
29e69c54bd | ||
|
|
5fd0b27589 | ||
|
|
7d6b2ac87a | ||
|
|
93f488e61a | ||
|
|
f7498ef81f | ||
|
|
f1834c6a15 | ||
|
|
ffcca1aea3 | ||
|
|
0937da9e50 | ||
|
|
33e637ff71 | ||
|
|
a538e2896e | ||
|
|
c02cc5d391 | ||
|
|
613e48ece3 |
@@ -34,4 +34,3 @@ STICKERS_TEST_ENABLED=1
|
||||
LOCAL_PAIRING_ENABLED=1
|
||||
TEST_STATEOFUS=1
|
||||
FAST_CREATE_COMMUNITY_ENABLED=1
|
||||
FLAG_NEW_CONTACT_UI_ENABLED=0
|
||||
|
||||
@@ -22,37 +22,37 @@
|
||||
:multi-lhs-hang]
|
||||
|
||||
:fn-map
|
||||
{"reg-sub" :arg1-pair
|
||||
"h/describe" :arg1-body
|
||||
"h/describe-skip" :arg1-body
|
||||
"h/describe-only" :arg1-body
|
||||
"h/test" :arg1-body
|
||||
"h/test-skip" :arg1-body
|
||||
"h/test-only" :arg1-body
|
||||
"test/async" :arg1-body
|
||||
"test/use-fixtures" :arg1-body
|
||||
"global.describe" :arg1-body
|
||||
"global.test" :arg1-body
|
||||
"list-comp" :binding
|
||||
"defview" :arg1-body
|
||||
"letsubs" :binding
|
||||
"with-let" "let"
|
||||
"reg-event-fx" :arg1-pair
|
||||
"reg-fx" :arg1-pair
|
||||
"testing" :arg1-body
|
||||
"deftest-sub" :arg1-body
|
||||
"h/integration-test" :arg1-body
|
||||
"wait-for" :arg1-body
|
||||
"with-deps-check" :arg1-body
|
||||
"schema/=>" :arg1-body
|
||||
"->" [:noarg1-body
|
||||
{:list {:constant-pair? false :force-nl? false}
|
||||
:next-inner-restore [[:list :constant-pair?]]}]
|
||||
"set!" "reset!"
|
||||
"assoc-when" "assoc"
|
||||
"assoc-some" "assoc"
|
||||
"conj-when" "conj"
|
||||
"conj-some" "conj"}
|
||||
{"reg-sub" :arg1-pair
|
||||
"h/describe" :arg1-body
|
||||
"h/describe-skip" :arg1-body
|
||||
"h/describe-only" :arg1-body
|
||||
"h/test" :arg1-body
|
||||
"h/test-skip" :arg1-body
|
||||
"h/test-only" :arg1-body
|
||||
"test/async" :arg1-body
|
||||
"test/use-fixtures" :arg1-body
|
||||
"global.describe" :arg1-body
|
||||
"global.test" :arg1-body
|
||||
"list-comp" :binding
|
||||
"defview" :arg1-body
|
||||
"letsubs" :binding
|
||||
"with-let" "let"
|
||||
"reg-event-fx" :arg1-pair
|
||||
"reg-fx" :arg1-pair
|
||||
"testing" :arg1-body
|
||||
"deftest-sub" :arg1-body
|
||||
"test-async" :arg1-body
|
||||
"wait-for" :arg1-body
|
||||
"with-deps-check" :arg1-body
|
||||
"schema/=>" :arg1-body
|
||||
"->" [:noarg1-body
|
||||
{:list {:constant-pair? false :force-nl? false}
|
||||
:next-inner-restore [[:list :constant-pair?]]}]
|
||||
"set!" "reset!"
|
||||
"assoc-when" "assoc"
|
||||
"assoc-some" "assoc"
|
||||
"conj-when" "conj"
|
||||
"conj-some" "conj"}
|
||||
|
||||
:style-map
|
||||
{:no-comma {:map {:comma? false}}
|
||||
|
||||
@@ -331,13 +331,14 @@ shadow-server:##@ Start shadow-cljs in server mode for watching
|
||||
|
||||
_test-clojure: export TARGET := clojure
|
||||
_test-clojure: export WATCH ?= false
|
||||
_test-clojure: status-go-library
|
||||
_test-clojure:
|
||||
ifeq ($(WATCH), true)
|
||||
yarn install && \
|
||||
yarn node-pre-gyp rebuild && \
|
||||
yarn shadow-cljs compile mocks && \
|
||||
nodemon --exec "yarn shadow-cljs compile test && node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO" -e cljs
|
||||
else
|
||||
yarn install && \
|
||||
yarn node-pre-gyp rebuild && \
|
||||
yarn shadow-cljs compile mocks && \
|
||||
yarn shadow-cljs compile test && \
|
||||
node --require ./test-resources/override.js "$$SHADOW_OUTPUT_TO"
|
||||
@@ -350,8 +351,9 @@ test: _test-clojure
|
||||
|
||||
test-watch-for-repl: export SHADOW_OUTPUT_TO := target/test/test.js
|
||||
test-watch-for-repl: export SHADOW_NS_REGEXP := .*-test$$
|
||||
test-watch-for-repl: status-go-library
|
||||
test-watch-for-repl: ##@test Watch all Clojure tests and support REPL connections
|
||||
yarn install
|
||||
yarn node-pre-gyp rebuild
|
||||
rm -f target/test/test.js
|
||||
yarn shadow-cljs compile mocks && \
|
||||
concurrently --kill-others --prefix-colors 'auto' --names 'build,repl' \
|
||||
@@ -373,25 +375,25 @@ test-contract: export SHADOW_NS_REGEXP := ^tests\.contract-test.*$$
|
||||
test-contract: ##@test Run contract tests
|
||||
test-contract: _test-clojure
|
||||
|
||||
android-test: jsbundle
|
||||
android-test: export TARGET := android
|
||||
android-test:
|
||||
test-android: jsbundle
|
||||
test-android: export TARGET := android
|
||||
test-android: ##@test Android Gradle test
|
||||
cd android && ./gradlew test
|
||||
|
||||
component-test-watch: export TARGET := clojure
|
||||
component-test-watch: export COMPONENT_TEST := true
|
||||
component-test-watch: export BABEL_ENV := test
|
||||
component-test-watch: export JEST_USE_SILENT_REPORTER := false
|
||||
component-test-watch: ##@ Watch tests and re-run no changes to cljs files
|
||||
test-component-watch: export TARGET := clojure
|
||||
test-component-watch: export COMPONENT_TEST := true
|
||||
test-component-watch: export BABEL_ENV := test
|
||||
test-component-watch: export JEST_USE_SILENT_REPORTER := false
|
||||
test-component-watch: ##@ Watch tests and re-run no changes to cljs files
|
||||
@scripts/check-metro-shadow-process.sh
|
||||
rm -rf ./component-spec
|
||||
nodemon --exec 'yarn shadow-cljs compile component-test && jest --config=test/jest/jest.config.js --testEnvironment node ' -e cljs
|
||||
|
||||
component-test: export TARGET := clojure
|
||||
component-test: export COMPONENT_TEST := true
|
||||
component-test: export BABEL_ENV := test
|
||||
component-test: export JEST_USE_SILENT_REPORTER := false
|
||||
component-test: ##@test Run component tests once in NodeJS
|
||||
test-component: export TARGET := clojure
|
||||
test-component: export COMPONENT_TEST := true
|
||||
test-component: export BABEL_ENV := test
|
||||
test-component: export JEST_USE_SILENT_REPORTER := false
|
||||
test-component: ##@test Run component tests once in NodeJS
|
||||
@scripts/check-metro-shadow-process.sh
|
||||
rm -rf ./component-spec
|
||||
yarn shadow-cljs compile component-test && \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
@@ -34,10 +34,10 @@ pipeline {
|
||||
}
|
||||
|
||||
environment {
|
||||
LANG = "en_US.UTF-8"
|
||||
LC_ALL = "en_US.UTF-8"
|
||||
LANGUAGE = "en_US.UTF-8"
|
||||
TARGET = "android${utils.isE2EBuild() ? "-e2e" : ""}"
|
||||
LANG = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
PLATFORM = "android${utils.isE2EBuild() ? "-e2e" : ""}"
|
||||
BUILD_ENV = 'prod'
|
||||
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
|
||||
FASTLANE_DISABLE_COLORS = 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
triggers {
|
||||
// Nightly at 2am
|
||||
cron 'H 2 * * *'
|
||||
// Nightly at 0am
|
||||
cron 'H 0 * * *'
|
||||
}
|
||||
|
||||
parameters {
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
@@ -34,10 +34,10 @@ pipeline {
|
||||
}
|
||||
|
||||
environment {
|
||||
LANG = "en_US.UTF-8"
|
||||
LC_ALL = "en_US.UTF-8"
|
||||
LANGUAGE = "en_US.UTF-8"
|
||||
TARGET = 'ios'
|
||||
LANG = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
PLATFORM = 'ios'
|
||||
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
|
||||
FASTLANE_DISABLE_COLORS = 1
|
||||
BUNDLE_PATH = "${HOME}/.bundle"
|
||||
|
||||
+34
-41
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
/* Options section can't access functions in objects. */
|
||||
def isPRBuild = utils.isPRBuild()
|
||||
@@ -29,61 +29,47 @@ pipeline {
|
||||
description: 'Specify build type. Values: pr / e2e / nightly / release',
|
||||
defaultValue: 'pr',
|
||||
)
|
||||
booleanParam(
|
||||
name: 'RUN_CONTRACT_TESTS',
|
||||
description: 'Whether to run optional and slow contract tests.',
|
||||
defaultValue: false,
|
||||
)
|
||||
}
|
||||
|
||||
environment {
|
||||
LANG = "en_US.UTF-8"
|
||||
LC_ALL = "en_US.UTF-8"
|
||||
LANGUAGE = "en_US.UTF-8"
|
||||
TARGET = 'tests'
|
||||
LANG = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
PLATFORM = 'tests'
|
||||
BUILD_ENV = 'prod'
|
||||
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
|
||||
LOG_FILE = utils.pkgFilename(ext: 'log', arch: 'tests')
|
||||
CLJ_LINTER_PRINT_WARNINGS = 'true'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checks') {
|
||||
stage('Test') {
|
||||
parallel {
|
||||
stage('Lint') {
|
||||
steps {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make lint CLJ_LINTER_PRINT_WARNINGS=true 2>&1 | tee ${LOG_FILE}
|
||||
"""
|
||||
}
|
||||
steps { make('lint') }
|
||||
}
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make test-unit 2>&1 | tee -a ${LOG_FILE}
|
||||
"""
|
||||
}
|
||||
stage('Unit') {
|
||||
steps { make('test-unit') }
|
||||
}
|
||||
stage('Component') {
|
||||
steps { make('test-component') }
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Contract Tests') {
|
||||
steps {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make test-contract 2>&1 | tee -a ${LOG_FILE}
|
||||
"""
|
||||
}
|
||||
}
|
||||
stage('Integration Tests') {
|
||||
steps {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make test-integration 2>&1 | tee -a ${LOG_FILE}
|
||||
"""
|
||||
}
|
||||
}
|
||||
stage('Component Tests') {
|
||||
steps {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make component-test 2>&1 | tee -a ${LOG_FILE}
|
||||
"""
|
||||
stage('Heavy Test') {
|
||||
parallel {
|
||||
stage('Contract') {
|
||||
when { expression { params.RUN_CONTRACT_TESTS } }
|
||||
steps { make('test-contract') }
|
||||
}
|
||||
stage('Integration') {
|
||||
steps { make('test-integration') }
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Upload') {
|
||||
@@ -100,3 +86,10 @@ pipeline {
|
||||
always { sh 'make purge' }
|
||||
}
|
||||
}
|
||||
|
||||
def make(target) {
|
||||
sh """#!/bin/bash
|
||||
set -eo pipefail
|
||||
make ${target} 2>&1 | tee -a ${LOG_FILE}
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent { label 'macos' }
|
||||
|
||||
environment {
|
||||
LANG = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
TARGET = 'ios'
|
||||
LANG = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
PLATFORM = 'ios'
|
||||
FASTLANE_DISABLE_COLORS = 1
|
||||
/* avoid writing to r/o /nix */
|
||||
GEM_HOME = '~/.rubygems'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent { label params.AGENT_LABEL }
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
||||
environment {
|
||||
LANG = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
TARGET = 'ios'
|
||||
LANG = 'en_US.UTF-8'
|
||||
LANGUAGE = 'en_US.UTF-8'
|
||||
LC_ALL = 'en_US.UTF-8'
|
||||
PLATFORM = 'ios'
|
||||
FASTLANE_DISABLE_COLORS = 1
|
||||
/* avoid writing to r/o /nix */
|
||||
GEM_HOME = '~/.rubygems'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env groovy
|
||||
library 'status-jenkins-lib@v1.8.7'
|
||||
library 'status-jenkins-lib@v1.8.12'
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
|
||||
@@ -16,10 +16,10 @@ Both of these links are showing it for React-Testing-Library (not Native) howeve
|
||||
## Running the tests
|
||||
To run these tests there are two methods.
|
||||
|
||||
`make component-test`
|
||||
`make test-component`
|
||||
setups and runs the test suite once.
|
||||
|
||||
`make component-test-watch`
|
||||
`make test-component-watch`
|
||||
setups and runs the test suite and watches for code changes will then retrigger the test suite.
|
||||
|
||||
## Writing Tests
|
||||
@@ -38,7 +38,7 @@ There is a file of utility functions defined in "src/test_helpers/component.cljs
|
||||
## Configuration
|
||||
Status Mobile has a bespoke tech stack, as such there is more complexities to configuring the tests.
|
||||
|
||||
### Shadow-CLJS
|
||||
### Shadow-CLJS
|
||||
the configuration for compiling our tests are defined in the "shadow-cljs.edn" file.
|
||||
The three main parts of this are
|
||||
`:target :npm-module`
|
||||
@@ -47,9 +47,9 @@ Needed for the configuration we are using
|
||||
a vector of entry points for the test files.
|
||||
and the `ns-regexp` to specify what tests to find. Since we have multiple forms of tests we decided that "component-spec" is the least likely to detect the wrong file type.
|
||||
|
||||
It's worth knowing that our tests are compiled to JS and then run in the temporary folder `component-tests`.
|
||||
It's worth knowing that our tests are compiled to JS and then run in the temporary folder `component-tests`.
|
||||
|
||||
### Jest
|
||||
There is also further configuration for Jest in "test/jest". There is a jest config file which has some mostly standard configuration pieces, where the tests live, what environment variables are set etc. This is documented by Jest here: https://jestjs.io/docs/configuration
|
||||
|
||||
There is also a setup file which is used to set some global and default values. Additionally this file is used to mock some of the react native (among other) dependencies
|
||||
There is also a setup file which is used to set some global and default values. Additionally this file is used to mock some of the react native (among other) dependencies.
|
||||
|
||||
+2
-2
@@ -54,13 +54,13 @@ Here I'm showing a terminal-only experience using Tmux (left pane Emacs, right p
|
||||
To run tests:
|
||||
|
||||
```
|
||||
make component-test
|
||||
make test-component
|
||||
```
|
||||
|
||||
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
|
||||
|
||||
```
|
||||
make component-test-watch
|
||||
make test-component-watch
|
||||
```
|
||||
|
||||
Check [component tests doc](./component-tests-overview.md) for more.
|
||||
|
||||
@@ -1888,6 +1888,36 @@ void _InitLogging(const FunctionCallbackInfo<Value>& args) {
|
||||
delete c;
|
||||
}
|
||||
|
||||
void _RestoreAccountAndLogin(const FunctionCallbackInfo<Value>& args) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
Local<Context> context = isolate->GetCurrentContext();
|
||||
|
||||
if (args.Length() != 1) {
|
||||
// Throw an Error that is passed back to JavaScript
|
||||
isolate->ThrowException(Exception::TypeError(
|
||||
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for RestoreAccountAndLogin")));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the argument types
|
||||
|
||||
if (!args[0]->IsString()) {
|
||||
isolate->ThrowException(Exception::TypeError(
|
||||
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'RestoreAccountAndLogin'")));
|
||||
return;
|
||||
}
|
||||
|
||||
String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
|
||||
char *arg0 = *arg0Obj;
|
||||
|
||||
// Call exported Go function, which returns a C string
|
||||
char *c = RestoreAccountAndLogin(arg0);
|
||||
|
||||
Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
|
||||
args.GetReturnValue().Set(ret);
|
||||
delete c;
|
||||
}
|
||||
|
||||
|
||||
void init(Local<Object> exports) {
|
||||
NODE_SET_METHOD(exports, "multiAccountGenerateAndDeriveAddresses", _MultiAccountGenerateAndDeriveAddresses);
|
||||
@@ -1945,6 +1975,7 @@ void init(Local<Object> exports) {
|
||||
NODE_SET_METHOD(exports, "connectionChange", _ConnectionChange);
|
||||
NODE_SET_METHOD(exports, "pollSignal", _PollSignal);
|
||||
NODE_SET_METHOD(exports, "initLogging", _InitLogging);
|
||||
NODE_SET_METHOD(exports, "restoreAccountAndLogin", _RestoreAccountAndLogin);
|
||||
}
|
||||
|
||||
NODE_MODULE(NODE_GYP_MODULE_NAME, init)
|
||||
|
||||
@@ -53,6 +53,14 @@ copyNodeModules() {
|
||||
|
||||
# Find files that were modified and should cause a re-copying of node modules.
|
||||
# Some files are generated/modified by build processes and should be ignored.
|
||||
#
|
||||
# react-native/ReactCommon/react/renderer/components/rncore/*
|
||||
# generated at runtime by react-native
|
||||
# related code https://github.com/facebook/react-native/blob/v0.72.5/packages/react-native/ReactCommon/React-rncore.podspec#L19
|
||||
#
|
||||
# react-native-config/ios/ReactNativeConfig/GeneratedDotEnv.m
|
||||
# generated at runtime by react-native-config
|
||||
# related code https://github.com/lugg/react-native-config/blob/v1.5.0/react-native-config.podspec#L52
|
||||
findFilesNewerThan() {
|
||||
local sentinel="${1}"
|
||||
local dir="${2}"
|
||||
@@ -61,6 +69,8 @@ findFilesNewerThan() {
|
||||
-not -ipath "*/*android/build/*" -prune \
|
||||
-not -ipath "*/xcuserdata/*" -prune \
|
||||
-not -ipath "*/scripts/.packager.env" \
|
||||
-not -path "*/node_modules/react-native/ReactCommon/react/renderer/components/rncore/*" \
|
||||
-not -path "*/node_modules/react-native-config/ios/ReactNativeConfig/GeneratedDotEnv.m" \
|
||||
-print
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Increment a version string using Semantic Versioning (SemVer) terminology.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { withTiming, runOnJS } from 'react-native-reanimated';
|
||||
import { useAnimatedReaction, withTiming, runOnJS } from 'react-native-reanimated';
|
||||
import { useState } from 'react';
|
||||
|
||||
export function messagesListOnScroll(distanceFromListTop, chatListScrollY, callback) {
|
||||
return function (event) {
|
||||
@@ -12,3 +13,21 @@ export function messagesListOnScroll(distanceFromListTop, chatListScrollY, callb
|
||||
runOnJS(callback)(layoutHeight, newDistance);
|
||||
};
|
||||
}
|
||||
|
||||
export function useMessagesScrolledToThreshold(distanceFromListTop, threshold) {
|
||||
const [scrolledToThreshold, setScrolledToThreshold] = useState(false);
|
||||
|
||||
useAnimatedReaction(
|
||||
function () {
|
||||
return distanceFromListTop.value <= threshold;
|
||||
},
|
||||
function (current) {
|
||||
if (current !== scrolledToThreshold) {
|
||||
runOnJS(setScrolledToThreshold)(current);
|
||||
}
|
||||
},
|
||||
[scrolledToThreshold],
|
||||
);
|
||||
|
||||
return scrolledToThreshold;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@ export function navigationHeaderPosition(distanceFromListTop, isAllLoaded, topBa
|
||||
});
|
||||
}
|
||||
|
||||
export function navigationButtonsCompleteOpacity(isCalculationComplete) {
|
||||
return useDerivedValue(function () {
|
||||
'worklet';
|
||||
return isCalculationComplete.value ? withTiming(1) : 0;
|
||||
});
|
||||
}
|
||||
|
||||
export function interpolateNavigationViewOpacity(props) {
|
||||
return useDerivedValue(function () {
|
||||
'worklet';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
["eth-phishing-detect" :as eth-phishing-detect]
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.bottom-sheet.events :as bottom-sheet]
|
||||
[legacy.status-im.browser.eip3085 :as eip3085]
|
||||
[legacy.status-im.browser.eip3326 :as eip3326]
|
||||
[legacy.status-im.browser.permissions :as browser.permissions]
|
||||
[legacy.status-im.browser.webview-ref :as webview-ref]
|
||||
@@ -16,6 +15,7 @@
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.universal-links :as links]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
@@ -443,9 +443,6 @@
|
||||
(= method "wallet_switchEthereumChain")
|
||||
(eip3326/handle-switch-ethereum-chain cofx dapp-name id message-id (first params))
|
||||
|
||||
(= method "wallet_addEthereumChain")
|
||||
(eip3085/handle-add-ethereum-chain cofx dapp-name id message-id (first params))
|
||||
|
||||
:else
|
||||
{:browser/call-rpc [payload
|
||||
#(re-frame/dispatch [:browser.callback/call-rpc
|
||||
@@ -658,12 +655,11 @@
|
||||
stored-bookmarks)]
|
||||
{:db (assoc db :bookmarks/bookmarks bookmarks)}))
|
||||
|
||||
(rf/defn initialize-browser
|
||||
[_]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_getBrowsers"
|
||||
:on-success #(re-frame/dispatch [::initialize-browsers %])}
|
||||
{:method "browsers_getBookmarks"
|
||||
:on-success #(re-frame/dispatch [::initialize-bookmarks %])}
|
||||
{:method "permissions_getDappPermissions"
|
||||
:on-success #(re-frame/dispatch [::initialize-dapp-permissions %])}]})
|
||||
(re-frame/reg-fx :browser/initialize-browser
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_getBrowsers"
|
||||
:on-success [::initialize-browsers]})
|
||||
(json-rpc/call {:method "browsers_getBookmarks"
|
||||
:on-success [::initialize-bookmarks]})
|
||||
(json-rpc/call {:method "permissions_getDappPermissions"
|
||||
:on-success [::initialize-dapp-permissions]})))
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
;(`wallet_addEthereumChain`)
|
||||
(ns legacy.status-im.browser.eip3085
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.network.core :as network]
|
||||
[legacy.status-im.ui.screens.browser.eip3085.sheet :as sheet]
|
||||
[legacy.status-im.utils.random :as random]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
@@ -40,37 +36,3 @@
|
||||
:message "User rejected the request."}}
|
||||
:dispatch [:bottom-sheet/hide-old]})
|
||||
|
||||
(rf/defn handle-add-ethereum-chain
|
||||
{:events [:eip3085/handle-add-ethereum-chain]}
|
||||
[{{:networks/keys [networks] :as db} :db :as cofx}
|
||||
dapp-name id message-id
|
||||
{:keys [chainId blockExplorerUrls chainName iconUrls nativeCurrency rpcUrls] :as params}]
|
||||
(let [manage {:name {:value chainName}
|
||||
:symbol {:value (:symbol nativeCurrency)}
|
||||
:url {:value (first rpcUrls)}
|
||||
:network-id {:value chainId}
|
||||
:chain {:value :custom}}]
|
||||
(if (network/valid-manage? manage)
|
||||
(let [{:keys [name url chain network-id symbol]} manage
|
||||
random-id (string/replace (random/id) "-" "")
|
||||
network (network/new-network random-id
|
||||
(:value name)
|
||||
(:value symbol)
|
||||
(:value url)
|
||||
(:value chain)
|
||||
(:value network-id))
|
||||
new-networks (assoc networks random-id network)
|
||||
params (assoc params
|
||||
:new-networks new-networks
|
||||
:id id
|
||||
:new-network network)]
|
||||
(if (network/chain-id-available? networks network)
|
||||
{:dispatch [:bottom-sheet/show-sheet-old
|
||||
{:content (fn []
|
||||
[sheet/permissions-panel dapp-name message-id params])}]}
|
||||
(send-success-call-to-bridge cofx id message-id)))
|
||||
{:browser/send-to-bridge {:type constants/web3-send-async-callback
|
||||
:messageId message-id
|
||||
:error {:code -32602
|
||||
:message "invalid network parameters"}}})))
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
[legacy.status-im.chat.models.loading :as chat.loading]
|
||||
[legacy.status-im.data-store.messages :as data-store.messages]
|
||||
[legacy.status-im.utils.deprecated-types :as types]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.contexts.chat.messenger.messages.delete-message.events :as delete-message]
|
||||
[status-im.contexts.chat.messenger.messages.list.events :as message-list]
|
||||
@@ -135,9 +134,7 @@
|
||||
message-id (:messageId removed-message)]
|
||||
(data-store.messages/mark-messages-seen chat-id
|
||||
[message-id]
|
||||
#(re-frame/dispatch
|
||||
[:chat/decrease-unviewed-count
|
||||
chat-id %3]))))
|
||||
nil)))
|
||||
removed-messages)
|
||||
remove-messages-fx (fn [{:keys [db]}]
|
||||
{:dispatch [:activity-center.notifications/fetch-unread-count]})]
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
[legacy.status-im.bottom-sheet.events :as bottom-sheet]
|
||||
legacy.status-im.communities.e2e
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -84,13 +83,12 @@
|
||||
(navigation/navigate-back)
|
||||
(handle-response response-js)))
|
||||
|
||||
(rf/defn member-banned
|
||||
{:events [::member-banned]}
|
||||
[cofx response-js]
|
||||
(rf/merge cofx
|
||||
(bottom-sheet/hide-bottom-sheet-old)
|
||||
(handle-response response-js)
|
||||
(activity-center/notifications-fetch-unread-count)))
|
||||
(re-frame/reg-event-fx ::member-banned
|
||||
(fn [{:keys [db]} [response-js]]
|
||||
{:db (assoc db :bottom-sheet/show? false)
|
||||
:fx [[:dismiss-bottom-sheet-overlay-old]
|
||||
[:sanitize-messages-and-process-response response-js]
|
||||
[:activity-center.notifications/fetch-unread-count]]}))
|
||||
|
||||
(rf/defn member-ban
|
||||
{:events [::member-ban]}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.contexts.chat.contacts.events :as contacts-store]
|
||||
[status-im.contexts.chat.messenger.messages.list.events :as message-list]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
@@ -45,21 +44,23 @@
|
||||
(apply
|
||||
rf/merge
|
||||
cofx
|
||||
{:db (->
|
||||
db
|
||||
(update :chats dissoc public-key)
|
||||
(update :chats-home-list disj public-key)
|
||||
(assoc-in [:contacts/contacts public-key
|
||||
:added?]
|
||||
false))
|
||||
:dispatch [:shell/close-switcher-card public-key]
|
||||
:effects/push-notifications-clear-message-notifications [public-key]}
|
||||
(activity-center/notifications-fetch-unread-count)
|
||||
{:db (->
|
||||
db
|
||||
(update :chats dissoc public-key)
|
||||
(update :chats-home-list disj public-key)
|
||||
(assoc-in [:contacts/contacts public-key
|
||||
:added?]
|
||||
false))
|
||||
:fx [[:activity-center.notifications/fetch-unread-count]
|
||||
[:effects/push-notifications-clear-message-notifications [public-key]]
|
||||
[:dispatch [:shell/close-switcher-card public-key]]]}
|
||||
fxs)))
|
||||
|
||||
(rf/defn block-contact
|
||||
{:events [:contact.ui/block-contact-confirmed]}
|
||||
[{:keys [db] :as cofx} public-key]
|
||||
[{:keys [db] :as cofx} public-key
|
||||
{:keys [handle-navigation?]
|
||||
:or {handle-navigation? true}}]
|
||||
(let [contact (-> (contact.db/public-key->contact
|
||||
(:contacts/contacts db)
|
||||
public-key)
|
||||
@@ -76,9 +77,10 @@
|
||||
(re-frame/dispatch [:sanitize-messages-and-process-response block-contact])
|
||||
(re-frame/dispatch [:hide-popover])))
|
||||
;; reset navigation to avoid going back to non existing one to one chat
|
||||
(if from-one-to-one-chat?
|
||||
(navigation/pop-to-root :shell-stack)
|
||||
(navigation/navigate-back)))))
|
||||
(when handle-navigation?
|
||||
(if from-one-to-one-chat?
|
||||
(navigation/pop-to-root :shell-stack)
|
||||
(navigation/navigate-back))))))
|
||||
|
||||
(rf/defn contact-unblocked
|
||||
{:events [:contacts/unblocked]}
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
(query-fn (comp participant-set :public-key) (vals all-contacts))))
|
||||
|
||||
(defn get-all-contacts-in-group-chat
|
||||
[members admins contacts {:keys [public-key preferred-name name] :as current-account}]
|
||||
[members admins contacts {:keys [public-key preferred-name name display-name] :as current-account}]
|
||||
(let [current-contact (some->
|
||||
current-account
|
||||
(select-keys [:name :preferred-name :public-key :images])
|
||||
(select-keys [:name :preferred-name :public-key :images :compressed-key])
|
||||
(set/rename-keys {:name :alias :preferred-name :name})
|
||||
(assoc :primary-name (or preferred-name name)))
|
||||
(assoc :primary-name (or display-name preferred-name name)))
|
||||
all-contacts (cond-> contacts
|
||||
current-contact
|
||||
(assoc public-key current-contact))]
|
||||
|
||||
@@ -29,37 +29,41 @@
|
||||
|
||||
(testing "transforms messages from RPC response"
|
||||
(is
|
||||
(= {:last-message {:quoted-message nil
|
||||
:outgoing-status nil
|
||||
:command-parameters nil
|
||||
:link-previews []
|
||||
:content {:sticker nil
|
||||
:rtl? nil
|
||||
:ens-name nil
|
||||
:parsed-text nil
|
||||
:response-to nil
|
||||
:chat-id nil
|
||||
:image nil
|
||||
:line-count nil
|
||||
:links nil
|
||||
:text nil}
|
||||
:outgoing false}
|
||||
(= {:last-message {:quoted-message nil
|
||||
:outgoing-status nil
|
||||
:command-parameters nil
|
||||
:link-previews []
|
||||
:status-link-previews []
|
||||
:content {:sticker nil
|
||||
:rtl? nil
|
||||
:ens-name nil
|
||||
:parsed-text nil
|
||||
:response-to nil
|
||||
:chat-id nil
|
||||
:image nil
|
||||
:line-count nil
|
||||
:links nil
|
||||
:text nil}
|
||||
:bridge-message nil
|
||||
:outgoing false}
|
||||
:message nil
|
||||
:reply-message {:quoted-message nil
|
||||
:outgoing-status nil
|
||||
:command-parameters nil
|
||||
:link-previews []
|
||||
:content {:sticker nil
|
||||
:rtl? nil
|
||||
:ens-name nil
|
||||
:parsed-text nil
|
||||
:response-to nil
|
||||
:chat-id nil
|
||||
:image nil
|
||||
:line-count nil
|
||||
:links nil
|
||||
:text nil}
|
||||
:outgoing false}}
|
||||
:reply-message {:quoted-message nil
|
||||
:outgoing-status nil
|
||||
:command-parameters nil
|
||||
:link-previews []
|
||||
:status-link-previews []
|
||||
:content {:sticker nil
|
||||
:rtl? nil
|
||||
:ens-name nil
|
||||
:parsed-text nil
|
||||
:response-to nil
|
||||
:chat-id nil
|
||||
:image nil
|
||||
:line-count nil
|
||||
:links nil
|
||||
:text nil}
|
||||
:bridge-message nil
|
||||
:outgoing false}}
|
||||
(-> raw-notification
|
||||
store/<-rpc
|
||||
(select-keys [:last-message :message :reply-message])))))
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
(ns legacy.status-im.data-store.chats
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.data-store.messages :as messages]
|
||||
[legacy.status-im.utils.deprecated-types :as types]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn rpc->type
|
||||
[{:keys [chat-type name] :as chat}]
|
||||
@@ -58,69 +60,80 @@
|
||||
:admins #{}
|
||||
:members-joined #{})))
|
||||
|
||||
(defn <-color
|
||||
[value]
|
||||
(if (and (some? value)
|
||||
(string/starts-with? value "#"))
|
||||
value
|
||||
(keyword value)))
|
||||
|
||||
(defn <-rpc
|
||||
[chat]
|
||||
(-> chat
|
||||
(set/rename-keys {:id :chat-id
|
||||
:communityId :community-id
|
||||
:syncedFrom :synced-from
|
||||
:syncedTo :synced-to
|
||||
:membershipUpdateEvents :membership-update-events
|
||||
:deletedAtClockValue :deleted-at-clock-value
|
||||
:chatType :chat-type
|
||||
:unviewedMessagesCount :unviewed-messages-count
|
||||
:unviewedMentionsCount :unviewed-mentions-count
|
||||
:lastMessage :last-message
|
||||
:lastClockValue :last-clock-value
|
||||
:invitationAdmin :invitation-admin
|
||||
:profile :profile-public-key
|
||||
:muteTill :muted-till})
|
||||
(set/rename-keys {:id :chat-id
|
||||
:communityId :community-id
|
||||
:syncedFrom :synced-from
|
||||
:syncedTo :synced-to
|
||||
:membershipUpdateEvents :membership-update-events
|
||||
:deletedAtClockValue :deleted-at-clock-value
|
||||
:chatType :chat-type
|
||||
:unviewedMessagesCount :unviewed-messages-count
|
||||
:unviewedMentionsCount :unviewed-mentions-count
|
||||
:lastMessage :last-message
|
||||
:lastClockValue :last-clock-value
|
||||
:invitationAdmin :invitation-admin
|
||||
:profile :profile-public-key
|
||||
:muteTill :muted-till
|
||||
:hideIfPermissionsNotMet :hide-if-permissions-not-met?})
|
||||
rpc->type
|
||||
unmarshal-members
|
||||
(update :last-message #(when % (messages/<-rpc %)))
|
||||
(update :color <-color)
|
||||
(dissoc :members)))
|
||||
|
||||
(defn <-rpc-js
|
||||
[^js chat]
|
||||
(-> {:name (.-name chat)
|
||||
:description (.-description chat)
|
||||
:color (.-color chat)
|
||||
:emoji (.-emoji chat)
|
||||
:timestamp (.-timestamp chat)
|
||||
:alias (.-alias chat)
|
||||
:muted (.-muted chat)
|
||||
:joined (.-joined chat)
|
||||
:muted-till (.-muteTill chat)
|
||||
:chat-id (.-id chat)
|
||||
:community-id (.-communityId chat)
|
||||
:synced-from (.-syncedFrom chat)
|
||||
:synced-to (.-syncedTo chat)
|
||||
:deleted-at-clock-value (.-deletedAtClockValue chat)
|
||||
:chat-type (.-chatType chat)
|
||||
:unviewed-messages-count (.-unviewedMessagesCount chat)
|
||||
:unviewed-mentions-count (.-unviewedMentionsCount chat)
|
||||
:last-message {:content {:text (.-text chat)
|
||||
:parsed-text (types/js->clj (.-parsedText chat))
|
||||
:response-to (.-responseTo chat)}
|
||||
:content-type (.-contentType chat)
|
||||
:community-id (.-contentCommunityId chat)
|
||||
:outgoing (boolean (.-outgoingStatus chat))
|
||||
:album-images-count (.-albumImagesCount chat)
|
||||
:from (.-from chat)
|
||||
:deleted? (.-deleted chat)
|
||||
:deleted-for-me? (.-deletedForMe chat)}
|
||||
:last-clock-value (.-lastClockValue chat)
|
||||
:profile-public-key (.-profile chat)
|
||||
:highlight (.-highlight chat)
|
||||
:active (.-active chat)
|
||||
:members (types/js->clj (.-members chat))}
|
||||
(-> {:name (.-name chat)
|
||||
:description (.-description chat)
|
||||
:color (<-color (.-color chat))
|
||||
:emoji (.-emoji chat)
|
||||
:timestamp (.-timestamp chat)
|
||||
:alias (.-alias chat)
|
||||
:muted (.-muted chat)
|
||||
:joined (.-joined chat)
|
||||
:muted-till (.-muteTill chat)
|
||||
:chat-id (.-id chat)
|
||||
:community-id (.-communityId chat)
|
||||
:synced-from (.-syncedFrom chat)
|
||||
:synced-to (.-syncedTo chat)
|
||||
:deleted-at-clock-value (.-deletedAtClockValue chat)
|
||||
:chat-type (.-chatType chat)
|
||||
:unviewed-messages-count (.-unviewedMessagesCount chat)
|
||||
:unviewed-mentions-count (.-unviewedMentionsCount chat)
|
||||
:last-message {:content {:text (.-text chat)
|
||||
:parsed-text (types/js->clj (.-parsedText
|
||||
chat))
|
||||
:response-to (.-responseTo chat)}
|
||||
:content-type (.-contentType chat)
|
||||
:community-id (.-contentCommunityId chat)
|
||||
:outgoing (boolean (.-outgoingStatus chat))
|
||||
:album-images-count (.-albumImagesCount chat)
|
||||
:from (.-from chat)
|
||||
:deleted? (.-deleted chat)
|
||||
:deleted-for-me? (.-deletedForMe chat)}
|
||||
:last-clock-value (.-lastClockValue chat)
|
||||
:profile-public-key (.-profile chat)
|
||||
:highlight (.-highlight chat)
|
||||
:active (.-active chat)
|
||||
:members (types/js->clj (.-members chat))
|
||||
:hide-if-permissions-not-met (.-hideIfPermissionsNotMet chat)}
|
||||
rpc->type
|
||||
unmarshal-members))
|
||||
|
||||
(rf/defn fetch-chats-preview
|
||||
[_ {:keys [on-success]}]
|
||||
{:json-rpc/call [{:method "wakuext_chatsPreview"
|
||||
:params []
|
||||
:js-response true
|
||||
:on-success #(on-success ^js %)
|
||||
:on-error #(log/error "failed to fetch chats" 0 -1 %)}]})
|
||||
(re-frame/reg-fx :fetch-chats-preview
|
||||
(fn [{:keys [on-success]}]
|
||||
(json-rpc/call {:method "wakuext_chatsPreview"
|
||||
:params []
|
||||
:js-response true
|
||||
:on-success #(on-success ^js %)
|
||||
:on-error #(log/error "failed to fetch chats" 0 -1 %)})))
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
(deftest normalize-chat-test
|
||||
(let [chat {:id "chat-id"
|
||||
:color "color"
|
||||
:color "yellow"
|
||||
:name "name"
|
||||
:chatType 3
|
||||
:members [{:id "a"
|
||||
@@ -26,7 +26,7 @@
|
||||
:timestamp 2}
|
||||
expected-chat {:public? false
|
||||
:group-chat true
|
||||
:color "color"
|
||||
:color :yellow
|
||||
:chat-name "name"
|
||||
:contacts #{"a" "b" "c" "d"}
|
||||
:chat-type 3
|
||||
|
||||
@@ -4,13 +4,6 @@
|
||||
[clojure.walk :as walk]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(defn rpc->channel-permissions
|
||||
[rpc-channels-permissions]
|
||||
(update-vals rpc-channels-permissions
|
||||
(fn [{:keys [viewAndPostPermissions viewOnlyPermissions]}]
|
||||
{:view-only (set/rename-keys viewOnlyPermissions {:satisfied :satisfied?})
|
||||
:view-and-post (set/rename-keys viewAndPostPermissions {:satisfied :satisfied?})})))
|
||||
|
||||
(defn <-revealed-accounts-rpc
|
||||
[accounts]
|
||||
(mapv
|
||||
@@ -34,8 +27,11 @@
|
||||
(assoc acc
|
||||
(name k)
|
||||
(-> v
|
||||
(assoc :can-post? (:canPost v))
|
||||
(dissoc :canPost)
|
||||
(assoc :token-gated? (:tokenGated v)
|
||||
:can-post? (:canPost v)
|
||||
:can-view? (:canView v)
|
||||
:hide-if-permissions-not-met? (:hideIfPermissionsNotMet v))
|
||||
(dissoc :canPost :tokenGated :canView :hideIfPermissionsNotMet)
|
||||
(update :members walk/stringify-keys))))
|
||||
{}
|
||||
chats))
|
||||
@@ -68,6 +64,7 @@
|
||||
:canJoin :can-join?
|
||||
:requestedToJoinAt :requested-to-join-at
|
||||
:isMember :is-member?
|
||||
:outroMessage :outro-message
|
||||
:adminSettings :admin-settings
|
||||
:tokenPermissions :token-permissions
|
||||
:communityTokensMetadata :tokens-metadata
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
(ns legacy.status-im.data-store.communities-test
|
||||
(:require
|
||||
[cljs.test :refer [deftest is]]
|
||||
[legacy.status-im.data-store.communities :as sut]))
|
||||
|
||||
(def permissions
|
||||
{"community-id-chat-1"
|
||||
{:viewOnlyPermissions {:satisfied false
|
||||
:permissions {:token-permission-id-01 {:criteria [false]}}}
|
||||
:viewAndPostPermissions {:satisfied true :permissions {}}}
|
||||
"community-id-chat-2"
|
||||
{:viewOnlyPermissions {:satisfied true :permissions {}}
|
||||
:viewAndPostPermissions {:satisfied true :permissions {}}}})
|
||||
|
||||
(deftest rpc->channel-permissions-test
|
||||
(is (= {"community-id-chat-1"
|
||||
{:view-only {:satisfied? false
|
||||
:permissions {:token-permission-id-01 {:criteria [false]}}}
|
||||
:view-and-post {:satisfied? true :permissions {}}}
|
||||
"community-id-chat-2"
|
||||
{:view-only {:satisfied? true :permissions {}}
|
||||
:view-and-post {:satisfied? true :permissions {}}}}
|
||||
(sut/rpc->channel-permissions permissions))))
|
||||
@@ -16,13 +16,41 @@
|
||||
:community-id :communityId
|
||||
:clock-value :clock})))
|
||||
|
||||
(defn- <-status-link-previews-rpc
|
||||
[preview]
|
||||
(-> preview
|
||||
(update :community
|
||||
set/rename-keys
|
||||
{:communityId :community-id
|
||||
:displayName :display-name
|
||||
:membersCount :members-count
|
||||
:activeMembersCount :active-members-count})
|
||||
(update-in [:community :banner] set/rename-keys {:dataUri :data-uri})
|
||||
(update-in [:community :icon] set/rename-keys {:dataUri :data-uri})))
|
||||
|
||||
(defn ->status-link-previews-rpc
|
||||
[preview]
|
||||
(-> preview
|
||||
(update :community
|
||||
set/rename-keys
|
||||
{:community-id :communityId
|
||||
:display-name :displayName
|
||||
:members-count :membersCount
|
||||
:active-members-count :activeMembersCount})
|
||||
(update-in [:community :banner] set/rename-keys {:data-uri :dataUri})
|
||||
(update-in [:community :icon] set/rename-keys {:data-uri :dataUri})))
|
||||
|
||||
(defn- <-link-preview-rpc
|
||||
[preview]
|
||||
(update preview :thumbnail set/rename-keys {:dataUri :data-uri}))
|
||||
(-> preview
|
||||
(update :thumbnail set/rename-keys {:dataUri :data-uri})
|
||||
(update :favicon set/rename-keys {:dataUri :data-uri})))
|
||||
|
||||
(defn ->link-preview-rpc
|
||||
[preview]
|
||||
(update preview :thumbnail set/rename-keys {:data-uri :dataUri}))
|
||||
(-> preview
|
||||
(update :thumbnail set/rename-keys {:data-uri :dataUri})
|
||||
(update :favicon set/rename-keys {:data-uri :dataUri})))
|
||||
|
||||
(defn <-rpc
|
||||
[message]
|
||||
@@ -53,8 +81,16 @@
|
||||
:new :new?
|
||||
:albumImagesCount :album-images-count
|
||||
:displayName :display-name
|
||||
:linkPreviews :link-previews})
|
||||
:linkPreviews :link-previews
|
||||
:statusLinkPreviews :status-link-previews
|
||||
:bridgeMessage :bridge-message})
|
||||
(update :bridge-message
|
||||
set/rename-keys
|
||||
{:bridgeName :bridge-name
|
||||
:userName :user-name
|
||||
:userAvatar :user-avatar})
|
||||
(update :link-previews #(map <-link-preview-rpc %))
|
||||
(update :status-link-previews #(map <-status-link-previews-rpc %))
|
||||
(update :quoted-message
|
||||
set/rename-keys
|
||||
{:parsedText :parsed-text
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
:image nil
|
||||
:response-to "a"
|
||||
:links nil}
|
||||
:bridge-message nil
|
||||
:whisper-timestamp 1
|
||||
:contact-verification-state 1
|
||||
:contact-request-state 2
|
||||
@@ -37,7 +38,19 @@
|
||||
:compressed-key "c"
|
||||
:timestamp 3
|
||||
:link-previews [{:thumbnail {:url "http://localhost"
|
||||
:data-uri "data:image/png"}}]}
|
||||
:data-uri "data:image/png"}
|
||||
:favicon nil}]
|
||||
:status-link-previews [{:url "http://localhost"
|
||||
:community {:community-id "0x01"
|
||||
:display-name "Test Comm"
|
||||
:members-count 12
|
||||
:active-members-count 12
|
||||
:banner
|
||||
{:data-uri
|
||||
"data:image/png"}
|
||||
:icon
|
||||
{:data-uri
|
||||
"data:image/png"}}}]}
|
||||
message {:id message-id
|
||||
:whisperTimestamp 1
|
||||
:parsedText "parsed-text"
|
||||
@@ -61,5 +74,17 @@
|
||||
:timestamp 3
|
||||
:outgoingStatus "sending"
|
||||
:linkPreviews [{:thumbnail {:url "http://localhost"
|
||||
:dataUri "data:image/png"}}]}]
|
||||
:dataUri "data:image/png"}
|
||||
:favicon nil}]
|
||||
:statusLinkPreviews [{:url "http://localhost"
|
||||
:community {:communityId "0x01"
|
||||
:displayName "Test Comm"
|
||||
:membersCount 12
|
||||
:activeMembersCount 12
|
||||
:banner
|
||||
{:dataUri
|
||||
"data:image/png"}
|
||||
:icon
|
||||
{:dataUri
|
||||
"data:image/png"}}}]}]
|
||||
(is (= expected (m/<-rpc message))))))
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[clojure.walk :as walk]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
@@ -32,11 +34,11 @@
|
||||
:on-success #()
|
||||
:on-error #()}]})
|
||||
|
||||
(rf/defn fetch-switcher-cards-rpc
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_switcherCards"
|
||||
:params []
|
||||
:on-success #(rf/dispatch
|
||||
[:shell/switcher-cards-loaded
|
||||
(:switcherCards ^js %)])
|
||||
:on-error #(log/error "Failed to fetch switcher cards" %)}]})
|
||||
(re-frame/reg-fx :switcher-cards/fetch
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_switcherCards"
|
||||
:params []
|
||||
:on-success #(rf/dispatch
|
||||
[:shell/switcher-cards-loaded
|
||||
(:switcherCards ^js %)])
|
||||
:on-error #(log/error "Failed to fetch switcher cards" %)})))
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
(:require
|
||||
[clojure.set :as set]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn <-rpc
|
||||
[visibility-status-update]
|
||||
@@ -18,13 +18,13 @@
|
||||
{:current-user-status :current-user-visibility-status})
|
||||
(update :current-user-visibility-status <-rpc)))
|
||||
|
||||
(rf/defn fetch-visibility-status-updates-rpc
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_statusUpdates"
|
||||
:params []
|
||||
:on-success #(re-frame/dispatch
|
||||
[:visibility-status-updates/visibility-status-updates-loaded
|
||||
(:statusUpdates ^js %)])
|
||||
:on-error #(log/error
|
||||
"failed to fetch visibility-status-updates"
|
||||
%)}]})
|
||||
(re-frame/reg-fx :visibility-status-updates/fetch
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_statusUpdates"
|
||||
:params []
|
||||
:on-success #(re-frame/dispatch
|
||||
[:visibility-status-updates/visibility-status-updates-loaded
|
||||
(:statusUpdates ^js %)])
|
||||
:on-error #(log/error
|
||||
"failed to fetch visibility-status-updates"
|
||||
%)})))
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
|
||||
(rf/defn tx-history-end-reached
|
||||
[{:keys [db] :as cofx} address]
|
||||
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? cofx)]
|
||||
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? db)]
|
||||
{:db (assoc-in db
|
||||
[:wallet-legacy :fetching address :all-fetched?]
|
||||
(if syncing-allowed?
|
||||
@@ -327,7 +327,7 @@
|
||||
{:chain-tokens (:wallet-legacy/all-tokens db)
|
||||
:addresses [address]
|
||||
:before-block min-known-block
|
||||
:fetch-more? (utils.mobile-sync/syncing-allowed? cofx)
|
||||
:fetch-more? (utils.mobile-sync/syncing-allowed? db)
|
||||
;; Transfers are requested before and including `min-known-block` because there is no
|
||||
;; guarantee that all transfers from that block are shown already. To make sure that we fetch
|
||||
;; the whole `default-transfers-limit` of transfers the number of transfers already received
|
||||
|
||||
@@ -8,11 +8,16 @@
|
||||
legacy.status-im.chat.models.loading
|
||||
legacy.status-im.contact.block
|
||||
legacy.status-im.currency.core
|
||||
legacy.status-im.data-store.chats
|
||||
legacy.status-im.data-store.switcher-cards
|
||||
legacy.status-im.data-store.visibility-status-updates
|
||||
legacy.status-im.fleet.core
|
||||
legacy.status-im.group-chats.core
|
||||
[legacy.status-im.keycard.core :as keycard]
|
||||
legacy.status-im.log-level.core
|
||||
legacy.status-im.mailserver.constants
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
legacy.status-im.mobile-sync-settings.core
|
||||
legacy.status-im.multiaccounts.login.core
|
||||
legacy.status-im.multiaccounts.logout.core
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
@@ -37,7 +42,6 @@
|
||||
[react-native.core :as rn]
|
||||
[react-native.permissions :as permissions]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.biometric.events :as biometric]
|
||||
status-im.common.serialization
|
||||
status-im.common.standard-authentication.events
|
||||
[status-im.common.theme.core :as theme]
|
||||
@@ -120,7 +124,7 @@
|
||||
:content (i18n/label :t/biometric-auth-confirm-message)
|
||||
:confirm-button-text (i18n/label :t/biometric-auth-confirm-try-again)
|
||||
:cancel-button-text (i18n/label :t/biometric-auth-confirm-logout)
|
||||
:on-accept #(biometric/authenticate nil {:on-fail on-biometric-auth-fail})
|
||||
:on-accept #(rf/dispatch [:biometric/authenticate {:on-fail on-biometric-auth-fail}])
|
||||
:on-cancel #(re-frame/dispatch [:multiaccounts.logout.ui/logout-confirmed])})))
|
||||
|
||||
(rf/defn on-return-from-background
|
||||
@@ -142,7 +146,7 @@
|
||||
#(when-let [chat-id (:current-chat-id db)]
|
||||
{:dispatch [:chat/mark-all-as-read chat-id]})
|
||||
#(when requires-bio-auth
|
||||
(biometric/authenticate % {:on-fail on-biometric-auth-fail})))))
|
||||
{:dispatch [:biometric/authenticate {:on-fail on-biometric-auth-fail}]}))))
|
||||
|
||||
(rf/defn on-going-in-background
|
||||
[{:keys [db now]}]
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
[legacy.status-im.data-store.invitations :as data-store.invitations]
|
||||
[oops.core :as oops]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -19,15 +19,13 @@
|
||||
(when (get-in cofx [:db :chats chat-id])
|
||||
(chat.events/pop-to-root-and-navigate-to-chat cofx chat-id nil)))
|
||||
|
||||
(rf/defn handle-chat-removed
|
||||
{:events [:chat-removed]}
|
||||
[cofx response chat-id]
|
||||
(rf/merge cofx
|
||||
{:db (dissoc (:db cofx) :current-chat-id)
|
||||
:dispatch-n [[:shell/close-switcher-card chat-id]
|
||||
[:sanitize-messages-and-process-response response]
|
||||
[:pop-to-root :shell-stack]]}
|
||||
(activity-center/notifications-fetch-unread-count)))
|
||||
(re-frame/reg-event-fx :chat-removed
|
||||
(fn [{:keys [db]} [response chat-id]]
|
||||
{:db (dissoc db :current-chat-id)
|
||||
:fx [[:dispatch [:shell/close-switcher-card chat-id]]
|
||||
[:dispatch [:sanitize-messages-and-process-response response]]
|
||||
[:dispatch [:pop-to-root :shell-stack]]
|
||||
[:activity-center.notifications/fetch-unread-count]]}))
|
||||
|
||||
(rf/defn handle-chat-update
|
||||
{:events [:chat-updated]}
|
||||
@@ -66,16 +64,6 @@
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:chat-updated %])}]})
|
||||
|
||||
(rf/defn create
|
||||
{:events [:group-chats.ui/create-pressed]
|
||||
:interceptors [(re-frame/inject-cofx :random-guid-generator)]}
|
||||
[{:keys [db] :as cofx} group-name]
|
||||
(let [selected-contacts (:group/selected-contacts db)]
|
||||
{:json-rpc/call [{:method "wakuext_createGroupChatWithMembers"
|
||||
:params [nil group-name (into [] selected-contacts)]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [:chat-updated %])}]}))
|
||||
|
||||
(rf/defn create-from-link
|
||||
{:events [:group-chats/create-from-link]}
|
||||
[cofx {:keys [chat-id invitation-admin chat-name]}]
|
||||
@@ -264,8 +252,7 @@
|
||||
{}
|
||||
invitations))})
|
||||
|
||||
(rf/defn get-group-chat-invitations
|
||||
[_]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_getGroupChatInvitations"
|
||||
:on-success #(re-frame/dispatch [::initialize-invitations %])}]})
|
||||
(re-frame/reg-fx :group-chats/get-group-chat-invitations
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_getGroupChatInvitations"
|
||||
:on-success [::initialize-invitations]})))
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
[legacy.status-im.node.core :as node]
|
||||
[legacy.status-im.utils.mobile-sync :as mobile-network-utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
@@ -61,7 +62,7 @@
|
||||
(dissoc :mailserver/current-request :mailserver/fetching-gaps-in-progress))})
|
||||
|
||||
(defn fetch-use-mailservers?
|
||||
[{:keys [db]}]
|
||||
[db]
|
||||
(get-in db [:profile/profile :use-mailservers?]))
|
||||
|
||||
(defonce showing-connection-error-popup? (atom false))
|
||||
@@ -117,24 +118,32 @@
|
||||
[{:keys [db] :as cofx}]
|
||||
{:db (dissoc db :mailserver/current-request)})
|
||||
|
||||
(defn needs-to-fetch-historic-messages?
|
||||
[db]
|
||||
(and
|
||||
(:messenger/started? db)
|
||||
(mobile-network-utils/syncing-allowed? db)
|
||||
(fetch-use-mailservers? db)
|
||||
(not (:mailserver/current-request db))))
|
||||
|
||||
(rf/defn process-next-messages-request
|
||||
{:events [::request-messages]}
|
||||
[{:keys [db now] :as cofx}]
|
||||
(when (and
|
||||
(:messenger/started? db)
|
||||
(mobile-network-utils/syncing-allowed? cofx)
|
||||
(fetch-use-mailservers? cofx)
|
||||
(not (:mailserver/current-request db)))
|
||||
{:db (assoc db :mailserver/current-request true)
|
||||
:json-rpc/call [{:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||
:params [false]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
(log/info "fetched historical messages")
|
||||
(re-frame/dispatch [::request-success %]))
|
||||
:on-error #(do
|
||||
(log/error "failed retrieve historical messages" %)
|
||||
(re-frame/dispatch [::request-error]))}]}))
|
||||
[{:keys [db]}]
|
||||
(when (needs-to-fetch-historic-messages? db)
|
||||
{:db (assoc db :mailserver/current-request true)
|
||||
:mailserver/request-all-historic-messages nil}))
|
||||
|
||||
(re-frame/reg-fx :mailserver/request-all-historic-messages
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||
:params [false]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
(log/info "fetched historical messages")
|
||||
(re-frame/dispatch [::request-success %]))
|
||||
:on-error #(do
|
||||
(log/error "failed retrieve historical messages" %)
|
||||
(re-frame/dispatch [::request-error]))})))
|
||||
|
||||
(rf/defn handle-mailserver-changed
|
||||
[{:keys [db] :as cofx} ms]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[legacy.status-im.utils.mobile-sync :as utils]
|
||||
[status-im.contexts.chat.home.add-new-contact.events :as add-new-contact]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -18,27 +18,24 @@
|
||||
(or (nil? remember-choice?)
|
||||
remember-choice?))}))
|
||||
|
||||
(rf/defn on-network-status-change
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [initialized? (get db :network-status/initialized?)
|
||||
logged-in? (multiaccounts.model/logged-in? db)
|
||||
{:keys [remember-syncing-choice?]} (:profile/profile db)]
|
||||
(apply
|
||||
rf/merge
|
||||
cofx
|
||||
{:db (assoc db :network-status/initialized? true)}
|
||||
(cond
|
||||
;; NOTE(rasom): When we log into account on-network-status-change is
|
||||
;; dispatched, but that doesn't mean there was a status change, thus
|
||||
;; no reason to restart wallet.
|
||||
(and logged-in? initialized?)
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet-old)
|
||||
#(add-new-contact/set-new-identity-reconnected %)]
|
||||
|
||||
logged-in?
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet-old)]))))
|
||||
(re-frame/reg-event-fx :mobile-network/on-network-status-change
|
||||
(fn [{:keys [db]}]
|
||||
(let [previously-initialized? (get db :network-status/initialized?)
|
||||
logged-in? (multiaccounts.model/logged-in? db)
|
||||
fetch-historic-messages? (mailserver/needs-to-fetch-historic-messages? db)]
|
||||
(if logged-in?
|
||||
{:db (cond-> (-> db
|
||||
(assoc :network-status/initialized? true)
|
||||
(assoc :bottom-sheet/show? false))
|
||||
fetch-historic-messages?
|
||||
(assoc :mailserver/current-request true))
|
||||
:fx [(when fetch-historic-messages?
|
||||
[:mailserver/request-all-historic-messages])
|
||||
[:dismiss-bottom-sheet-overlay-old]
|
||||
(when previously-initialized?
|
||||
(let [new-identity-input (get-in db [:contacts/new-identity :input])]
|
||||
[:dispatch [:contacts/set-new-identity {:input new-identity-input}]]))]}
|
||||
{:db (assoc db :network-status/initialized? true)}))))
|
||||
|
||||
(defn apply-settings
|
||||
([sync?] (apply-settings sync? :default))
|
||||
|
||||
@@ -13,15 +13,14 @@
|
||||
(native-module/logout)))
|
||||
|
||||
(rf/defn initialize-app-db
|
||||
[{{:keys [keycard initials-avatar-font-file]
|
||||
:biometric/keys [supported-type]
|
||||
:network/keys [type]}
|
||||
[{{:keys [keycard initials-avatar-font-file biometrics]
|
||||
:network/keys [type]}
|
||||
:db}]
|
||||
{:db (assoc db/app-db
|
||||
:network/type type
|
||||
:initials-avatar-font-file initials-avatar-font-file
|
||||
:keycard (dissoc keycard :secrets :pin :application-info)
|
||||
:biometric/supported-type supported-type
|
||||
:biometrics biometrics
|
||||
:syncing nil)})
|
||||
|
||||
(rf/defn logout-method
|
||||
@@ -46,6 +45,7 @@
|
||||
[_]
|
||||
;; we need to disable notifications before starting the logout process
|
||||
{:effects/push-notifications-disable nil
|
||||
:dispatch [:alert-banners/remove-all]
|
||||
:dispatch-later [{:ms 100
|
||||
:dispatch [::logout-method
|
||||
{:auth-method keychain/auth-method-none
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
(ns legacy.status-im.network.core
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
[clojure.string :as string]))
|
||||
|
||||
(def url-regex
|
||||
#"https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}(\.[a-z]{2,6})?\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)")
|
||||
@@ -14,12 +9,6 @@
|
||||
[url]
|
||||
(boolean (re-matches url-regex (str url))))
|
||||
|
||||
(def default-manage
|
||||
{:name {:value ""}
|
||||
:url {:value ""}
|
||||
:symbol {:value ""}
|
||||
:chain {:value :mainnet}})
|
||||
|
||||
(defn validate-string
|
||||
[{:keys [value]}]
|
||||
{:value value
|
||||
@@ -56,123 +45,3 @@
|
||||
[current-networks network]
|
||||
(let [chain-id (get-in network [:config :NetworkId])]
|
||||
(every? #(not= chain-id (get-in % [1 :config :NetworkId])) current-networks)))
|
||||
|
||||
(defn get-network
|
||||
[{:keys [db]} network-id]
|
||||
(get-in db [:networks/networks network-id]))
|
||||
|
||||
(rf/defn set-input
|
||||
{:events [::input-changed]}
|
||||
[{:keys [db]} input-key value]
|
||||
{:db (-> db
|
||||
(update-in [:networks/manage input-key] assoc :value value)
|
||||
(update-in [:networks/manage] validate-manage))})
|
||||
|
||||
;; No edit functionality actually implemented
|
||||
(rf/defn edit
|
||||
{:events [::add-network-pressed]}
|
||||
[{db :db}]
|
||||
{:db (assoc db :networks/manage (validate-manage default-manage))
|
||||
:dispatch [:navigate-to :edit-network]})
|
||||
|
||||
(rf/defn connect-success
|
||||
{:events [::connect-success]}
|
||||
[_ network-id]
|
||||
{:ui/show-confirmation
|
||||
{:title (i18n/label :t/close-app-title)
|
||||
:content (i18n/label :t/logout-app-content)
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept #(re-frame/dispatch [::save-network-settings-pressed network-id])
|
||||
:on-cancel nil}})
|
||||
|
||||
(rf/defn connect-failure
|
||||
{:events [::connect-failure]}
|
||||
[_ reason]
|
||||
{:effects.utils/show-popup
|
||||
{:title (i18n/label :t/error)
|
||||
:content (str reason)}})
|
||||
|
||||
(rf/defn connect
|
||||
{:events [::connect-network-pressed]}
|
||||
[{:keys [db] :as cofx} network-id]
|
||||
(if (get-in db [:networks/networks network-id :config])
|
||||
(connect-success cofx network-id)
|
||||
(connect-failure cofx "A network with the specified id doesn't exist")))
|
||||
|
||||
(rf/defn delete
|
||||
{:events [::delete-network-pressed]}
|
||||
[{:keys [db]} network]
|
||||
(let [current-network? (= (:networks/current-network db) network)]
|
||||
(if (or current-network?
|
||||
(not (get-in db [:networks/networks network])))
|
||||
{:ui/show-error (i18n/label :t/delete-network-error)}
|
||||
{:ui/show-confirmation {:title (i18n/label :t/delete-network-title)
|
||||
:content (i18n/label :t/delete-network-confirmation)
|
||||
:confirm-button-text (i18n/label :t/delete)
|
||||
:on-accept #(re-frame/dispatch [::remove-network-confirmed
|
||||
network])
|
||||
:on-cancel nil}})))
|
||||
|
||||
(rf/defn save-network-settings
|
||||
{:events [::save-network-settings-pressed]}
|
||||
[{:keys [db] :as cofx} network]
|
||||
{:db (assoc db :networks/current-network network)
|
||||
:json-rpc/call [{:method "settings_saveSetting"
|
||||
:params [:networks/current-network network]
|
||||
:on-success #(re-frame/dispatch [:logout])}]})
|
||||
|
||||
(rf/defn remove-network
|
||||
{:events [::remove-network-confirmed]}
|
||||
[{:keys [db] :as cofx} network]
|
||||
(let [networks (dissoc (:networks/networks db) network)]
|
||||
{:db (assoc db :networks/networks networks)
|
||||
:json-rpc/call [{:method "settings_saveSetting"
|
||||
:params [:networks/networks (vals networks)]
|
||||
:on-success #(re-frame/dispatch [:navigate-back])}]}))
|
||||
|
||||
(defn new-network
|
||||
[random-id network-name sym upstream-url chain-type chain-id]
|
||||
(let [data-dir (str "/ethereum/" (name chain-type) "_rpc")
|
||||
config {:NetworkId (or (when chain-id (int chain-id))
|
||||
(chain/chain-keyword->chain-id chain-type))
|
||||
:DataDir data-dir
|
||||
:UpstreamConfig {:Enabled true
|
||||
:URL upstream-url}}]
|
||||
{:id random-id
|
||||
:name network-name
|
||||
:symbol sym
|
||||
:config config}))
|
||||
|
||||
(rf/defn save
|
||||
{:events [::save-network-pressed]
|
||||
:interceptors [(re-frame/inject-cofx :random-id-generator)]}
|
||||
[{{:networks/keys [manage networks] :as db} :db
|
||||
random-id-generator :random-id-generator
|
||||
:as cofx}]
|
||||
(if (valid-manage? manage)
|
||||
;; rename network-id from UI to chain-id
|
||||
(let [{:keys [name url chain network-id symbol]} manage
|
||||
random-id (string/replace (random-id-generator) "-" "")
|
||||
network (new-network random-id
|
||||
(:value name)
|
||||
(:value symbol)
|
||||
(:value url)
|
||||
(:value chain)
|
||||
(:value network-id))
|
||||
custom-chain-type? (= :custom (:value chain))
|
||||
new-networks (assoc networks random-id network)]
|
||||
(if (or (not custom-chain-type?)
|
||||
(chain-id-available? networks network))
|
||||
{:db (-> db
|
||||
(dissoc :networks/manage)
|
||||
(assoc :networks/networks new-networks))
|
||||
:json-rpc/call [{:method "settings_saveSetting"
|
||||
:params [:networks/networks (vals new-networks)]
|
||||
:on-success #(re-frame/dispatch [:navigate-back])}]}
|
||||
{:ui/show-error "chain-id already defined"}))
|
||||
{:ui/show-error "invalid network parameters"}))
|
||||
|
||||
(rf/defn open-network-details
|
||||
{:events [::network-entry-pressed]}
|
||||
[cofx network]
|
||||
(navigation/navigate-to cofx :network-details {:networks/selected-network network}))
|
||||
|
||||
@@ -31,38 +31,6 @@
|
||||
(testing "an https url not on the default port"
|
||||
(is (network.core/valid-rpc-url? "https://valid.something.else:65323"))))
|
||||
|
||||
(deftest new-network-test
|
||||
(let [actual (network.core/new-network "randomid"
|
||||
"network-name"
|
||||
"network-symbol"
|
||||
"upstream-url"
|
||||
:mainnet
|
||||
nil)]
|
||||
(is (= {:id "randomid"
|
||||
:name "network-name"
|
||||
:symbol "network-symbol"
|
||||
:config {:NetworkId 1
|
||||
:DataDir "/ethereum/mainnet_rpc"
|
||||
:UpstreamConfig {:Enabled true
|
||||
:URL "upstream-url"}}}
|
||||
actual))))
|
||||
|
||||
(deftest new-network-id-test
|
||||
(let [actual (network.core/new-network "randomid"
|
||||
"network-name"
|
||||
"network-symbol"
|
||||
"upstream-url"
|
||||
:mainnet
|
||||
"5777")]
|
||||
(is (= {:id "randomid"
|
||||
:name "network-name"
|
||||
:symbol "network-symbol"
|
||||
:config {:NetworkId 5777
|
||||
:DataDir "/ethereum/mainnet_rpc"
|
||||
:UpstreamConfig {:Enabled true
|
||||
:URL "upstream-url"}}}
|
||||
actual))))
|
||||
|
||||
(deftest valid-manage-test
|
||||
(testing "a valid manage"
|
||||
(is (network.core/valid-manage? {:url {:value "http://valid.com"}
|
||||
@@ -92,101 +60,3 @@
|
||||
:name {:value "valid"}
|
||||
:symbol {:value ""}
|
||||
:chain {:value "valid"}})))))
|
||||
|
||||
(deftest set-input-test
|
||||
(testing "it updates and validate a field"
|
||||
(is
|
||||
(= {:db {:networks/manage {:url {:value "http://valid.com"
|
||||
:error false}
|
||||
:name {:value ""
|
||||
:error true}
|
||||
:symbol {:value "symbol"
|
||||
:error false}
|
||||
:chain {:value "mainnet"
|
||||
:error false}
|
||||
:network-id {:value nil
|
||||
:error false}}}}
|
||||
(network.core/set-input {:db {:networks/manage {:url {:value "something"
|
||||
:error true}
|
||||
:name {:value ""
|
||||
:error false}
|
||||
:symbol {:value "symbol"
|
||||
:error false}
|
||||
:chain {:value "mainnet"
|
||||
:error false}}}}
|
||||
:url
|
||||
"http://valid.com")))))
|
||||
|
||||
(deftest not-save-invalid-url
|
||||
(testing "it does not save a network with an invalid url"
|
||||
(is
|
||||
(:ui/show-error (network.core/save {:random-id-generator (constantly "random")
|
||||
:db {:networks/manage {:url {:value "wrong"}
|
||||
:chain {:value "1"}
|
||||
:name {:value "empty"}}
|
||||
:profile/profile {}}})))))
|
||||
|
||||
(deftest save-valid-network
|
||||
(testing "save a valid network"
|
||||
(let [fx (network.core/save
|
||||
{:random-id-generator (constantly "random-id")
|
||||
:db {:networks/manage {:url {:value "http://valid.com"}
|
||||
:chain {:value :mainnet}
|
||||
:symbol {:value "symbol"}
|
||||
:name {:value "valid"}}
|
||||
:profile/profile {}
|
||||
:networks/networks {"random2"
|
||||
{:id "random2"
|
||||
:name "network-name"
|
||||
:symbol "symbol"
|
||||
:config {:NetworkId 1
|
||||
:DataDir "/ethereum/mainnet_rpc"
|
||||
:UpstreamConfig
|
||||
{:Enabled true
|
||||
:URL "upstream-url"}}}}}})]
|
||||
(is (= "settings_saveSetting" (:method (first (:json-rpc/call fx)))))
|
||||
(is (nil? (:networks/manage (:db fx))))
|
||||
(testing "and check that it has an id with `-` and the correct mainnet NetworkId"
|
||||
(is (= 1 (get-in fx [:db :networks/networks "randomid" :config :NetworkId])))))))
|
||||
|
||||
(deftest not-save-custom-chain-with-non-unique-id
|
||||
(testing "it does not save a custom chain with network-id already defined"
|
||||
(let [result (network.core/save
|
||||
{:random-id-generator (constantly "already-defined")
|
||||
:db {:networks/manage {:url {:value "http://valid.com"}
|
||||
:chain {:value :custom}
|
||||
:name {:value "valid"}
|
||||
:network-id {:value 1}}
|
||||
:profile/profile {}
|
||||
:networks/networks {"random"
|
||||
{:id "random"
|
||||
:name "network-name"
|
||||
:config {:NetworkId 1
|
||||
:DataDir "/ethereum/mainnet_rpc"
|
||||
:UpstreamConfig
|
||||
{:Enabled true
|
||||
:URL "upstream-url"}}}}}})]
|
||||
(is (:ui/show-error result)))))
|
||||
|
||||
(deftest save-valid-network-with-unique-chain-id-check
|
||||
(testing "save a valid network with chain-id not already defined"
|
||||
(let [fx (network.core/save
|
||||
{:random-id-generator (constantly "random")
|
||||
:db {:networks/manage {:url {:value "http://valid.com"}
|
||||
:chain {:value :mainnet}
|
||||
:name {:value "valid"}
|
||||
:symbol {:value "symbol"}
|
||||
:network-id {:value 5}}
|
||||
:profile/profile {}
|
||||
:networks/networks {"randomid"
|
||||
{:id "randomid"
|
||||
:name "network-name"
|
||||
:symbol "symbol"
|
||||
:config {:NetworkId 3
|
||||
:DataDir "/ethereum/mainnet_rpc"
|
||||
:UpstreamConfig
|
||||
{:Enabled true
|
||||
:URL "upstream-url"}}}}}})]
|
||||
(is (= "settings_saveSetting" (:method (first (:json-rpc/call fx)))))
|
||||
(is (nil? (:networks/manage (:db fx))))
|
||||
(is (get-in fx [:db :networks/networks "random"])))))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns legacy.status-im.network.net-info
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]
|
||||
[legacy.status-im.mobile-sync-settings.core :as mobile-network]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
@@ -13,11 +12,11 @@
|
||||
{:db (assoc db :network-status (if is-connected? :online :offline))}))
|
||||
|
||||
(rf/defn change-network-type
|
||||
[{:keys [db] :as cofx} old-network-type network-type expensive?]
|
||||
[{:keys [db] :as cofx} network-type expensive?]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :network/type network-type)
|
||||
:network/notify-status-go [network-type expensive?]}
|
||||
(mobile-network/on-network-status-change)))
|
||||
:network/notify-status-go [network-type expensive?]
|
||||
:dispatch [:mobile-network/on-network-status-change]}))
|
||||
|
||||
(rf/defn handle-network-info-change
|
||||
{:events [::network-info-changed]}
|
||||
@@ -37,7 +36,7 @@
|
||||
(when-not status-changed?
|
||||
(change-network-status isConnected))
|
||||
(when-not type-changed?
|
||||
(change-network-type old-network-type type (:is-connection-expensive details))))))
|
||||
(change-network-type type (:is-connection-expensive details))))))
|
||||
|
||||
(defn add-net-info-listener
|
||||
[]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require
|
||||
[legacy.status-im.utils.utils :as utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.re-frame :as rf]))
|
||||
@@ -22,6 +23,21 @@
|
||||
:params [(chain/chain-id db) id]
|
||||
:on-success #()}]}))
|
||||
|
||||
(re-frame/reg-fx :stickers/load-packs
|
||||
(fn [chain-id]
|
||||
(json-rpc/call {:method "stickers_market"
|
||||
:params [chain-id]
|
||||
:on-success [:stickers/stickers-market-success]})
|
||||
(json-rpc/call {:method "stickers_installed"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-installed-success]})
|
||||
(json-rpc/call {:method "stickers_pending"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-pending-success]})
|
||||
(json-rpc/call {:method "stickers_recent"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-recent-success]})))
|
||||
|
||||
(rf/defn load-packs
|
||||
{:events [:stickers/load-packs]}
|
||||
[{:keys [db]}]
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
(re-frame/reg-sub
|
||||
:mailserver/use-status-nodes?
|
||||
(fn [db _]
|
||||
(boolean (mailserver/fetch-use-mailservers? {:db db}))))
|
||||
(boolean (mailserver/fetch-use-mailservers? db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:mailserver.edit/validation-errors
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
(ns legacy.status-im.subs.networks
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.config :as config]
|
||||
[utils.ethereum.chain :as chain]))
|
||||
|
||||
(defn- filter-networks
|
||||
[network-type]
|
||||
(fn [network]
|
||||
(let [chain-id (chain/network->chain-id network)
|
||||
testnet? (chain/testnet? chain-id)
|
||||
custom? (:custom? network)]
|
||||
(case network-type
|
||||
:custom custom?
|
||||
:mainnet (and (not custom?) (not testnet?))
|
||||
:testnet (and (not custom?) testnet?)))))
|
||||
|
||||
(defn- label-networks
|
||||
[default-networks]
|
||||
(fn [network]
|
||||
(let [custom? (not (default-networks (:id network)))]
|
||||
(assoc network :custom? custom?))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-networks
|
||||
:<- [:networks/networks]
|
||||
(fn [networks]
|
||||
(let [networks (map (label-networks (into #{} (map :id config/default-networks)))
|
||||
(sort-by :name (vals networks)))
|
||||
types [:mainnet :testnet :custom]]
|
||||
(zipmap
|
||||
types
|
||||
(map #(filter (filter-networks %) networks) types)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:manage-network-valid?
|
||||
:<- [:networks/manage]
|
||||
(fn [manage]
|
||||
(not-any? :error (vals manage))))
|
||||
@@ -5,7 +5,6 @@
|
||||
legacy.status-im.subs.ens
|
||||
legacy.status-im.subs.keycard
|
||||
legacy.status-im.subs.mailservers
|
||||
legacy.status-im.subs.networks
|
||||
legacy.status-im.subs.stickers
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
@@ -100,6 +99,7 @@
|
||||
;;; Link previews
|
||||
(reg-root-key-sub :link-previews-whitelist :link-previews-whitelist)
|
||||
(reg-root-key-sub :chat/link-previews :chat/link-previews)
|
||||
(reg-root-key-sub :chat/status-link-previews :chat/status-link-previews)
|
||||
|
||||
;;commands
|
||||
(reg-root-key-sub :commands/select-account :commands/select-account)
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
(re-frame/dispatch event))
|
||||
|
||||
(defn- normal-mode-settings-data
|
||||
[{:keys [network-name
|
||||
current-log-level
|
||||
[{:keys [current-log-level
|
||||
light-client-enabled?
|
||||
transactions-management-enabled?
|
||||
current-fleet
|
||||
@@ -25,22 +24,6 @@
|
||||
(keep
|
||||
identity
|
||||
[{:size :small
|
||||
:title (i18n/label :t/network)
|
||||
:accessibility-label :network-button
|
||||
:container-margin-top 8
|
||||
:on-press
|
||||
#(re-frame/dispatch [:open-modal :network-settings])
|
||||
:accessory :text
|
||||
:accessory-text network-name
|
||||
:chevron true}
|
||||
{:size :small
|
||||
:title (i18n/label :t/network-info)
|
||||
:accessibility-label :network-button
|
||||
:container-margin-top 8
|
||||
:on-press
|
||||
#(re-frame/dispatch [:open-modal :network-info])
|
||||
:chevron true}
|
||||
{:size :small
|
||||
:title (i18n/label :t/log-level)
|
||||
:accessibility-label :log-level-settings-button
|
||||
:on-press
|
||||
@@ -151,15 +134,13 @@
|
||||
is-goerli-enabled? [:profile/is-goerli-enabled?]
|
||||
light-client-enabled? [:profile/light-client-enabled?]
|
||||
webview-debug [:profile/webview-debug]
|
||||
network-name [:network-name]
|
||||
transactions-management-enabled? [:wallet-legacy/transactions-management-enabled?]
|
||||
current-log-level [:log-level/current-log-level]
|
||||
current-fleet [:fleets/current-fleet]
|
||||
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
|
||||
[list/flat-list
|
||||
{:data (flat-list-data
|
||||
{:network-name network-name
|
||||
:current-log-level current-log-level
|
||||
{:current-log-level current-log-level
|
||||
:transactions-management-enabled? transactions-management-enabled?
|
||||
:light-client-enabled? light-client-enabled?
|
||||
:current-fleet current-fleet
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
(:require
|
||||
[legacy.status-im.react-native.resources :as resources]
|
||||
[legacy.status-im.ui.components.colors :as quo.colors]
|
||||
[legacy.status-im.ui.components.fast-image :as fast-image]
|
||||
[legacy.status-im.ui.screens.chat.message.legacy-style :as style]
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
@@ -145,23 +144,6 @@
|
||||
[rn/text {:style (style/status-text)}]
|
||||
(-> content :parsed-text peek :children))]])
|
||||
|
||||
;; EMOJI
|
||||
(defn emoji
|
||||
[]
|
||||
(fn [{:keys [content] :as message}]
|
||||
[rn/view (style/message-view message)
|
||||
[rn/view {:style (style/message-view-content)}
|
||||
[rn/view {:style (style/style-message-text)}
|
||||
[rn/text {:style (style/emoji-message message)}
|
||||
(:text content)]]]]))
|
||||
|
||||
;; STICKER
|
||||
(defn sticker
|
||||
[{:keys [content]}]
|
||||
[fast-image/fast-image
|
||||
{:style {:margin 10 :width 140 :height 140}
|
||||
:source {:uri (str (-> content :sticker :url) "&download=true")}}])
|
||||
|
||||
(defn contact-request-status-pending
|
||||
[]
|
||||
[rn/view {:style {:flex-direction :row}}
|
||||
|
||||
@@ -85,9 +85,7 @@
|
||||
:accessibility-label :share-community-link
|
||||
:type :secondary
|
||||
:on-press #(debounce/throttle-and-dispatch
|
||||
[(if can-invite?
|
||||
::communities/invite-people-confirmation-pressed
|
||||
::communities/share-community-confirmation-pressed) @user-pk
|
||||
[::communities/share-community-confirmation-pressed @user-pk
|
||||
selected]
|
||||
3000)}
|
||||
(i18n/label (if can-invite? :t/invite :t/share))]}]]))))
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
{:active (= value id)
|
||||
:accessory :radio
|
||||
:title (get titles id)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/update-value :default-sync-period id])}])
|
||||
:on-press #(re-frame/dispatch [:profile.settings/profile-update :default-sync-period id])}])
|
||||
|
||||
(views/defview default-sync-period-settings
|
||||
[]
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network.edit-network.styles)
|
||||
|
||||
(def edit-network-view
|
||||
{:flex 1
|
||||
:margin-horizontal 16
|
||||
:margin-vertical 15})
|
||||
|
||||
(def bottom-container
|
||||
{:flex-direction :row
|
||||
:padding-vertical 4})
|
||||
|
||||
(def container {:flex 1})
|
||||
@@ -1,72 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network.edit-network.views
|
||||
(:require
|
||||
[legacy.status-im.network.core :as network]
|
||||
[legacy.status-im.ui.components.core :as quo]
|
||||
[legacy.status-im.ui.components.list.item :as list.item]
|
||||
[legacy.status-im.ui.components.list.views :as list]
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[legacy.status-im.ui.screens.network.edit-network.styles :as styles]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.i18n :as i18n])
|
||||
(:require-macros [legacy.status-im.utils.views :as views]))
|
||||
|
||||
(defn- render-network-type
|
||||
[type _ _ manage-network]
|
||||
(let [name (case type
|
||||
:mainnet (i18n/label :t/mainnet-network)
|
||||
:goerli (i18n/label :t/goerli-network)
|
||||
:custom (i18n/label :t/custom))]
|
||||
[list.item/list-item
|
||||
{:title name
|
||||
:accessory :radio
|
||||
:active (= (get-in manage-network [:chain :value]) type)
|
||||
:on-press #(re-frame/dispatch [::network/input-changed :chain type])}]))
|
||||
|
||||
(views/defview edit-network
|
||||
[]
|
||||
(views/letsubs [manage-network [:networks/manage]
|
||||
is-valid? [:manage-network-valid?]]
|
||||
(let [custom? (= (get-in manage-network [:chain :value]) :custom)]
|
||||
[react/keyboard-avoiding-view {:flex 1}
|
||||
[react/scroll-view
|
||||
[react/view styles/edit-network-view
|
||||
[react/view {:padding-vertical 8}
|
||||
[quo/text-input
|
||||
{:label (i18n/label :t/name)
|
||||
:placeholder (i18n/label :t/specify-name)
|
||||
:default-value (get-in manage-network [:name :value])
|
||||
:on-change-text #(re-frame/dispatch [::network/input-changed :name %])
|
||||
:auto-focus true}]]
|
||||
[react/view {:padding-vertical 8}
|
||||
[quo/text-input
|
||||
{:label (i18n/label :t/symbol)
|
||||
:placeholder (i18n/label :t/specify-symbol)
|
||||
:default-value (get-in manage-network [:symbol :value])
|
||||
:on-change-text #(re-frame/dispatch [::network/input-changed :symbol %])
|
||||
:auto-focus true}]]
|
||||
[react/view {:padding-vertical 8}
|
||||
[quo/text-input
|
||||
{:label (i18n/label :t/rpc-url)
|
||||
:placeholder (i18n/label :t/specify-rpc-url)
|
||||
:default-value (get-in manage-network [:url :value])
|
||||
:on-change-text #(re-frame/dispatch [::network/input-changed :url %])}]]]
|
||||
[quo/list-header (i18n/label :t/network-chain)]
|
||||
[list/flat-list
|
||||
{:data [:mainnet :goerli :custom]
|
||||
:key-fn (fn [_ i] (str i))
|
||||
:render-data manage-network
|
||||
:render-fn render-network-type}]
|
||||
(when custom?
|
||||
[react/view styles/edit-network-view
|
||||
[quo/text-input
|
||||
{:label (i18n/label :t/network-id)
|
||||
:placeholder (i18n/label :t/specify-network-id)
|
||||
:on-change-text #(re-frame/dispatch [::network/input-changed :network-id %])}]])]
|
||||
[react/view styles/bottom-container
|
||||
[react/view {:flex 1}]
|
||||
[quo/button
|
||||
{:after :main-icons/next
|
||||
:type :secondary
|
||||
:disabled (not is-valid?)
|
||||
:on-press #(re-frame/dispatch [::network/save-network-pressed])}
|
||||
(i18n/label :t/save)]]])))
|
||||
@@ -1,47 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network.network-details.views
|
||||
(:require
|
||||
[legacy.status-im.network.core :as network]
|
||||
[legacy.status-im.ui.components.core :as quo]
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[legacy.status-im.ui.screens.network.styles :as st]
|
||||
[legacy.status-im.ui.screens.network.views :as network-settings]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.debounce :refer [throttle-and-dispatch]]
|
||||
[utils.i18n :as i18n])
|
||||
(:require-macros [legacy.status-im.utils.views :as views]))
|
||||
|
||||
(views/defview network-details
|
||||
[]
|
||||
(views/letsubs [{:keys [networks/selected-network]} [:get-screen-params]
|
||||
current-network [:networks/current-network]
|
||||
networks [:get-networks]]
|
||||
(let [{:keys [id name config]} selected-network
|
||||
connected? (= id current-network)
|
||||
custom? (seq (filter #(= (:id %) id) (:custom networks)))]
|
||||
[:<>
|
||||
[react/view {:flex 1}
|
||||
[network-settings/network-badge
|
||||
{:name name
|
||||
:connected? connected?}]
|
||||
(when-not connected?
|
||||
[react/touchable-highlight
|
||||
{:on-press #(throttle-and-dispatch [::network/connect-network-pressed id] 1000)}
|
||||
[react/view st/connect-button-container
|
||||
[react/view
|
||||
{:style st/connect-button
|
||||
:accessibility-label :network-connect-button}
|
||||
[react/text {:style st/connect-button-label}
|
||||
(i18n/label :t/connect)]]
|
||||
[react/i18n-text
|
||||
{:style st/connect-button-description
|
||||
:key :connecting-requires-login}]]])
|
||||
[react/view (st/network-config-container)
|
||||
[react/text
|
||||
{:style st/network-config-text
|
||||
:accessibility-label :network-details-text}
|
||||
config]]]
|
||||
(when custom?
|
||||
[react/view st/bottom-container
|
||||
[react/view {:flex 1}
|
||||
[quo/button {:on-press #(re-frame/dispatch [::network/delete-network-pressed id])}
|
||||
(i18n/label :t/delete)]]])])))
|
||||
@@ -1,90 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network.styles
|
||||
(:require
|
||||
[legacy.status-im.ui.components.colors :as colors]
|
||||
[legacy.status-im.utils.styles :as styles]))
|
||||
|
||||
(def wrapper
|
||||
{:flex 1})
|
||||
|
||||
(def badge-name-text
|
||||
{:font-size 17})
|
||||
|
||||
(styles/def badge-connected-text
|
||||
{:color colors/gray
|
||||
:ios {:margin-top 5}})
|
||||
|
||||
(def connect-button-container
|
||||
{:margin-top 8
|
||||
:margin-bottom 16
|
||||
:margin-horizontal 16})
|
||||
|
||||
(def connect-button
|
||||
{:height 52
|
||||
:align-items :center
|
||||
:justify-content :center
|
||||
:background-color colors/blue
|
||||
:border-radius 8
|
||||
:ios {:opacity 0.9}})
|
||||
|
||||
(def connect-button-label
|
||||
{:color colors/white-persist
|
||||
:font-size 17})
|
||||
|
||||
(def connect-button-description
|
||||
{:color colors/gray
|
||||
:margin-top 8
|
||||
:height 20})
|
||||
|
||||
(styles/defn network-config-container
|
||||
[]
|
||||
{:height 160
|
||||
:margin-top 8
|
||||
:padding-top 16
|
||||
:padding-left 16
|
||||
:margin-horizontal 16
|
||||
:background-color colors/gray-lighter
|
||||
:ios {:border-radius 9
|
||||
:opacity 0.9}
|
||||
:android {:border-radius 4}})
|
||||
|
||||
(styles/def network-config-text
|
||||
{:font-size 17
|
||||
:ios {:opacity 0.8}
|
||||
:android {:opacity 0.4}})
|
||||
|
||||
(defn network-icon
|
||||
[connected? size]
|
||||
{:width size
|
||||
:height size
|
||||
:border-radius (/ size 2)
|
||||
:background-color (if connected? colors/blue colors/gray-lighter)
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def network-badge
|
||||
{:height 88
|
||||
:padding-left 16
|
||||
:flex-direction :row
|
||||
:align-items :center})
|
||||
|
||||
(styles/def network-item
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:padding-horizontal 16
|
||||
:ios {:height 64}
|
||||
:android {:height 56}})
|
||||
|
||||
(def network-item-name-text
|
||||
{:font-size 17})
|
||||
|
||||
(def network-item-connected-text
|
||||
{:color colors/gray
|
||||
:font-size 14
|
||||
:margin-top 6})
|
||||
|
||||
(def bottom-container
|
||||
{:flex-direction :row
|
||||
:margin-horizontal 12
|
||||
:margin-vertical 15})
|
||||
|
||||
(def container {:flex 1})
|
||||
@@ -1,71 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network.views
|
||||
(:require
|
||||
[legacy.status-im.network.core :as network]
|
||||
[legacy.status-im.ui.components.colors :as colors]
|
||||
[legacy.status-im.ui.components.icons.icons :as icons]
|
||||
[legacy.status-im.ui.components.list.item :as list.item]
|
||||
[legacy.status-im.ui.components.list.views :as list]
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[legacy.status-im.ui.components.topbar :as topbar]
|
||||
[legacy.status-im.ui.screens.network.styles :as styles]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.i18n :as i18n])
|
||||
(:require-macros [legacy.status-im.utils.views :as views]))
|
||||
|
||||
(defn- network-icon
|
||||
[connected? size]
|
||||
[react/view (styles/network-icon connected? size)
|
||||
[icons/icon :main-icons/network {:color (if connected? colors/white-persist colors/gray)}]])
|
||||
|
||||
(defn network-badge
|
||||
[& [{:keys [name connected?]}]]
|
||||
[react/view styles/network-badge
|
||||
[network-icon connected? 56]
|
||||
[react/view {:padding-left 16}
|
||||
[react/text {:style styles/badge-name-text}
|
||||
(or name (i18n/label :t/new-network))]
|
||||
(when connected?
|
||||
[react/i18n-text
|
||||
{:style styles/badge-connected-text
|
||||
:key :connected}])]])
|
||||
|
||||
(def mainnet?
|
||||
#{"mainnet" "mainnet_rpc"})
|
||||
|
||||
(defn render-network
|
||||
[{:keys [id name] :as network} _ _ current-network]
|
||||
(let [connected? (= id current-network)]
|
||||
[list.item/list-item
|
||||
{:on-press #(re-frame/dispatch [::network/network-entry-pressed network])
|
||||
:icon :main-icons/network
|
||||
:icon-bg-color (if connected? colors/blue colors/gray-lighter)
|
||||
:icon-color (if connected? colors/white-persist colors/gray)
|
||||
:title name
|
||||
:subtitle (when connected? (i18n/label :t/connected))
|
||||
:chevron true}]))
|
||||
|
||||
(views/defview network-settings
|
||||
[]
|
||||
(views/letsubs [current-network [:networks/current-network]
|
||||
networks [:get-networks]]
|
||||
[:<>
|
||||
[topbar/topbar
|
||||
{:title (i18n/label :t/network-settings)
|
||||
:right-accessories
|
||||
[{:icon :main-icons/add
|
||||
:on-press #(re-frame/dispatch [::network/add-network-pressed])}]}]
|
||||
[react/view styles/wrapper
|
||||
[list/section-list
|
||||
{:sections [{:title (i18n/label :t/main-networks)
|
||||
:key :mainnet
|
||||
:data (:mainnet networks)}
|
||||
{:title (i18n/label :t/test-networks)
|
||||
:key :testnet
|
||||
:data (:testnet networks)}
|
||||
{:title (i18n/label :t/custom-networks)
|
||||
:key :custom
|
||||
:data (:custom networks)}]
|
||||
:key-fn :id
|
||||
:default-separator? true
|
||||
:render-data current-network
|
||||
:render-fn render-network}]]]))
|
||||
@@ -1,84 +0,0 @@
|
||||
(ns legacy.status-im.ui.screens.network-info.views
|
||||
(:require
|
||||
[legacy.status-im.ethereum.decode :as decode]
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[utils.datetime :as datetime]))
|
||||
|
||||
(defn get-block
|
||||
[block callback]
|
||||
(json-rpc/call
|
||||
{:method "eth_getBlockByNumber"
|
||||
:params [block false]
|
||||
:on-success callback
|
||||
:on-error #(js/alert (str "can't fetch latest block" %))}))
|
||||
|
||||
(defn to-date
|
||||
[timestamp]
|
||||
(datetime/timestamp->long-date
|
||||
(* 1000 timestamp)))
|
||||
|
||||
(defn check-lag
|
||||
[]
|
||||
(let [latest-block (reagent/atom nil)
|
||||
last-loaded-block (reagent/atom nil)
|
||||
on-press
|
||||
(fn []
|
||||
(get-block
|
||||
"latest"
|
||||
(fn [res]
|
||||
(reset! latest-block res)
|
||||
(get-block
|
||||
(str "0x"
|
||||
(native-module/number-to-hex
|
||||
@(re-frame/subscribe [:ethereum/current-block])))
|
||||
(fn [res]
|
||||
(reset! last-loaded-block res))))))]
|
||||
(fn []
|
||||
[react/view
|
||||
{:style {:flex 1
|
||||
:margin-horizontal 16}}
|
||||
(if-not @latest-block
|
||||
[react/text
|
||||
{:on-press on-press}
|
||||
"PRESS TO REFRESH"]
|
||||
[react/text
|
||||
{:on-press on-press}
|
||||
(let [latest-block-number
|
||||
(decode/uint (:number @latest-block))
|
||||
|
||||
latest-block-timestamp
|
||||
(decode/uint (:timestamp @latest-block))
|
||||
|
||||
last-loaded-block-number
|
||||
(decode/uint (:number @last-loaded-block))
|
||||
|
||||
last-loaded-block-timestamp
|
||||
(decode/uint (:timestamp @last-loaded-block))]
|
||||
(str "Latest block number: "
|
||||
latest-block-number
|
||||
"\n"
|
||||
"Latest block time: "
|
||||
(to-date latest-block-timestamp)
|
||||
"\n"
|
||||
"Last loaded block: "
|
||||
last-loaded-block-number
|
||||
"\n"
|
||||
"Last loaded block time: "
|
||||
(to-date last-loaded-block-timestamp)
|
||||
"\n"
|
||||
"Seconds diff: "
|
||||
(- latest-block-timestamp
|
||||
last-loaded-block-timestamp)
|
||||
"\n"
|
||||
"Blocks diff: " (- latest-block-number
|
||||
last-loaded-block-number)
|
||||
"\n"
|
||||
"PRESS TO REFRESH"))])])))
|
||||
|
||||
(defn network-info
|
||||
[]
|
||||
[check-lag])
|
||||
@@ -111,7 +111,7 @@
|
||||
:subtitle (i18n/label :t/webview-camera-permission-requests-subtitle)
|
||||
:subtitle-max-lines 2
|
||||
:on-press #(re-frame/dispatch
|
||||
[:profile.settings/update-value
|
||||
[:profile.settings/profile-update
|
||||
:webview-allow-permission-requests?
|
||||
((complement boolean) webview-allow-permission-requests?)])}])
|
||||
[separator]
|
||||
@@ -169,8 +169,7 @@
|
||||
{:active (= value id)
|
||||
:accessory :radio
|
||||
:title (get titles id)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/update-value :profile-pictures-visibility
|
||||
id])}])
|
||||
:on-press #(re-frame/dispatch [:profile.settings/profile-update :profile-pictures-visibility id])}])
|
||||
|
||||
(views/defview profile-pic
|
||||
[]
|
||||
|
||||
@@ -51,4 +51,4 @@
|
||||
:icon :main-icons/delete
|
||||
:theme :accent
|
||||
:title (i18n/label :t/profile-pic-remove)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/delete-profile-picture nil])}])]))
|
||||
:on-press #(re-frame/dispatch [:profile.settings/delete-profile-picture])}])]))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns legacy.status-im.ui.screens.screens
|
||||
(:require
|
||||
[legacy.status-im.ui.components.colors :as colors]
|
||||
[legacy.status-im.ui.components.icons.icons :as icons]
|
||||
[legacy.status-im.ui.screens.about-app.views :as about-app]
|
||||
[legacy.status-im.ui.screens.advanced-settings.views :as advanced-settings]
|
||||
[legacy.status-im.ui.screens.appearance.views :as appearance]
|
||||
@@ -24,10 +23,6 @@
|
||||
[legacy.status-im.ui.screens.link-previews-settings.views :as link-previews-settings]
|
||||
[legacy.status-im.ui.screens.log-level-settings.views :as log-level-settings]
|
||||
[legacy.status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings]
|
||||
[legacy.status-im.ui.screens.network-info.views :as network-info]
|
||||
[legacy.status-im.ui.screens.network.edit-network.views :as edit-network]
|
||||
[legacy.status-im.ui.screens.network.network-details.views :as network-details]
|
||||
[legacy.status-im.ui.screens.network.views :as network]
|
||||
[legacy.status-im.ui.screens.notifications-settings.views :as notifications-settings]
|
||||
[legacy.status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :as edit-mailserver]
|
||||
[legacy.status-im.ui.screens.offline-messaging-settings.views :as offline-messaging-settings]
|
||||
@@ -52,10 +47,18 @@
|
||||
[status-im.contexts.chat.group-details.view :as group-details]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(defn right-button-options
|
||||
[id icon]
|
||||
{:id id
|
||||
:icon (icons/icon-source icon)})
|
||||
(defn topbar-options
|
||||
[title]
|
||||
{:elevation 0
|
||||
:title {:color (if (colors/dark?) colors/white colors/black)
|
||||
:text (i18n/label title)}
|
||||
:rightButtonColor (if (colors/dark?) colors/white colors/black)
|
||||
:background {:color (if (colors/dark?) colors/black colors/white)}
|
||||
:backButton {:color (if (colors/dark?) colors/white colors/black)
|
||||
:id :legacy-back-button
|
||||
:testID :back-button
|
||||
:visible true
|
||||
:popStackOnPress false}})
|
||||
|
||||
(defn screens
|
||||
[]
|
||||
@@ -81,20 +84,15 @@
|
||||
|
||||
{:name :stickers
|
||||
:options {:insets {:top? true}
|
||||
:topBar {:title {:text (i18n/label :t/sticker-market)}}}
|
||||
:topBar (topbar-options :t/sticker-market)}
|
||||
:component stickers/packs}
|
||||
|
||||
{:name :stickers-pack
|
||||
:options {:insets {:top? true}}
|
||||
:component stickers/pack}
|
||||
|
||||
{:name :new-group
|
||||
:options {:insets {:top? true}}
|
||||
;;TODO custom subtitle
|
||||
:component group-chat/new-group}
|
||||
|
||||
{:name :currency-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/main-currency)}}
|
||||
:options {:topBar (topbar-options :t/main-currency)
|
||||
:insets {:top? true}}
|
||||
:component currency-settings/currency-settings}
|
||||
|
||||
@@ -104,27 +102,27 @@
|
||||
:options {:topBar {:visible false}}
|
||||
:component profile.user/my-profile}
|
||||
{:name :contacts-list
|
||||
:options {:topBar {:title {:text (i18n/label :t/contacts)}}
|
||||
:options {:topBar (topbar-options :t/contacts)
|
||||
:insets {:top? true}}
|
||||
:component contacts-list/contacts-list}
|
||||
{:name :ens-main
|
||||
:options {:topBar {:title {:text (i18n/label :t/ens-usernames)}}
|
||||
:options {:topBar (topbar-options :t/ens-usernames)
|
||||
:insets {:top? true}}
|
||||
:component ens/main}
|
||||
{:name :ens-search
|
||||
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}}
|
||||
:options {:topBar (topbar-options :t/ens-your-username)
|
||||
:insets {:top? true}}
|
||||
:component ens/search}
|
||||
{:name :ens-checkout
|
||||
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}}
|
||||
:options {:topBar (topbar-options :t/ens-your-username)
|
||||
:insets {:top? true}}
|
||||
:component ens/checkout}
|
||||
{:name :ens-confirmation
|
||||
:options {:topBar {:title {:text (i18n/label :t/ens-your-username)}}
|
||||
:options {:topBar (topbar-options :t/ens-your-username)
|
||||
:insets {:top? true}}
|
||||
:component ens/confirmation}
|
||||
{:name :ens-terms
|
||||
:options {:topBar {:title {:text (i18n/label :t/ens-terms-registration)}}
|
||||
:options {:topBar (topbar-options :t/ens-terms-registration)
|
||||
:insets {:top? true}}
|
||||
:component ens/terms}
|
||||
{:name :ens-name-details
|
||||
@@ -132,7 +130,7 @@
|
||||
:options {:insets {:top? true}}
|
||||
:component ens/name-details}
|
||||
{:name :blocked-users-list
|
||||
:options {:topBar {:title {:text (i18n/label :t/blocked-users)}}
|
||||
:options {:topBar (topbar-options :t/blocked-users)
|
||||
:insets {:top? true}}
|
||||
:component contacts-list/blocked-users-list}
|
||||
{:name :wakuv2-settings
|
||||
@@ -148,7 +146,7 @@
|
||||
:options {:insets {:top? true}}
|
||||
:component bootnodes-settings/bootnodes-settings}
|
||||
{:name :installations
|
||||
:options {:topBar {:title {:text (i18n/label :t/devices)}}
|
||||
:options {:topBar (topbar-options (i18n/label :t/devices))
|
||||
:insets {:top? true}}
|
||||
:component pairing/installations}
|
||||
{:name :edit-bootnode
|
||||
@@ -164,107 +162,91 @@
|
||||
:options {:insets {:top? true}}
|
||||
:component edit-mailserver/edit-mailserver}
|
||||
{:name :dapps-permissions
|
||||
:options {:topBar {:title {:text (i18n/label :t/dapps-permissions)}}
|
||||
:options {:topBar (topbar-options :t/dapps-permissions)
|
||||
:insets {:top? true}}
|
||||
:component dapps-permissions/dapps-permissions}
|
||||
{:name :privacy-and-security
|
||||
:options {:topBar {:title {:text (i18n/label :t/privacy-and-security)}}
|
||||
:options {:topBar (topbar-options :t/privacy-and-security)
|
||||
:insets {:top? true}}
|
||||
:component privacy-and-security/privacy-and-security}
|
||||
{:name :messages-from-contacts-only
|
||||
:options {:topBar {:title {:text (i18n/label :t/accept-new-chats-from)}}
|
||||
:options {:topBar (topbar-options :t/accept-new-chats-from)
|
||||
:insets {:top? true}}
|
||||
:component messages-from-contacts-only/messages-from-contacts-only-view}
|
||||
{:name :appearance
|
||||
:options {:topBar {:title {:text (i18n/label :t/appearance)}}
|
||||
:options {:topBar (topbar-options :t/appearance)
|
||||
:insets {:top? true}}
|
||||
:component appearance/appearance-view}
|
||||
{:name :privacy-and-security-profile-pic-show-to
|
||||
:options {:topbar {:title {:text (i18n/label :t/show-profile-pictures-to)}}
|
||||
:options {:topbar (topbar-options :t/show-profile-pictures-to)
|
||||
:insets {:top? true}}
|
||||
:component privacy-and-security/profile-pic-show-to}
|
||||
{:name :privacy-and-security-profile-pic
|
||||
:options {:topBar {:title {:text (i18n/label :t/show-profile-pictures)}}
|
||||
:options {:topBar (topbar-options :t/show-profile-pictures)
|
||||
:insets {:top? true}}
|
||||
:component privacy-and-security/profile-pic}
|
||||
{:name :notifications
|
||||
:options {:topBar {:title {:text (i18n/label :t/notification-settings)}}
|
||||
:options {:topBar (topbar-options :t/notification-settings)
|
||||
:insets {:top? true}}
|
||||
:component notifications-settings/notifications-settings}
|
||||
{:name :sync-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/sync-settings)}}
|
||||
:options {:topBar (topbar-options :t/sync-settings)
|
||||
:insets {:top? true}}
|
||||
:component sync-settings/sync-settings}
|
||||
{:name :advanced-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/advanced)}}
|
||||
:options {:topBar (topbar-options :t/advanced)
|
||||
:insets {:top? true}}
|
||||
:component advanced-settings/advanced-settings}
|
||||
{:name :help-center
|
||||
:options {:topBar {:title {:text (i18n/label :t/need-help)}}
|
||||
:options {:topBar (topbar-options :t/need-help)
|
||||
:insets {:top? true}}
|
||||
:component help-center/help-center}
|
||||
{:name :glossary
|
||||
:options {:topBar {:title {:text (i18n/label :t/glossary)}}
|
||||
:options {:topBar (topbar-options :t/glossary)
|
||||
:insets {:top? true}}
|
||||
:component glossary/glossary}
|
||||
{:name :about-app
|
||||
:options {:topBar {:title {:text (i18n/label :t/about-app)}}
|
||||
:options {:topBar (topbar-options :t/about-app)
|
||||
:insets {:top? true}}
|
||||
:component about-app/about-app}
|
||||
{:name :privacy-policy
|
||||
:options {:topBar {:title {:text (i18n/label :t/privacy-policy)}}
|
||||
:options {:topBar (topbar-options :t/privacy-policy)
|
||||
:insets {:top? true}}
|
||||
:component about-app/privacy-policy}
|
||||
{:name :terms-of-service
|
||||
:options {:topBar {:title {:text (i18n/label :t/terms-of-service)}}
|
||||
:options {:topBar (topbar-options :t/terms-of-service)
|
||||
:insets {:top? true}}
|
||||
:component about-app/tos}
|
||||
{:name :principles
|
||||
:options {:topBar {:title {:text (i18n/label :t/principles)}}
|
||||
:options {:topBar (topbar-options :t/principles)
|
||||
:insets {:top? true}}
|
||||
:component about-app/principles}
|
||||
{:name :manage-dapps-permissions
|
||||
;;TODO dynamic title
|
||||
:options {:insets {:top? true}}
|
||||
:component dapps-permissions/manage}
|
||||
{:name :network-settings
|
||||
;;TODO accessories
|
||||
:options {:insets {:top? true}}
|
||||
:component network/network-settings}
|
||||
{:name :network-details
|
||||
:options {:topBar {:title {:text (i18n/label :t/network-details)}}
|
||||
:insets {:top? true}}
|
||||
:component network-details/network-details}
|
||||
{:name :network-info
|
||||
:options {:topBar {:title {:text (i18n/label :t/network-info)}}
|
||||
:insets {:top? true}}
|
||||
:component network-info/network-info}
|
||||
{:name :rpc-usage-info
|
||||
:options {:topBar {:title {:text (i18n/label :t/rpc-usage-info)}}
|
||||
:options {:topBar (topbar-options :t/rpc-usage-info)
|
||||
:insets {:top? true}}
|
||||
:component rpc-usage-info/usage-info}
|
||||
{:name :peers-stats
|
||||
:options {:topBar {:title {:text (i18n/label :t/peers-stats)}}
|
||||
:options {:topBar (topbar-options :t/peers-stats)
|
||||
:insets {:top? true}}
|
||||
:component peers-stats/peers-stats}
|
||||
{:name :edit-network
|
||||
:options {:topBar {:title {:text (i18n/label :t/add-network)}}
|
||||
:insets {:top? true}}
|
||||
:component edit-network/edit-network}
|
||||
{:name :log-level-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/log-level-settings)}}
|
||||
:options {:topBar (topbar-options :t/log-level-settings)
|
||||
:insets {:top? true}}
|
||||
:component log-level-settings/log-level-settings}
|
||||
{:name :fleet-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/fleet-settings)}}
|
||||
:options {:topBar (topbar-options :t/fleet-settings)
|
||||
:insets {:top? true}}
|
||||
:component fleet-settings/fleet-settings}
|
||||
{:name :mobile-network-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/mobile-network-settings)}}
|
||||
:options {:topBar (topbar-options :t/mobile-network-settings)
|
||||
:insets {:top? true}}
|
||||
:component mobile-network-settings/mobile-network-settings}
|
||||
{:name :backup-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/backup-settings)}}
|
||||
:options {:topBar (topbar-options :t/backup-settings)
|
||||
:insets {:top? true}}
|
||||
:component backup-settings/backup-settings}
|
||||
{:name :backup-seed
|
||||
@@ -272,14 +254,14 @@
|
||||
:options {:insets {:top? true}}
|
||||
:component profile.seed/backup-seed}
|
||||
{:name :reset-password
|
||||
:options {:topBar {:title {:text (i18n/label :t/reset-password)}}
|
||||
:options {:topBar (topbar-options :t/reset-password)
|
||||
:insets {:top? true}}
|
||||
:component reset-password/reset-password}
|
||||
{:name :delete-profile
|
||||
:insets {:bottom? true}
|
||||
:component delete-profile/delete-profile}
|
||||
{:name :default-sync-period-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/default-sync-period)}}
|
||||
:options {:topBar (topbar-options :t/default-sync-period)
|
||||
:insets {:top? true}}
|
||||
:component default-sync-period-settings/default-sync-period-settings}
|
||||
|
||||
@@ -288,7 +270,7 @@
|
||||
;[Chat] Link preview settings
|
||||
|
||||
{:name :link-previews-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/chat-link-previews)}}
|
||||
:options {:topBar (topbar-options :t/chat-link-previews)
|
||||
:insets {:top? true}}
|
||||
:component link-previews-settings/link-previews-settings}
|
||||
|
||||
@@ -328,7 +310,7 @@
|
||||
;;TODO WHY MODAL?
|
||||
;[Profile] Notifications settings
|
||||
{:name :notifications-settings
|
||||
:options {:topBar {:title {:text (i18n/label :t/notification-settings)}}
|
||||
:options {:topBar (topbar-options :t/notification-settings)
|
||||
:popGesture false
|
||||
:hardwareBackButton {:dismissModalOnPress false
|
||||
:popStackOnPress false}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.mail :as react-native-mail]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.log :as log]
|
||||
[status-im.config :as config]
|
||||
[utils.datetime :as datetime]
|
||||
@@ -31,11 +32,10 @@
|
||||
[{:keys [db]} node-version]
|
||||
{:db (assoc db :web3-node-version node-version)})
|
||||
|
||||
(rf/defn initialize-web3-client-version
|
||||
{:events [:logging/initialize-web3-client-version]}
|
||||
[_]
|
||||
{:json-rpc/call [{:method "web3_clientVersion"
|
||||
:on-success #(re-frame/dispatch [:logging/store-web3-client-version %])}]})
|
||||
(re-frame/reg-fx :logging/initialize-web3-client-version
|
||||
(fn []
|
||||
(json-rpc/call {:method "web3_clientVersion"
|
||||
:on-success [:logging/store-web3-client-version]})))
|
||||
|
||||
(defn extract-url-components
|
||||
[address]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
(= network-type "cellular"))
|
||||
|
||||
(defn syncing-allowed?
|
||||
[{:keys [db]}]
|
||||
[db]
|
||||
(let [network (:network/type db)
|
||||
{:keys [syncing-on-mobile-network?]} (:profile/profile db)]
|
||||
(or (= network "wifi")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
(:require-macros [legacy.status-im.utils.slurp :refer [slurp]])
|
||||
(:require
|
||||
[legacy.status-im.fleet.default-fleet :refer (default-fleets)])
|
||||
(:require [legacy.status-im.utils.test :as utils.test]))
|
||||
(:require [tests.test-utils :as utils.test]))
|
||||
|
||||
;; to generate a js Proxy at js/__STATUS_MOBILE_JS_IDENTITY_PROXY__ that accept any (.xxx) call and
|
||||
;; return itself
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(defn- get-dimensions
|
||||
[size]
|
||||
(case size
|
||||
:size-24 24
|
||||
:size-20 20
|
||||
nil))
|
||||
|
||||
(defn collection-avatar
|
||||
[theme]
|
||||
{:width 24
|
||||
:height 24
|
||||
[theme size]
|
||||
{:width (get-dimensions size)
|
||||
:height (get-dimensions size)
|
||||
:border-width 1
|
||||
:border-color (colors/theme-colors colors/neutral-80-opa-10 colors/white-opa-10 theme)
|
||||
:border-radius 6})
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
:image - collection image
|
||||
:theme - keyword -> :light/:dark"
|
||||
[{:keys [image theme]}]
|
||||
[{:keys [image theme size] :or {size :size-24}}]
|
||||
[fast-image/fast-image
|
||||
{:accessibility-label :collection-avatar
|
||||
:source image
|
||||
:style (style/collection-avatar theme)}])
|
||||
:style (style/collection-avatar theme size)}])
|
||||
|
||||
(def view (quo.theme/with-theme view-internal))
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
:or {size :size-20
|
||||
customization-color :blue
|
||||
picture nil
|
||||
icon-name :i/group}}]
|
||||
icon-name :i/members}}]
|
||||
(let [container-size (get-in sizes [size :container])
|
||||
icon-size (get-in sizes [size :icon])]
|
||||
[rn/view
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns quo.components.colors.color-picker.component-spec
|
||||
(:require
|
||||
[quo.components.colors.color-picker.view :as color-picker]
|
||||
[reagent.core :as reagent]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "color-picker"
|
||||
@@ -12,7 +11,7 @@
|
||||
(-> (h/expect event)
|
||||
(.toHaveBeenCalled))))
|
||||
(h/test "color picker color changed"
|
||||
(let [selected (reagent/atom nil)]
|
||||
(let [selected (atom nil)]
|
||||
(h/render [color-picker/view {:on-change #(reset! selected %)}])
|
||||
(h/fire-event :press (get (h/get-all-by-label-text :color-picker-item) 0))
|
||||
(-> (h/expect @selected)
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
[quo.components.colors.color.constants :as constants]
|
||||
[quo.components.colors.color.view :as color]
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[react-native.gesture :as gesture]))
|
||||
|
||||
(defn get-item-layout
|
||||
[_ index]
|
||||
@@ -52,7 +53,7 @@
|
||||
:index index
|
||||
:viewPosition 0.5})))))
|
||||
50)))
|
||||
[rn/flat-list
|
||||
[gesture/flat-list
|
||||
{:ref on-ref
|
||||
;; TODO: using :feng-shui? temporarily while b & w is being developed.
|
||||
;; https://github.com/status-im/status-mobile/discussions/16676
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
(ns quo.components.community.channel-action.style
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(defn channel-action-container
|
||||
[{:keys [big? disabled?]}]
|
||||
(cond-> {}
|
||||
disabled? (assoc :opacity 0.3)
|
||||
big? (assoc :flex-grow 1)
|
||||
(not big?) (assoc :width 104)))
|
||||
|
||||
(defn channel-action
|
||||
[{:keys [color pressed? theme]}]
|
||||
{:height 102
|
||||
:padding 12
|
||||
:border-radius 16
|
||||
:background-color (colors/resolve-color color theme (if pressed? 20 10))
|
||||
:justify-content :space-between})
|
||||
|
||||
(def channel-action-row
|
||||
{:flex-direction :row
|
||||
:justify-content :space-between
|
||||
:align-items :center})
|
||||
@@ -0,0 +1,39 @@
|
||||
(ns quo.components.community.channel-action.view
|
||||
(:require
|
||||
[quo.components.community.channel-action.style :as style]
|
||||
[quo.components.counter.counter.view :as counter]
|
||||
[quo.components.icon :as icons]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [big? customization-color label counter-value icon on-press accessibility-label disabled?]}]
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
[pressed? set-pressed] (rn/use-state false)
|
||||
on-press-in (rn/use-callback #(set-pressed true))
|
||||
on-press-out (rn/use-callback #(set-pressed false))]
|
||||
[rn/view
|
||||
{:style (style/channel-action-container
|
||||
{:big? big?
|
||||
:disabled? disabled?})}
|
||||
[rn/pressable
|
||||
(cond-> {:style (style/channel-action
|
||||
{:big? big?
|
||||
:color customization-color
|
||||
:pressed? pressed?
|
||||
:theme theme
|
||||
:disabled? disabled?})
|
||||
:accessibility-label accessibility-label}
|
||||
(not disabled?) (assoc :on-press on-press
|
||||
:on-press-in on-press-in
|
||||
:on-press-out on-press-out))
|
||||
[rn/view {:style style/channel-action-row}
|
||||
[icons/icon icon]
|
||||
(when counter-value
|
||||
[counter/view {:type :secondary} counter-value])]
|
||||
[text/text
|
||||
{:size :paragraph-1
|
||||
:weight :medium
|
||||
:number-of-lines 2}
|
||||
label]]]))
|
||||
@@ -1,32 +0,0 @@
|
||||
(ns quo.components.community.channel-actions
|
||||
(:require
|
||||
[quo.components.community.style :as style]
|
||||
[quo.components.counter.counter.view :as counter]
|
||||
[quo.components.icon :as icons]
|
||||
[quo.components.markdown.text :as text]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn channel-action
|
||||
[{:keys [big? color label counter-value icon on-press accessibility-label]}]
|
||||
[rn/touchable-opacity
|
||||
{:on-press on-press
|
||||
:style (style/channel-action-touch big?)
|
||||
:accessibility-label accessibility-label}
|
||||
[rn/view {:style (style/channel-action color)}
|
||||
[rn/view {:style style/channel-action-row}
|
||||
[icons/icon icon]
|
||||
(when counter-value
|
||||
[counter/view {:type :secondary} counter-value])]
|
||||
[text/text {:size :paragraph-1 :weight :medium :number-of-lines 2} label]]])
|
||||
|
||||
(defn channel-actions
|
||||
[{:keys [style actions]}]
|
||||
[rn/view {:style (merge {:flex-direction :row :flex 1} style)}
|
||||
(map-indexed
|
||||
(fn [index action]
|
||||
^{:key index}
|
||||
[:<>
|
||||
[channel-action action]
|
||||
(when (not= action (last actions))
|
||||
[rn/view {:width 16}])])
|
||||
actions)])
|
||||
@@ -0,0 +1,16 @@
|
||||
(ns quo.components.community.channel-actions.view
|
||||
(:require
|
||||
[quo.components.community.channel-action.view :as channel-action]
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [container-style actions]}]
|
||||
[rn/view {:style (assoc container-style :flex-direction :row)}
|
||||
(map-indexed
|
||||
(fn [index action]
|
||||
^{:key index}
|
||||
[:<>
|
||||
[channel-action/view action]
|
||||
(when (not= action (last actions))
|
||||
[rn/view {:width 16}])])
|
||||
actions)])
|
||||
@@ -133,25 +133,6 @@
|
||||
colors/neutral-80
|
||||
theme)})
|
||||
|
||||
(defn channel-action-touch
|
||||
[big?]
|
||||
{:flex 1
|
||||
:max-width (if big? 216 104)})
|
||||
|
||||
(defn channel-action
|
||||
[color]
|
||||
{:padding 12
|
||||
:height 102
|
||||
:flex 1
|
||||
:border-radius 16
|
||||
:background-color (colors/custom-color color 50 10)
|
||||
:justify-content :space-between})
|
||||
|
||||
(def channel-action-row
|
||||
{:flex-direction :row
|
||||
:justify-content :space-between
|
||||
:align-items :center})
|
||||
|
||||
(defn loading-card
|
||||
[width theme]
|
||||
(merge
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[:catn
|
||||
[:props
|
||||
[:map {:closed true}
|
||||
[:container-style {:optional true} [:maybe :map]]
|
||||
[:value {:optional true} [:maybe [:or :string :int]]]
|
||||
[:status {:optional true} [:maybe :keyword]]
|
||||
[:size {:optional true} [:maybe [:enum :size-32 :size-24]]]
|
||||
@@ -19,7 +20,7 @@
|
||||
:any])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [value accessibility-label]
|
||||
[{:keys [value accessibility-label container-style]
|
||||
:as props}]
|
||||
(let [default-props {:status :default
|
||||
:size :size-32}
|
||||
@@ -27,7 +28,7 @@
|
||||
[rn/view
|
||||
{:accessible true
|
||||
:accessibility-label (or accessibility-label :collectible-counter)
|
||||
:style (style/container props)}
|
||||
:style (merge (style/container props) container-style)}
|
||||
[text/text
|
||||
{:weight :medium
|
||||
:size (style/get-text-size props)
|
||||
|
||||
@@ -58,14 +58,15 @@
|
||||
:on-press on-press}
|
||||
[rn/view
|
||||
{:style (style/row-container sub-label)}
|
||||
[rn/view
|
||||
{:accessibility-label :left-icon-for-action
|
||||
:accessible true
|
||||
:style (style/left-icon sub-label)}
|
||||
[icon/icon icon
|
||||
{:color (or icon-color (get-icon-color danger? theme))
|
||||
:no-color no-icon-color?
|
||||
:size 20}]]
|
||||
(when icon
|
||||
[rn/view
|
||||
{:accessibility-label :left-icon-for-action
|
||||
:accessible true
|
||||
:style (style/left-icon sub-label)}
|
||||
[icon/icon icon
|
||||
{:color (or icon-color (get-icon-color danger? theme))
|
||||
:no-color no-icon-color?
|
||||
:size 20}]])
|
||||
[rn/view
|
||||
{:style style/text-container}
|
||||
[text/text
|
||||
|
||||
@@ -59,4 +59,15 @@
|
||||
:button-one-label "Request to join"}])
|
||||
(h/is-truthy (h/get-by-text "Eligible to join as"))
|
||||
(h/is-truthy (h/get-by-text "Admin"))
|
||||
(h/is-truthy (h/get-by-text "Request to join")))
|
||||
|
||||
(h/test "render with top description with custom text & 1 action"
|
||||
(render [bottom-actions/view
|
||||
{:description :top
|
||||
:role :admin
|
||||
:actions :one-action
|
||||
:description-top-text "You'll be an"
|
||||
:button-one-label "Request to join"}])
|
||||
(h/is-truthy (h/get-by-text "You'll be an"))
|
||||
(h/is-truthy (h/get-by-text "Admin"))
|
||||
(h/is-truthy (h/get-by-text "Request to join"))))
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
[:actions [:maybe [:enum :one-action :two-actions]]]
|
||||
[:description {:optional true} [:maybe [:enum :top :bottom :top-error]]]
|
||||
[:description-text {:optional true} [:maybe :string]]
|
||||
[:description-top-text {:optional true} [:maybe :string]]
|
||||
[:error-message {:optional true} [:maybe :string]]
|
||||
[:role {:optional true} [:maybe [:enum :admin :member :token-master :owner]]]
|
||||
[:button-one-label {:optional true} [:maybe :string]]
|
||||
@@ -38,8 +39,8 @@
|
||||
:owner :i/crown})
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [actions description description-text error-message role button-one-label button-two-label
|
||||
blur? button-one-props button-two-props theme scroll? container-style]}]
|
||||
[{:keys [actions description description-text description-top-text error-message role button-one-label
|
||||
button-two-label blur? button-one-props button-two-props theme scroll? container-style]}]
|
||||
[rn/view
|
||||
{:style (merge (style/container scroll? blur? theme) container-style)}
|
||||
(when (= description :top-error)
|
||||
@@ -54,12 +55,11 @@
|
||||
error-message]])
|
||||
|
||||
(when (and (= description :top) role)
|
||||
[rn/view
|
||||
{:style style/description-top}
|
||||
[rn/view {:style style/description-top}
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:style (style/description-top-text scroll? blur? theme)}
|
||||
(i18n/label :t/eligible-to-join-as)]
|
||||
(or description-top-text (i18n/label :t/eligible-to-join-as))]
|
||||
[context-tag/view
|
||||
{:type :icon
|
||||
:size 24
|
||||
|
||||
@@ -76,7 +76,8 @@
|
||||
(str description " · " (i18n/label :t/on-device))])
|
||||
|
||||
(defn- context-tag-subtitle
|
||||
[{:keys [context-tag-type community-logo community-name account-name emoji customization-color]}]
|
||||
[{:keys [context-tag-type community-logo community-name account-name emoji customization-color
|
||||
full-name profile-picture]}]
|
||||
(let [tag-type (or context-tag-type :account)]
|
||||
[rn/view
|
||||
{:accessibility-label :context-tag-wrapper
|
||||
@@ -88,7 +89,9 @@
|
||||
:community-name community-name
|
||||
:community-logo community-logo
|
||||
:size 24
|
||||
:customization-color customization-color}]]))
|
||||
:customization-color customization-color
|
||||
:profile-picture profile-picture
|
||||
:full-name full-name}]]))
|
||||
|
||||
(defn- description-subtitle
|
||||
[{:keys [theme blur? description]}]
|
||||
@@ -100,7 +103,7 @@
|
||||
|
||||
(defn- subtitle
|
||||
[{:keys [type theme blur? keycard? networks description community-name community-logo
|
||||
context-tag-type account-name emoji customization-color]}]
|
||||
context-tag-type account-name emoji customization-color full-name profile-picture]}]
|
||||
(cond
|
||||
(= :keypair type)
|
||||
[keypair-subtitle
|
||||
@@ -128,7 +131,9 @@
|
||||
:community-name community-name
|
||||
:account-name account-name
|
||||
:emoji emoji
|
||||
:customization-color customization-color}]
|
||||
:customization-color customization-color
|
||||
:profile-picture profile-picture
|
||||
:full-name full-name}]
|
||||
|
||||
(and (not= :label type) description)
|
||||
[description-subtitle
|
||||
@@ -187,7 +192,7 @@
|
||||
on-button-press
|
||||
on-button-long-press
|
||||
button-disabled? account-avatar-emoji account-avatar-type customization-color icon-avatar
|
||||
profile-picture keycard? networks label]}]
|
||||
profile-picture keycard? networks label full-name]}]
|
||||
[rn/view {:style style/container}
|
||||
(when (left-image-supported-types type)
|
||||
[rn/view {:style style/left-container}
|
||||
@@ -218,7 +223,9 @@
|
||||
:context-tag-type context-tag-type
|
||||
:customization-color customization-color
|
||||
:account-name account-name
|
||||
:emoji emoji}]]
|
||||
:emoji emoji
|
||||
:full-name full-name
|
||||
:profile-picture profile-picture}]]
|
||||
[right-icon
|
||||
{:theme theme
|
||||
:type type
|
||||
|
||||
@@ -2,5 +2,10 @@
|
||||
|
||||
(defn root-container
|
||||
[opacity height]
|
||||
{:height (or height 252)
|
||||
:opacity opacity})
|
||||
{:height (or height 252)
|
||||
:opacity opacity
|
||||
:position :absolute
|
||||
:top 0
|
||||
:left 0
|
||||
:right 0
|
||||
:z-index -1})
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
;; the `:or` destructuring won't work because it's only applied when the
|
||||
;; `:customization-color` key is non-existent. While deleting an account the key exists
|
||||
;; and has a `nil` value.
|
||||
(when customization-color
|
||||
(let [color-top (colors/resolve-color customization-color 50 20)
|
||||
color-bottom (colors/resolve-color customization-color 50 0)]
|
||||
(let [color-top (colors/resolve-color customization-color 50 20)
|
||||
color-bottom (colors/resolve-color customization-color 50 0)]
|
||||
(when (and color-top color-bottom)
|
||||
[linear-gradient/linear-gradient
|
||||
{:accessibility-label :gradient-cover
|
||||
:colors [color-top color-bottom]
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.reanimated :as reanimated]
|
||||
[reagent.core :as reagent]))
|
||||
[react-native.reanimated :as reanimated]))
|
||||
|
||||
(def header-height 56)
|
||||
|
||||
@@ -57,7 +56,7 @@
|
||||
:justify-content :center
|
||||
:align-items :flex-end})
|
||||
|
||||
(defn title-style
|
||||
(defn get-title-style
|
||||
[{:keys [left right]} title-align]
|
||||
(merge
|
||||
absolute-fill
|
||||
@@ -133,76 +132,77 @@
|
||||
:size :large}
|
||||
title])])
|
||||
|
||||
(defn- header-internal
|
||||
[{:keys [left-width right-width]}]
|
||||
(let [layout (reagent/atom {:left {:width (or left-width 8)
|
||||
:height header-height}
|
||||
:right {:width (or right-width 8)
|
||||
:height header-height}
|
||||
:title {:width 0
|
||||
:height header-height}})
|
||||
handle-layout (fn [el get-layout]
|
||||
(fn [evt]
|
||||
(let [width (oget evt "nativeEvent" "layout" "width")
|
||||
height (oget evt "nativeEvent" "layout" "height")]
|
||||
(when get-layout
|
||||
(get-layout el
|
||||
{:width width
|
||||
:height height}))
|
||||
(swap! layout assoc
|
||||
el
|
||||
{:width width
|
||||
:height height}))))]
|
||||
(fn
|
||||
[{:keys [left-accessories left-component border-bottom
|
||||
right-accessories right-component insets get-layout
|
||||
title subtitle title-component style title-align
|
||||
background theme]
|
||||
:or {title-align :center
|
||||
border-bottom false}}]
|
||||
(let [status-bar-height (get insets :top 0)
|
||||
height (+ header-height status-bar-height)]
|
||||
[reanimated/view
|
||||
{:style (header-wrapper-style {:height height
|
||||
:background background
|
||||
:border-bottom border-bottom
|
||||
:theme theme})}
|
||||
[rn/view
|
||||
{:pointer-events :box-none
|
||||
:height status-bar-height}]
|
||||
[rn/view
|
||||
{:style (merge {:height header-height}
|
||||
style)
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style absolute-fill
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style content
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style left-style
|
||||
:on-layout (handle-layout :left get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-actions
|
||||
{:accessories left-accessories
|
||||
:component left-component}]]
|
||||
|
||||
[rn/view
|
||||
{:style (title-style @layout title-align)
|
||||
:on-layout (handle-layout :title get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-title
|
||||
{:title title
|
||||
:subtitle subtitle
|
||||
:title-align title-align
|
||||
:component title-component}]]
|
||||
[rn/view
|
||||
{:style right-style
|
||||
:on-layout (handle-layout :right get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-actions
|
||||
{:accessories right-accessories
|
||||
:component right-component}]]]]]]))))
|
||||
|
||||
(def header (quo.theme/with-theme header-internal))
|
||||
(defn header
|
||||
[{:keys [left-accessories left-component border-bottom left-width right-width
|
||||
right-accessories right-component insets get-layout
|
||||
title subtitle title-component style title-align
|
||||
background]
|
||||
:or {title-align :center
|
||||
border-bottom false}}]
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
[layout set-layout] (rn/use-state {:left {:width (or left-width 8)
|
||||
:height header-height}
|
||||
:right {:width (or right-width 8)
|
||||
:height header-height}
|
||||
:title {:width 0
|
||||
:height header-height}})
|
||||
handle-layout (rn/use-callback
|
||||
(fn [el get-layout]
|
||||
(fn [evt]
|
||||
(let [width (oget evt "nativeEvent" "layout" "width")
|
||||
height (oget evt "nativeEvent" "layout" "height")]
|
||||
(when get-layout
|
||||
(get-layout el
|
||||
{:width width
|
||||
:height height}))
|
||||
(set-layout
|
||||
(assoc layout
|
||||
el
|
||||
{:width width
|
||||
:height height})))))
|
||||
[layout])
|
||||
status-bar-height (get insets :top 0)
|
||||
height (+ header-height status-bar-height)
|
||||
title-style (rn/use-memo (fn [] (get-title-style layout title-align))
|
||||
[layout title-align])]
|
||||
[reanimated/view
|
||||
{:style (header-wrapper-style {:height height
|
||||
:background background
|
||||
:border-bottom border-bottom
|
||||
:theme theme})}
|
||||
[rn/view
|
||||
{:pointer-events :box-none
|
||||
:height status-bar-height}]
|
||||
[rn/view
|
||||
{:style (merge {:height header-height}
|
||||
style)
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style absolute-fill
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style content
|
||||
:pointer-events :box-none}
|
||||
[rn/view
|
||||
{:style left-style
|
||||
:on-layout (handle-layout :left get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-actions
|
||||
{:accessories left-accessories
|
||||
:component left-component}]]
|
||||
[rn/view
|
||||
{:style title-style
|
||||
:on-layout (handle-layout :title get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-title
|
||||
{:title title
|
||||
:subtitle subtitle
|
||||
:title-align title-align
|
||||
:component title-component}]]
|
||||
[rn/view
|
||||
{:style right-style
|
||||
:on-layout (handle-layout :right get-layout)
|
||||
:pointer-events :box-none}
|
||||
[header-actions
|
||||
{:accessories right-accessories
|
||||
:component right-component}]]]]]]))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(def ^:private themes
|
||||
{:light {:default {:bg colors/white
|
||||
{:light {:default {:bg colors/neutral-5
|
||||
:border colors/neutral-20
|
||||
:icon colors/neutral-50
|
||||
:text colors/neutral-100}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
(h/fire-event :on-blur (h/get-by-label-text :address-text-input))
|
||||
(h/has-prop (h/get-by-label-text :address-text-input)
|
||||
:placeholder-text-color
|
||||
colors/neutral-30))))))
|
||||
colors/neutral-40))))))
|
||||
|
||||
(h/test "on blur with text blur? true"
|
||||
(with-redefs [clipboard/get-string #(% "")]
|
||||
@@ -75,7 +75,7 @@
|
||||
(h/fire-event :on-blur (h/get-by-label-text :address-text-input))
|
||||
(h/has-prop (h/get-by-label-text :address-text-input)
|
||||
:placeholder-text-color
|
||||
colors/neutral-80-opa-20))))))
|
||||
colors/neutral-80-opa-40))))))
|
||||
|
||||
(h/test "on blur with no text and blur? false"
|
||||
(with-redefs [clipboard/get-string #(% "")]
|
||||
|
||||
@@ -58,78 +58,64 @@
|
||||
[{:keys [default-value blur? on-change-text on-blur on-focus on-clear on-scan
|
||||
on-detect-ens on-detect-address on-detect-unclassified address-regex ens-regex
|
||||
valid-ens-or-address? container-style]}]
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
[status set-status] (rn/use-state :default)
|
||||
value (rn/use-ref-atom nil)
|
||||
[_ trigger-render-value] (rn/use-state @value)
|
||||
[focused? set-focused] (rn/use-state false)
|
||||
on-change (rn/use-callback
|
||||
(fn [text]
|
||||
(let [address? (when address-regex
|
||||
(boolean (re-matches address-regex text)))
|
||||
ens? (when ens-regex
|
||||
(boolean (re-matches ens-regex text)))]
|
||||
(reset! value text)
|
||||
(if (> (count text) 0)
|
||||
(set-status :typing)
|
||||
(set-status :active))
|
||||
(when on-change-text
|
||||
(on-change-text text))
|
||||
(when (and on-detect-ens ens?)
|
||||
(set-status :loading)
|
||||
(on-detect-ens text #(set-status :typing)))
|
||||
(when (and address? on-detect-address)
|
||||
(set-status :loading)
|
||||
(on-detect-address text))
|
||||
(when (and (not address?)
|
||||
(not ens?)
|
||||
on-detect-unclassified)
|
||||
(on-detect-unclassified text)))))
|
||||
set-value (rn/use-callback
|
||||
(fn [new-value]
|
||||
(reset! value new-value)
|
||||
(on-change new-value)
|
||||
(trigger-render-value new-value)))
|
||||
on-paste (rn/use-callback
|
||||
(fn []
|
||||
(clipboard/get-string
|
||||
(fn [clipboard]
|
||||
(when-not (empty? clipboard)
|
||||
(set-value clipboard))))))
|
||||
on-clear (rn/use-callback
|
||||
(fn []
|
||||
(set-value "")
|
||||
(set-status (if focused? :active :default))
|
||||
(when on-change-text
|
||||
(on-change-text ""))
|
||||
(when on-clear
|
||||
(on-clear)))
|
||||
[focused?])
|
||||
on-clear (rn/use-callback
|
||||
(fn []
|
||||
(set-value "")
|
||||
(set-status (if focused? :active :default))
|
||||
(when on-change-text
|
||||
(on-change-text ""))
|
||||
(when on-clear
|
||||
(on-clear)))
|
||||
[focused?])
|
||||
on-scan (when on-scan (rn/use-callback #(on-scan set-value)))
|
||||
on-focus (rn/use-callback
|
||||
(fn []
|
||||
(when (= (count @value) 0)
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
[status set-status] (rn/use-state :default)
|
||||
[value set-value] (rn/use-state nil)
|
||||
[focused? set-focused] (rn/use-state false)
|
||||
on-change (rn/use-callback
|
||||
(fn [text]
|
||||
(let [address? (when address-regex
|
||||
(boolean (re-matches address-regex text)))
|
||||
ens? (when ens-regex
|
||||
(boolean (re-matches ens-regex text)))]
|
||||
(set-value text)
|
||||
(if (> (count text) 0)
|
||||
(set-status :typing)
|
||||
(set-status :active))
|
||||
(set-focused true)
|
||||
(when on-focus (on-focus))))
|
||||
on-blur (rn/use-callback
|
||||
(fn []
|
||||
(when (= status :active)
|
||||
(set-status :default))
|
||||
(set-focused false)
|
||||
(when on-blur (on-blur)))
|
||||
[status])
|
||||
placeholder-text-color (rn/use-memo #(get-placeholder-text-color status theme blur?)
|
||||
[status theme blur?])]
|
||||
(when on-change-text
|
||||
(on-change-text text))
|
||||
(when (and on-detect-ens ens?)
|
||||
(set-status :loading)
|
||||
(on-detect-ens text #(set-status :typing)))
|
||||
(when (and address? on-detect-address)
|
||||
(set-status :loading)
|
||||
(on-detect-address text))
|
||||
(when (and (not address?)
|
||||
(not ens?)
|
||||
on-detect-unclassified)
|
||||
(on-detect-unclassified text)))))
|
||||
on-paste (rn/use-callback
|
||||
(fn []
|
||||
(clipboard/get-string
|
||||
(fn [clipboard]
|
||||
(when-not (empty? clipboard)
|
||||
(on-change clipboard))))))
|
||||
on-clear (rn/use-callback
|
||||
(fn []
|
||||
(on-change "")
|
||||
(set-status (if focused? :active :default))
|
||||
(when on-change-text
|
||||
(on-change-text ""))
|
||||
(when on-clear
|
||||
(on-clear)))
|
||||
[focused?])
|
||||
on-scan (rn/use-callback #(when on-scan (on-scan on-change))
|
||||
[on-scan])
|
||||
on-focus (rn/use-callback
|
||||
(fn []
|
||||
(when (= (count value) 0)
|
||||
(set-status :active))
|
||||
(set-focused true)
|
||||
(when on-focus (on-focus))))
|
||||
on-blur (rn/use-callback
|
||||
(fn []
|
||||
(when (= status :active)
|
||||
(set-status :default))
|
||||
(set-focused false)
|
||||
(when on-blur (on-blur)))
|
||||
[status])
|
||||
placeholder-text-color (rn/use-memo #(get-placeholder-text-color status theme blur?)
|
||||
[status theme blur?])]
|
||||
(rn/use-mount #(on-change (or default-value "")))
|
||||
[rn/view {:style (style/container container-style)}
|
||||
[rn/text-input
|
||||
@@ -137,7 +123,7 @@
|
||||
:style (style/input-text theme)
|
||||
:placeholder (i18n/label :t/name-ens-or-address)
|
||||
:placeholder-text-color placeholder-text-color
|
||||
:value @value
|
||||
:value value
|
||||
:auto-complete (when platform/ios? :off)
|
||||
:auto-capitalize :none
|
||||
:auto-correct false
|
||||
|
||||
@@ -55,16 +55,22 @@
|
||||
|
||||
(def ^:private custom-props
|
||||
"Custom properties that must be removed from properties map passed to InputText."
|
||||
[:type :blur? :theme :error? :right-icon :left-icon :disabled? :small? :button
|
||||
[:type :blur? :error? :right-icon :left-icon :disabled? :small? :button
|
||||
:label :char-limit :on-char-limit-reach :icon-name :multiline? :on-focus :on-blur
|
||||
:container-style])
|
||||
:container-style :ref])
|
||||
|
||||
(defn- base-input
|
||||
[{:keys [blur? theme error? right-icon left-icon disabled? small? button
|
||||
[{:keys [blur? error? right-icon left-icon disabled? small? button
|
||||
label char-limit multiline? clearable? on-focus on-blur container-style
|
||||
on-change-text on-char-limit-reach weight default-value]
|
||||
on-change-text on-char-limit-reach weight default-value on-clear]
|
||||
:as props}]
|
||||
(let [[status set-status] (rn/use-state :default)
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
ref (rn/use-ref-atom nil)
|
||||
on-ref (rn/use-callback (fn [value]
|
||||
(when (:ref props)
|
||||
((:ref props) value))
|
||||
(reset! ref value)))
|
||||
[status set-status] (rn/use-state :default)
|
||||
internal-on-focus (rn/use-callback #(set-status :focus))
|
||||
internal-on-blur (rn/use-callback #(set-status :default))
|
||||
[multiple-lines?
|
||||
@@ -92,6 +98,15 @@
|
||||
:else status)
|
||||
colors-by-status (style/status-colors status-kw blur? theme)
|
||||
variant-colors (style/variants-colors blur? theme)
|
||||
clear-on-press (rn/use-callback (fn []
|
||||
(.clear ^js @ref)
|
||||
(when on-clear (on-clear)))
|
||||
[on-clear])
|
||||
right-icon (or right-icon
|
||||
(when clearable?
|
||||
{:style-fn style/clear-icon
|
||||
:icon-name :i/clear
|
||||
:on-press clear-on-press}))
|
||||
clean-props (apply dissoc props custom-props)]
|
||||
[rn/view {:style container-style}
|
||||
(when (or label char-limit)
|
||||
@@ -107,7 +122,8 @@
|
||||
:small? small?
|
||||
:icon-name icon-name}])
|
||||
[rn/text-input
|
||||
(cond-> {:style (style/input colors-by-status small? multiple-lines? weight)
|
||||
(cond-> {:ref on-ref
|
||||
:style (style/input colors-by-status small? multiple-lines? weight)
|
||||
:accessibility-label :input
|
||||
:placeholder-text-color (:placeholder colors-by-status)
|
||||
:keyboard-appearance (quo.theme/theme-value :light :dark theme)
|
||||
@@ -146,7 +162,10 @@
|
||||
[{:keys [default-shown?]
|
||||
:or {default-shown? false}
|
||||
:as props}]
|
||||
(let [[password-shown? set-password-shown] (rn/use-state default-shown?)]
|
||||
(let [[password-shown?
|
||||
set-password-shown] (rn/use-state default-shown?)
|
||||
on-press (rn/use-callback #(set-password-shown (not password-shown?))
|
||||
[password-shown?])]
|
||||
[base-input
|
||||
(assoc props
|
||||
:accessibility-label :password-input
|
||||
@@ -155,7 +174,7 @@
|
||||
:secure-text-entry (not password-shown?)
|
||||
:right-icon {:style-fn style/password-icon
|
||||
:icon-name (if password-shown? :i/hide-password :i/reveal)
|
||||
:on-press #(set-password-shown (not password-shown?))})]))
|
||||
:on-press on-press})]))
|
||||
|
||||
(defn input
|
||||
"This input supports the following properties:
|
||||
@@ -181,15 +200,11 @@
|
||||
- :on-change-text
|
||||
...
|
||||
"
|
||||
[{:keys [type clearable? on-clear icon-name]
|
||||
[{:keys [type icon-name]
|
||||
:or {type :text}
|
||||
:as props}]
|
||||
(let [base-props (cond-> props
|
||||
icon-name (assoc-in [:left-icon :icon-name] icon-name)
|
||||
clearable? (assoc :right-icon
|
||||
{:style-fn style/clear-icon
|
||||
:icon-name :i/clear
|
||||
:on-press #(when on-clear (on-clear))}))]
|
||||
icon-name (assoc-in [:left-icon :icon-name] icon-name))]
|
||||
(if (= type :password)
|
||||
[password-input base-props]
|
||||
[base-input base-props])))
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
:background-color (colors/theme-colors colors/neutral-10
|
||||
colors/neutral-80-opa-80
|
||||
theme)
|
||||
:height 40
|
||||
:min-height 40
|
||||
:padding-horizontal 12
|
||||
:padding-vertical 9
|
||||
:margin-top 4})
|
||||
|
||||
@@ -22,11 +22,12 @@
|
||||
(defn- locked-input-internal
|
||||
[{:keys [label icon container-style theme]} value]
|
||||
[rn/view {:style container-style}
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
|
||||
label]
|
||||
(when label
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}}
|
||||
label])
|
||||
[info-box
|
||||
{:theme theme
|
||||
:icon icon
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
:padding-horizontal 12
|
||||
:padding-top 10
|
||||
:padding-bottom 12
|
||||
:height (if (= :message size) 245 266)
|
||||
:width (if (= :message size) 295 335)})
|
||||
:width (if (= :message size) 295 335)
|
||||
:flex 1})
|
||||
|
||||
(def header-container
|
||||
{:flex-direction :row
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
{:title "Some title"
|
||||
:description "Some description"
|
||||
:link "status.im"
|
||||
:logo "data:image/png,logo-x"
|
||||
:thumbnail "data:image/png,whatever"})
|
||||
|
||||
(h/describe "Links - Link Preview"
|
||||
@@ -21,17 +20,12 @@
|
||||
(h/is-truthy (h/query-by-text (:title props)))
|
||||
(h/is-truthy (h/query-by-text (:description props)))
|
||||
(h/is-truthy (h/query-by-text (:link props)))
|
||||
(h/is-truthy (h/query-by-label-text :logo))
|
||||
(h/is-truthy (h/query-by-label-text :thumbnail)))
|
||||
|
||||
(h/test "does not render thumbnail if prop is not present"
|
||||
(h/render [view/view (dissoc props :thumbnail)])
|
||||
(h/is-null (h/query-by-label-text :thumbnail)))
|
||||
|
||||
(h/test "does not render logo if prop is not present"
|
||||
(h/render [view/view (dissoc props :logo)])
|
||||
(h/is-null (h/query-by-label-text :logo)))
|
||||
|
||||
(h/test "shows button to enable preview when preview is disabled"
|
||||
(h/render [view/view
|
||||
(assoc props
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
(ns quo.components.links.link-preview.view
|
||||
(:require
|
||||
["react-native-blob-util" :default ReactNativeBlobUtil]
|
||||
[oops.core :as oops]
|
||||
[quo.components.buttons.button.view :as button]
|
||||
[quo.components.links.link-preview.style :as style]
|
||||
[quo.components.markdown.text :as text]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[react-native.platform :as platform]
|
||||
[react-native.svg :as svg]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn- button-disabled
|
||||
[disabled-text on-enable]
|
||||
@@ -51,14 +56,30 @@
|
||||
thumbnail)
|
||||
:accessibility-label :thumbnail}])
|
||||
|
||||
(defn- get-image-data
|
||||
[logo set-is-svg on-success]
|
||||
(-> (.config ReactNativeBlobUtil (clj->js {:trusty platform/ios?}))
|
||||
(.fetch "GET" logo)
|
||||
(.then (fn [imgObj]
|
||||
(set-is-svg (= "image/svg"
|
||||
(oops/oget imgObj
|
||||
["respInfo" "headers" "Content-Type"])))
|
||||
(on-success (oops/oget imgObj "data"))))
|
||||
(.catch #(log/error "could not fetch favicon " logo))))
|
||||
|
||||
(defn- logo-comp
|
||||
[logo]
|
||||
[rn/image
|
||||
{:accessibility-label :logo
|
||||
:source (if (string? logo)
|
||||
{:uri logo}
|
||||
logo)
|
||||
:style style/logo}])
|
||||
(let [[image-data set-image-data] (rn/use-state nil)
|
||||
[is-svg? set-is-svg] (rn/use-state nil)
|
||||
on-success (fn [data-uri]
|
||||
(set-image-data data-uri))
|
||||
_get-image-data (get-image-data logo set-is-svg on-success)]
|
||||
(if is-svg?
|
||||
[svg/svg-xml (merge style/logo {:xml image-data})]
|
||||
[rn/image
|
||||
{:accessibility-label :logo
|
||||
:source {:uri (str "data:image/png;base64," image-data)}
|
||||
:style style/logo}])))
|
||||
|
||||
(defn view
|
||||
[{:keys [title logo description link thumbnail
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
:border-radius 12
|
||||
:border-style :dashed
|
||||
:align-items :center
|
||||
:flex-direction :row
|
||||
:justify-content :center
|
||||
:align-self :stretch
|
||||
:padding horizontal-padding
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
(ns quo.components.links.url-preview.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[quo.components.icon :as icon]
|
||||
[quo.components.links.url-preview.style :as style]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.core :as rn]))
|
||||
[react-native.core :as rn]
|
||||
[react-native.svg :as svg]))
|
||||
|
||||
(def base64-svg-prefix "data:image/svg;base64,")
|
||||
|
||||
(defn- logo-comp
|
||||
[{:keys [logo]}]
|
||||
[rn/image
|
||||
{:accessibility-label :logo
|
||||
:source (if (string? logo)
|
||||
{:uri logo}
|
||||
logo)
|
||||
:style style/logo}])
|
||||
(if (and (string? logo)
|
||||
(string/starts-with? logo base64-svg-prefix))
|
||||
[svg/svg-xml
|
||||
(merge style/logo
|
||||
{:xml (-> logo
|
||||
(string/replace base64-svg-prefix "")
|
||||
js/atob)})]
|
||||
[rn/image
|
||||
{:accessibility-label :logo
|
||||
:source (if (string? logo)
|
||||
{:uri logo}
|
||||
logo)
|
||||
:style style/logo
|
||||
:resize-mode :cover}]))
|
||||
|
||||
(defn- content
|
||||
[{:keys [title body]}]
|
||||
@@ -50,6 +62,10 @@
|
||||
[rn/view
|
||||
{:accessibility-label :url-preview-loading
|
||||
:style (merge (style/loading-container) container-style)}
|
||||
[icon/icon :i/loading
|
||||
{:size 12
|
||||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)
|
||||
:container-style {:margin-right 8}}]
|
||||
[rn/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
@@ -60,6 +76,9 @@
|
||||
{:accessibility-label :url-preview
|
||||
:style (merge (style/container) container-style)}
|
||||
(when logo
|
||||
[logo-comp {:logo logo}])
|
||||
[logo-comp
|
||||
{:logo (if (map? logo)
|
||||
(:data-uri logo)
|
||||
logo)}])
|
||||
[content {:title title :body body}]
|
||||
[clear-button {:on-press on-clear}]]))
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
[rn/view {:style style/url-preview-separator}])
|
||||
|
||||
(defn- item-component
|
||||
[{:keys [title body loading? logo]} _ _
|
||||
[{:keys [title body loading? logo url]} _ _
|
||||
{:keys [width on-clear loading-message container-style]}]
|
||||
[url-preview/view
|
||||
{:logo logo
|
||||
@@ -41,7 +41,8 @@
|
||||
:loading? loading?
|
||||
:loading-message loading-message
|
||||
:on-clear on-clear
|
||||
:container-style (merge container-style {:width width})}])
|
||||
:container-style (merge container-style {:width width})
|
||||
:url url}])
|
||||
|
||||
(defn- f-view
|
||||
[]
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:on-press {:optional true} [:maybe fn?]]
|
||||
[:theme :schema.common/theme]
|
||||
[:title-icon {:optional true} [:maybe :keyword]]
|
||||
[:account-props
|
||||
[:map
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[reagent.core :as reagent]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(defn- account-view
|
||||
@@ -97,41 +96,40 @@
|
||||
(colors/resolve-color customization-color theme))}]])
|
||||
|
||||
(defn- internal-view
|
||||
[_]
|
||||
(let [pressed? (reagent/atom false)
|
||||
on-press-in #(reset! pressed? true)
|
||||
on-press-out #(reset! pressed? false)]
|
||||
(fn [{:keys [type state blur? customization-color on-press]
|
||||
:or {customization-color :blue
|
||||
type :default
|
||||
state :default
|
||||
blur? false}
|
||||
:as props}]
|
||||
[rn/pressable
|
||||
{:style (style/container
|
||||
{:state state
|
||||
:blur? blur?
|
||||
:customization-color customization-color
|
||||
:pressed? @pressed?})
|
||||
:on-press-in on-press-in
|
||||
:on-press on-press
|
||||
:on-press-out on-press-out
|
||||
:accessibility-label :container}
|
||||
[account-view props]
|
||||
[rn/view {:style (when (= type :tag) style/token-tag-container)}
|
||||
(cond
|
||||
(#{:balance-neutral :balance-negative :balance-positive} type)
|
||||
[balance-view props]
|
||||
[{:keys [type state blur? customization-color on-press]
|
||||
:or {customization-color :blue
|
||||
type :default
|
||||
state :default
|
||||
blur? false}
|
||||
:as props}]
|
||||
(let [theme (quo.theme/use-theme-value)
|
||||
[pressed? set-pressed] (rn/use-state false)
|
||||
on-press-in (rn/use-callback #(set-pressed true))
|
||||
on-press-out (rn/use-callback #(set-pressed false))
|
||||
props (assoc props :theme theme)]
|
||||
[rn/pressable
|
||||
{:style (style/container
|
||||
{:state state
|
||||
:blur? blur?
|
||||
:customization-color customization-color
|
||||
:pressed? pressed?})
|
||||
:on-press-in on-press-in
|
||||
:on-press on-press
|
||||
:on-press-out on-press-out
|
||||
:accessibility-label :container}
|
||||
[account-view props]
|
||||
[rn/view {:style (when (= type :tag) style/token-tag-container)}
|
||||
(cond
|
||||
(#{:balance-neutral :balance-negative :balance-positive} type)
|
||||
[balance-view props]
|
||||
|
||||
(= type :tag)
|
||||
[token-tag props]
|
||||
(= type :tag)
|
||||
[token-tag props]
|
||||
|
||||
(= type :action)
|
||||
[options-button props]
|
||||
(= type :action)
|
||||
[options-button props]
|
||||
|
||||
(and (= type :default) (= state :selected))
|
||||
[check-icon props])]])))
|
||||
(and (= type :default) (= state :selected))
|
||||
[check-icon props])]]))
|
||||
|
||||
(def view
|
||||
(quo.theme/with-theme
|
||||
(schema/instrument #'internal-view component-schema/?schema)))
|
||||
(def view (schema/instrument #'internal-view component-schema/?schema))
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[:action {:optional true} [:enum :icon :none]]
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:on-press {:optional true} [:maybe fn?]]
|
||||
[:theme :schema.common/theme]
|
||||
[:account-props
|
||||
[:map {:closed true}
|
||||
[:type [:enum :default :watch-only]]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user