Fixes the scroll behavior in a community channel member list. The problem was
that the code wasn't enforcing the correct height.
Partially solves https://github.com/status-im/status-mobile/issues/20514
Steps to test: Long press on any community channel and press View channel
members and details. The user should be able to correctly scroll throughout the
entire list of members.
BigNumber instances are not comparable to other data types, except numbers and
strings (supported directly by the library). This commit makes = safe on
bignumbers (no exceptions should be thrown), even when comparing a bignumber
with a nil value.
There's another important benefit from having a custom comparator: performance,
because re-frame will be able to correctly compare data with bignumbers and thus
reuse cached subscriptions and also Reagent will be able to skip processing when
props are equal.
The IComparable interface was not changed. Similarly to core CLJS data types,
sorting heterogeneous collections throws (ignore nils).
```clojure
;; This throws with message: cannot compare 10 to foo
(sort ["foo" 10])
```
We could make sorting work with heterogeneous collections, but then we would
need to extend many core data types to play nice with BigNumber and that sounds
more like a hack, and it's also not a problem we have nowadays.
* Fix color of non-selected keypairs
* Fix pressable area in keypairs
* Make validation more robust
* Make confirm button always pressable
* Fix wrong sentence in errors
* Solve account creation by fixing a memoized callback
* Improve logging
* tweak: use support blur colors for action drawer icons
* tweak: support blur colors for drawer-top icon
* tweak: support blur colors for account list inside keypair component
* tweak: use blur colors for missing-keypair bottom sheet actions
* feat: remove feature-flag for key-pairs and accounts inside wallet settings
* fix: ensure key-pairs-and-accounts settings are visible
* tweak: display key-pair rename screen as full-screen modal
* tweak: animate key-pair scanning screen as modal
* fix: do not allow user to rename key-pair to an existing key-pair name
* fix: ensure we visualise the validation error for key-pair name that is too long
* fix: ensure we can see the recovery-phrase suggestions when testnet-mode is active
* tweak: show recovery-phrase errors when keyboard is hidden
* fix: ensure we do not re-hash password
* fix: ensure we call `on-close` function when successfully handling biometrics auth
* fix: ensure we clear error states when editing the recovery-phrase input
* fix: use blur styles for standard authentication password input
* chore: add labels for qr validation
* tweak: handle display import-qr error and allow for re-scanning
* tweak: update blur background for all bottom-sheets
* chore: add feature-flag for import-all key-pairs button for missing key-pairs
* tidy: remove unused variable
* fix: ensure layout for android is correct when entering seed-phrase in testnet-mode
* fix: ensure we return the updated db when updating the db with backup key-pair
* tweak: coerce nil to empty string
* tweak: change validation error message for short key-pair name
* tweak: hide the options icon for the default key-pair inside key-pairs and accounts settings
* chore(wallet): make recent tab fullscreen for empty view
* chore(wallet): hide advanced button on send page
* chore(wallet): hide estimated fees when no routes found
* chore(wallet): update emoji icon to edit
* chore(wallet): update key pair placeholder to use keypair example
* chore(shell): feature flag saved address option in scanner
After migrating from v1 to v2, some user names may be too long to fit in some
devices in the "Settings > Edit Profile > Name" setting. The solution was to
truncate in the UI the name to the max valid length in v2, which is 20
characters.
Other small improvements:
- Don't use entire Clojure maps as the :key in React. This is known to be slow
because it's expensive for Clojure to generally transform a data structure
into its string representation.
- Don't find the last item of a list using last and an equality between two
maps. This will force each iteration to call last, which in turn will iterate
over the entire list of items (we can think of the Clojure lazy seq as a
linked list). Instead, we now cache the index outside the loop and do a number
comparison.
- Don't pass entire props to style functions when not needed because
destructuring has a cost. I wouldn't personally worry about this 99% of the
time, but when there's only argument like in this PR where we were passing a
single blur? argument, it's preferable to not use a map.
Solves a problem encountered in unit tests, where instances of BigNumber (used
in the utils.money namespace) can't be compared with = or match?
If you try the following code you will always get false because they're
different instances in memory.
(= (money/bignumber 0) (money/bignumber 0))
We now extend BigNumber (from lib bignumber.js) so that their instances are
comparable (e.g. necessary to sort) and understand equality.
We also extend BigNumber to work with the match? directive. For example, this is
the output of comparing a nested map containing bignumbers (colored in the
terminal):
(match? {:a {:b {:c (money/bignumber 42)}}}
{:a {:b {:c (money/bignumber 43)}}})
FAIL in (equivalence-test) (at cljs$test$run_block (status-mobile/target/test/cljs-runtime/cljs.test.js:366:13)
expected: (match? {:a {:b {:c (money/bignumber 42)}}} {:a {:b {:c (money/bignumber 43)}}})
actual: {:a
{:b {:c (mismatch (expected "42") (actual "43"))}}}
This commit refactors the keypairs data in app-db to save them by indexed by key-uid which will help to fetch, update, and delete easily instead of using filter and some methods every time we need to perform those operations.
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
* Add background color to collectibles
* Fix header text animation in unsupported collectibles
* Fix header height and animation color
* Fix image not showing when it's `nil` or `""`
* Add missing border to expanded-collectible
* Fix extra `0` in create/edit account title input
* Validate name, color and emoji in account creation/edition screen
* Refactor sub
* Fix button disabled condition and placeholder
This is a byproduct of the investigation on issue
https://github.com/status-im/status-mobile/issues/20203, more specifically, to
double-check if v1 users have their display names shown correctly.
Closes https://github.com/status-im/status-mobile/issues/20203
This is the scenario used to reproduce the bugs this PR is solving:
1. Alice creates an account in v1 (branch release/1.20.x).
2. Alice had 1 friend to chat with, Carol.
3. Alice sends and receives at least one message from Carol.
4. Alice installs the new app (latest develop branch suffices).
5. Alice login and try to edit her profile, but her 3-word name is not displayed
in the Settings > Edit Profile screen, nor in the Settings > Edit profile >
Name input field.
6. Alice also opens her chat with Carol, but her name appears as a public key
instead of her 3-word name she identifies herself with.
The solution presented here is to just fallback to Alice's 3-word name (name
field in the profile/contact app-db instance).
Areas that may be impacted
- Edit profile name.
- Name displayed in chats from the perspective of the sender who migrated from
v1.
Steps to test
In order to test this PR, it's necessary to migrate from v1 to v2 using two
separate builds. The v1 build can be obtained in PR
https://github.com/status-im/status-mobile/pull/20123. v2 build can be any one
from develop from today, for example.
This commit:
- fixes addresses are displayed without truncation
- fixes network preference (advanced icon) shown for ENS
- fixes navigation on adding a new saved address
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
Introduces a new macro deftest-event to facilitate writing tests for event
handlers. Motivation came from the _problem of having to always extract event
handlers as vars in order to test them_.
Although the implementation of deftest-sub and deftest-event are similar,
deftest-sub is critically important because it guarantees changes in one
subscription can be caught by tests from all other related subscriptions in the
graph (reference: PR https://github.com/status-im/status-mobile/pull/14472).
This is not the case for the new deftest-event macro. deftest-event is
essentially a way of make testing events less ceremonial by not requiring event
handlers to be extracted to vars. But there are a few other small benefits:
- The macro uses re-frame and "finds" the event handler by computing the
interceptor chain (except :do-fx), so in a way, the tests are covering a bit
more ground.
- Slightly easier way to find event tests in the repo since you can just find
references to deftest-event.
- Possibly slightly easier to maintain by devs because now event tests and sub
tests are written in a similar fashion.
- Less code diff. Whether an event has a test or not, there's no var to
add/remove.
- The dispatch function provided by the macro makes reading the tests easier
over time. For example, when we read subscription tests, the Act section of
the test is always the same (rf/sub [sub-name]). Similarly for events, the
Act section is always (dispatch [event-id arg1 arg2]).
- Makes the re-frame code look more idiomatic because it's more common to define
handlers as anonymous functions.
Downside: deftest-sub and deftest-event are relatively complicated macros.
Note: The test suite runs just as fast and clj-kondo can lint code within the
macro just as well.
Before:
```clojure
(deftest process-account-from-signal-test
(testing "process account from signal"
(let [cofx {:db {:wallet {:accounts {}}}}
effects (events/process-account-from-signal cofx [raw-account])
expected-effects {:db {:wallet {:accounts {address account}}}
:fx [[:dispatch [:wallet/get-wallet-token-for-account address]]
[:dispatch
[:wallet/request-new-collectibles-for-account-from-signal address]]
[:dispatch [:wallet/check-recent-history-for-account address]]]}]
(is (match? expected-effects effects)))))
```
After
```clojure
(h/deftest-event :wallet/process-account-from-signal
[event-id dispatch]
(let [expected-effects
{:db {:wallet {:accounts {address account}}}
:fx [[:dispatch [:wallet/get-wallet-token-for-account address]]
[:dispatch [:wallet/request-new-collectibles-for-account-from-signal address]]
[:dispatch [:wallet/check-recent-history-for-account address]]]}]
(reset! rf-db/app-db {:wallet {:accounts {}}})
(is (match? expected-effects (dispatch [event-id raw-account])))))
```