Commit Graph

58 Commits

Author SHA1 Message Date
Icaro Motta ca6fd3df66
Upgrade Clojure libraries (#17690)
Upgrades and cleans up all production Clojure dependencies and 1 dev-only
dependency (com.taoensso/tufte).

- Remove warning "WARNING: update-keys already refers to:
  #'clojure.core/update-keys in namespace: io.aviso.exception"
- Remove hickory and mvxcvi/alphabase dependencies they are not used.
- Upgrade com.taoensso/tufte from 2.1.0 to 2.6.3
- Upgrade transit-cljs from 0.8.248 to 0.8.280
- Upgrade cljs-bean from 1.3.0 to 1.9.0
- Remove workaround for com.taoensso/timbre in shadow-cljs.edn
- Upgrade com.taoensso/timbre from 4.10 (Status fork) to 6.3.1
2023-10-20 20:47:23 -03:00
flexsurfer 6f9bcd1bb1
rename quo2 (#17660) 2023-10-17 17:27:18 +02:00
flexsurfer b970b723a5
move legacy subs step 1 (#17648) 2023-10-16 15:47:20 +02:00
Icaro Motta 7f960f9be5
Add custom linter for i18n/label translation keywords (#17610)
This commit adds a custom linter to verify i18n/label is called with a qualified
keyword, like :t/foo. More sophisticated linters are possible too.

We also set the stage for other developers to consider more lint automation
instead of manually reviewing conventions in PRs.

If you want to understand how to write custom linters, check out
https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md. You can fire
the Clojure JVM REPL in status-mobile and play with the clj-kondo hook too, it
works beautifully.

Why do we care? By making sure all translation keywords are qualified with "t",
it is trivial to grep or replace them because they're unique in the repo, and
can't be confused with other words if you search by ":t/<something>".

Note: It's a best practice to commit clj-kondo configuration from external
libraries in the .clj-kondo directory. The directory .clj-kondo/babashka is
auto-generated, that's why it was added.
2023-10-11 18:53:34 -03:00
Icaro Motta aa2345d35c
Reduce Clojure linter warning noise (#17491)
Change the make "lint" target default behavior to NOT show clj-kondo warnings.

In the CI, I kept the same behavior, i.e. show all warnings and errors
simultaneously.

Motivation:
When devs run make lint, most of the time, they don't want to see a long list of
warnings. Their focus is on the errors. Additionally, the majority of devs in
the mobile team see clj-kondo warnings in their editors of choice already.

We (some of us) believe the editor feedback/warnings are sufficiently noisy.

Add the following somewhere in your config files if you want to see
warnings.

    export CLJ_LINTER_PRINT_WARNINGS=true
2023-10-04 16:06:54 -03:00
Icaro Motta 0f71c18f57
Disable fn-deprecated warning during development (#17204)
Disable :fn-deprecated warnings from the Closure compiler for the mobile
shadow-cljs target during development. The compiler warnings are no longer
necessary, because we're managing deprecation via clj-kondo.

Without the compiler setting's change, every code reload will generate warnings
for each and every deprecated call in the repo, which can quickly grow to the
hundreds or more, thus making the terminal output horrendous to understand.

Also set clj-kondo's "fail-level" to "error" (the default is "warning").
2023-09-06 08:58:42 -03:00
Icaro Motta b9890a9d44
Upgrade shadow-cljs and ClojureScript (#15417)
This commit upgrades Shadow CLJS from 2.11.16 (released on Feb/21) to latest
2.25.0 (Jul/23), so ~1.5 years worth of upgrades. By upgrading shadow we
can finally use the latest major Clojure version 1.11.x.

Why upgrade shadow?

- Shadow CLJS controls the ClojureScript version we can use. In order to use the
  latest major Clojure version we must upgrade Shadow CLJS.

- Shadow CLJS releases new versions very frequently, and if you take a look at
  its changelog https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md, you'll see
  it had tons and tons of bug fixes over the years. I hope some of them help
  improve the DX for certain contributors who recently reported issues with
  it.

- Clojure 1.11 brings new features, bug fixes and even performance improvements
  (although I think the performance mostly impacts Clojure on the JVM). See the
  changelog https://github.com/clojure/clojure/blob/master/changes.md#changes-to-clojure-in-version-1110

Things that can be beneficial to us, or are interesting nonetheless:

- New :as-alias to be used in require, which is like :as but does not require
  the namespace to load. This means namespaced keywords using :as-alias can't
  cause circular dependency errors. This feature would very useful if we used
  namespaced keywords, but we don't, so...
  https://github.com/clojure/clojure/blob/master/changes.md#22-as-alias-in-require
- New macros run-test and run-test-var to run single test with fixtures and
  report.
- New iteration function, useful for processing paginated data.
  https://www.abhinavomprakash.com/posts/clojure-iteration/
- New update-keys function: applies a function to every key in a map.
- New update-vals function: applies a function to every value in a map.

Examples for update-vals and update-keys. They should perform better than the
common reduce-kv approach since they use a transient data structure.

    (let [m {:a 1 :b 2}]
      (update-vals m inc)) ; => {:a 2, :b 3}
    
    (let [m {:a 1 :b 2}]
      (update-keys m name)) ; => {"a" 1, "b" 2}

Why change namespaces within __tests__ directories?

Any namespace with the word --tests-- throws an error, like the one below. I
didn't bother investigating why, so I changed the guidelines to reflect the new
convention. It's probably related to the double dashes in the name.

    Namespace quo2.components.dividers.--tests--.divider-label-component-spec has a
    segment starting with an invalid JavaScript identifier at line 1
2023-07-28 13:40:54 -03:00
Parvesh Monu 8a4cba56f6
Improve hot reloading (#16349) 2023-06-22 16:55:09 +05:30
flexsurfer fb4d484d7d
bump reagent 1.2.0 (#16070) 2023-05-31 13:35:31 +02:00
Icaro Motta 9dad4716d6
Upgrade re-frame (#15997)
This commit upgrades re-frame to v1.3.0 (latest stable release), released ~9
months ago, in 2022-08-27. This is a solid upgrade, with no breaking changes as
far as I tested status-mobile. It's a great testament of re-frame's stability
and commitment to backwards compatibility, as are many Clojure libs.

Fixes https://github.com/status-im/status-mobile/issues/15963

The big, and truly relevant addition is the introduction of the :fx built-in
effect that was added ~3 years ago in Aug/2020 in v1.1.0.

Relevant changelog:

- Global interceptors are now supported (added in v1.0.0).
- reg-event-fx will just warn (not generate an error) if the effect map returned
  contains an unknown effect key.
- re-frame will now warn us when we are calling subscribe outside of a reactive
  context.
- "re-frame now guarantees that a :db effect, if present, will be actioned
  before any other sibling effects. re-frame continues to provide NO guarantees
  about the order in which other effects will be actioned."
  (https://day8.github.io/re-frame/releases/2020/#110-2020-08-24)
- There's syntactic sugar for trivial reg-sub declarations (added in v1.3.0).
  See the documentation for reg-sub for more details
  https://day8.github.io/re-frame/api-re-frame.core/#reg-sub
- "The built-in effect :dispatch-later can now take a single map value.
  Supplying a sequence of maps is now deprecated in favor of using multiple
  :dispatch-later effects within the new :fx effect."
  https://day8.github.io/re-frame/releases/2020/#111-2020-08-26
2023-05-31 06:08:34 -03:00
Jakub Sokołowski 58d20967ae
nix: use jsbundle derivation for iOS as well
For some unknown to me reason we are using a different Yarn call to
Shadow-cljs to generate the JSBundle for iOS builds, while the one
created by the Android derivation shoudl be exactly the same.

I'm changing the target to just be `make jsbundle` while keeping aliases
referencing old naming, and moving things around in `nix` folder to
reflect the fact that the derivation is no longer Android-specific.

Also, crucially, I've changed the `import` in `index.js` to use the
`./result/index.js` path, since that's what Nix creates. I'm not sure if
this clashes with any developer workflow that takes place locally, so
I'd appreciate some testing from developers.

Depends on: https://github.com/status-im/status-jenkins-lib/pull/67

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2023-05-22 10:31:09 +02:00
andrey 6858884c83
[#15756] Token gated communities 2023-05-20 08:54:06 +01:00
Icaro Motta 7a4b12acf4
Make component test helpers usable from the REPL (#15468)
This commit makes the test-helpers.component namespace loadable in the REPL,
plus other changes that allow for a reasonably enjoyable RDD (REPL-Driven
Development) workflow.

Why? I want to be able to get instant feedback when I render a component with
the RN Testing Library (RNTL), and only once I'm satisfied with my findings is
when I proceed to write/update the tests. This nearly instant feedback loop is
only feasible using the ClojureScript REPL, and I'd rather not endure long
recompilation cycles.

Note that by REPL I mean connecting to the CLJS REPL of the Shadow-CLJS :mobile
target.

Essentially, this is what this commit does:

- [x] Allow the test-helpers.component namespace to be evaluated in the REPL.
      This is now possible because I changed all functions that assumed js/jest
      existed with a guard clause using the CLJS macro exists?. Without the
      guard clauses, evaluating the namespace explodes due to stuff like
      js/jest.useFakeTimers that fail in compile time (it's a syntax sugar
      macro).
- [x] Change the family of functions to get the translation by text to either
      translate using i18n/label or translate with the dummy prefix tx:,
      depending if the code is running inside the Jest runtime or not.
- [x] Wrap remaining RNTL query functions, except for the find-* ones, since
      they don't work at all outside the Jest runtime.
- [x] All wrapped functions support the original arguments supported by RNTL.
      Arguments are always converted with clj->js.
- [x] All wrapped functions can optionally take a node (ReactTestInstance) as
      their first argument, otherwise the global screen object will be used.
      This is very important! See the explanation on section Doesn't RNTL
      recommend using the screen object?
- [x] Update Shadow-CLJS preloads, so that (in development) you can fire off the
      REPL and always be ready to call component test helpers. This is critical!

What else would be possible? Just an idea, but now that we can easily render
components using the same machinery provided by RNTL in the tests, we can
roughly implement Storybook's Play function
https://storybook.js.org/docs/react/writing-stories/play-function

Lesson learned: In the REPL, you may need to call
(re-frame.core/clear-subscription-cache!), otherwise you will experience
subscriptions returning the same value if their arguments are the same. For
example, I faced this while playing with the namespace
status-im2.contexts.communities.menus.community-options.component-spec. There
are better ways to solve this particular problem in the context of tests if we
use the tooling provided by day8.re-frame.test.

Doesn't RNTL recommend using the screen object? Indeed, it is recommended to use
the screen object instead of destructuring the results of RNTL render. It's just
easier and less error prone, but this only works reliably within the Jest
runtime, since it automatically cleans up rendered state after each test. When
using the REPL this is no longer the case, and I faced some errors, like Unable
to find node on an unmounted component, where RNTL would refuse to re-render
components, even if I explicitly unmounted them or called cleanup.

The only reliable solution I found was to store the result of render (a node)
and pass it to every subsequent call. This is not a workaround, it's officially
supported, but it's a tad less convenient. You can also not pass the node
reference and it should work most of the time.

Practical examples

Workflow suggestion: write your local experiments in the same namespace as the
component spec and within the comment macro. This way, you can have the Jest
watcher running and a REPL connected to :mobile, and they won't step on each
other. For the test watcher, I usually change quo2-core-spec or
status-im2.core-spec to only require what I'm interested, otherwise Jest
consumes way too many resources.

```clojure
;; Namespace quo2.components.colors.color-picker.component-spec
(h/test "color picker color changed"
  (let [selected (reagent/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)
        (.toStrictEqual :blue))))

(comment
  (def selected (atom nil))
  (def c (h/render [color-picker/view {:on-change #(reset! selected %)}]))

  (h/fire-event :press (get (h/get-all-by-label-text c :color-picker-item) 0))

  ;; Options are passed down converted to JS types.
  (h/debug c {:message "Rendering header"})

  @selected ; => :blue
)
```

```clojure
;; Namespace quo2.components.tags.--tests--.status-tags-component-spec
(h/test "renders status tag with pending type"
  (render-status-tag {:status {:type :pending}
                      :label  "Pending"
                      :size   :small})
  (-> (h/expect (h/get-all-by-label-text :status-tag-pending))
      (.toBeTruthy))
  (-> (h/expect (h/get-by-text "Pending"))
      (.toBeTruthy)))

(comment
  (def c (render-status-tag {:status {:type :pending}
                             :label  "Pending"
                             :size   :small}))

  (h/get-all-by-label-text c :status-tag-pending))
```

```clojure
;; Namespace status-im2.contexts.communities.menus.community-options.component-spec
(h/test "joined and muted community"
  (setup-subs {:communities/my-pending-request-to-join nil
               :communities/community                  {:joined       true
                                                        :muted        true
                                                        :token-gated? true}})
  (h/render [options/community-options-bottom-sheet {:id "test"}])
  (-> (h/expect (h/get-by-translation-text :unmute-community))
      (.toBeTruthy)))

(comment
  (setup-subs {:communities/my-pending-request-to-join nil
               :communities/community                  {:joined       true
                                                        :muted        true
                                                        :token-gated? true}})
  (def c (h/render [options/community-options-bottom-sheet {:id "test"}]))
  (some? (h/get-by-translation-text c :invite-people-from-contacts)) ; => true
)
```
2023-03-27 11:54:56 -03:00
Jakub Sokołowski 0f8ad69319
Nix/upgrade zprint 1.2.5 (#15113)
* nix: upgrade zprint from 1.2.4 to 1.2.5

To address issue described in:
https://github.com/kkinnear/zprint/issues/273

Signed-off-by: Jakub Sokołowski <jakub@status.im>

* chore: use zprint :multi-lhs-hang

* refactor: re-format clojure using zprint 1.2.5

---------

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Co-authored-by: yqrashawn <namy.19@gmail.com>
2023-02-17 20:10:00 +08:00
Omar Basem 95380175a6
fix: image actions (#14996)
* fix: image actions and reactions
2023-02-09 07:18:49 +04:00
flexsurfer e8e8547879
cleanup setup (#14827) 2023-01-19 12:15:28 +01:00
Alexander 27c8c5547c
[#14689] Link previews in chat (#14771)
* Initial

* Link fetching

* Post-merge fix
2023-01-18 22:43:26 +01:00
flexsurfer d2e35fe928
move constants/config to status-im2 root and remove old constants/config (#14821) 2023-01-18 15:43:58 +01:00
flexsurfer ed348e0871
cleaning (#14808)
cleaning, introduce react-native.red-black-tree and move messages list events
2023-01-18 12:16:33 +01:00
Jamie Caprani 73c4be8dee
Communities Join Screens - Implement all permutations of Context Drawer options (#14700) 2023-01-13 09:35:41 +00:00
Omar Basem 951fd43d10
Images Album (#14635)
* feat: images album
2023-01-05 16:31:32 +04:00
Icaro Motta 915b8ebd9a
New component Selector > Filter (#14650) 2022-12-28 12:21:15 -03:00
yqrashawn 39e29cfb5a
feat: replace clj-fmt with zprint (#14520) 2022-12-20 21:57:49 +08:00
Omar Basem ba41d4b271
Photo Selector 2 (#14487)
* Photo Selector (2)
2022-12-20 07:36:06 +04:00
Jamie Caprani c6e8aad745
feat: add component tests using react-testing-library and jest (#14331) 2022-11-23 05:59:18 -08:00
flexsurfer c7d5e90882
introduce new project structure (first step) (#14356)
* introduce new project structure
2022-11-14 19:16:55 +01:00
Jakub Sokołowski 93f5b2e32c
nix: fix shadow-cljs on M1 by upgrading to 2.11.16
On M1 calling `shadow-cljs` fails with:
```
Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader$NativeLibrary/load (ClassLoader.java:-2).
/private/var/folders/__/x311ykg17rqgq2wyl4kn1pdr0001yh/T/jna8753030888504535661.tmp:
    dlopen(/private/var/folders/__/x311ykg17rqgq2wyl4kn1pdr0001yh/T/jna8753030888504535661.tmp, 0x0001):
        tried: '/private/var/folders/__/x311ykg17rqgq2wyl4kn1pdr0001yh/T/jna8753030888504535661.tmp'
            (fat file, but missing compatible architecture (have (unknown,i386,x86_64), need (arm64e)))
```
This is due to an outdeted dependency on JNA 3.2.2, which is pulled in
by `hawk` package which up until release `2.11.16` was a `shadow-clj`
dependency which was removed because it was:

>Only used to be used on macOS since it was slightly faster than the default
>JVM implementation. However in Big Sur it seems to cause issues and break
>completely or just be a lot slower.

https://github.com/thheller/shadow-cljs/commit/f3b89b5a

Dropped the explicit dependency on `org.clojure/core.async` to avoid:
```
WARNING: The org.clojure/core.async dependency in shadow-cljs.edn was ignored.
Default version is used and override is not allowed to ensure compatibility.
```

Resolves: https://github.com/status-im/status-mobile/issues/14196

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2022-10-20 17:54:02 +02:00
Roman Volosovskyi c017c01c53
[#11335] Use Pokt network as an infura replacement 2022-10-19 17:00:17 +02:00
Icaro Motta 8502834500
Improve activity log component
Also makes hot reload optional with environment variable
SHADOW_AUTOBUILD_ENABLED.
2022-09-09 00:39:32 -03:00
yqrashawn ccd26dcfd0
refactor: go through clj-kondo warnings (#13929) 2022-09-05 18:52:39 +08:00
Jakub Sokołowski 8ec2f23203
nix: pass OPENSEA_API_KEY via saveAccountAndLogin
Here the injection of OpenSea API key was done at compile time:
https://github.com/status-im/status-mobile/commit/aa72ac57

But this makes `status-go` builds impure, and also prevents them from
being extracted from `status-mobile` into `status-go` repo.

Instead we pass the `OPENSEA_API_KEY` env variable to JS bundle at build
time, which is then passed to `status-go` via the
`Statusgo.saveAccountAndLogin` call in `saveAccountAndLogin`:
https://github.com/status-im/status-mobile/blob/51174f84/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java#L323-L327

Which sends `NodeConfig` that also contains `WalletConfig` which can
include `OpenseaAPIKey`:
```go
type WalletConfig struct {
    Enabled       bool
    OpenseaAPIKey string `json:"OpenseaAPIKey"`
}
```
https://github.com/status-im/status-go/blob/0135cc15/params/config.go#L510-L514

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2022-08-05 14:23:33 +02:00
yqrashawn a08c7ff22e
feat: add repl support for cljs test (#13754) 2022-08-03 16:14:20 +02:00
flexsurfer 8a01d02135
re-frisk 1.6.0 (#13380) 2022-05-20 12:31:54 +02:00
andrey f39b688e89
google free and metrics free
Signed-off-by: andrey <motor4ik@gmail.com>
2022-05-19 07:22:23 +02:00
Parvesh Monu 36c7d8e4ca
Implementation of remote android notifications (#13028) 2022-02-14 17:27:33 +05:30
andrey 05ed28b9a2
re-frisk 1.5.0 2021-04-19 11:45:43 +02:00
andrey 87f86d3b7b
bump re-frisk 1.4.0 2021-04-12 08:36:54 +02:00
andrey 76b1e2a007
bump re-frisk
Signed-off-by: andrey <motor4ik@gmail.com>
2021-03-12 13:01:59 +01:00
Jakub Sokołowski 293fd5fae1
nix: add missing cljfmt dependencies to nix/deps/clojure
It seems like this worked before purely because the `cljfmt` library was
already in the `~/.m2` cache folder. This issue was noticed when I
cleaned up the `~/.m2` folder on one Jenkins slave host and the Lint stage
started randomly failing.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Signed-off-by: andrey <motor4ik@gmail.com>
2021-03-01 16:42:38 +01:00
andrey 9648f741b4
cleaning 3
Signed-off-by: andrey <motor4ik@gmail.com>
2021-02-17 16:16:54 +01:00
andrey 0087a66df8
bump re-frisk 2021-01-21 15:25:54 +01:00
andrey af2b053fa9
disable fast refresh on ios and bump re-frisk
Signed-off-by: andrey <motor4ik@gmail.com>
2021-01-20 11:44:24 +01:00
Andrea Maria Piana 85991d2272
Set infura token and update snx/synth contract
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-10-07 10:01:39 +02:00
Andrea Maria Piana 966f6de31a
Fix infura token
Setting a top-level closure-defines does not have any effect,
it needs to be for some reason inside each environment.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-10-05 16:22:14 +02:00
andrey 9cd1e08aaa
upgrade shadow
Signed-off-by: andrey <motor4ik@gmail.com>
2020-10-01 08:53:10 +02:00
Александар Симић b2a79b3e89
Update nREPL to the latest stable
With the update of Emacs CIDER 0.26.1, it expects to have the latest
cider-nrepl dependency to be at 0.25.3 otherwise it throws an error
when connecting to the project's REPL.

Signed-off-by: andrey <motor4ik@gmail.com>
2020-09-02 11:27:52 +02:00
Gheorghe Pinzaru 793579885a
Add universal QR scanner via common router
Rename events

Add router to handle all links

Use router in add new chat

Unify universal link and universal qr with router

Add icon for universal scanner

Update tests

Now routing is tested in routing PR

lint

Cleanup

QA fixes

Scan own profile

Handle more EIP

Fix wallet scanner

Fix stack for view profile in UL

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
2020-08-11 10:24:15 +03:00
yenda 67ce4b03aa
Revert "upgrade shadow"
This reverts commit 08cbc76111.

Signed-off-by: yenda <eric@status.im>
2020-07-14 13:02:24 +02:00
andrey eef6815616
[#10880] Expanded view with public chat categories 2020-07-10 14:54:39 +02:00
andrey 08cbc76111
upgrade shadow
Signed-off-by: andrey <motor4ik@gmail.com>
2020-07-10 12:41:15 +02:00