From dc571b6067ee1f058d5a50c3314f910ed00afcd5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 6 Nov 2023 14:38:14 +0100 Subject: [PATCH] Getting rid of status-im.multiaccounts.core + removing three word random names (#17384) --- ios/Podfile.lock | 2 +- .../status/ethereum/module/StatusModule.java | 40 --- .../ios/RCTStatus/RCTStatus.m | 36 --- modules/react-native-status/nodejs/status.cpp | 66 ----- src/native_module/core.cljs | 22 +- src/status_im/contact/core.cljs | 6 - src/status_im/contact/db.cljs | 23 +- src/status_im/contact/db_test.cljs | 92 ++++--- src/status_im/events.cljs | 2 +- src/status_im/keycard/fx.cljs | 10 - src/status_im/keycard/recovery.cljs | 69 ++---- src/status_im/keycard/simulated_keycard.cljs | 14 +- src/status_im/multiaccounts/core.cljs | 234 ------------------ src/status_im/multiaccounts/logout/core.cljs | 19 +- src/status_im/multiaccounts/recover/core.cljs | 10 +- .../ui/components/chat_icon/screen.cljs | 12 +- .../ui/screens/advanced_settings/views.cljs | 2 +- .../ui/screens/appearance/views.cljs | 2 +- .../ui/screens/communities/members.cljs | 4 +- .../ui/screens/contacts_list/views.cljs | 4 +- .../default_sync_period_settings/view.cljs | 2 +- .../ui/screens/keycard/recovery/views.cljs | 15 +- src/status_im/ui/screens/keycard/views.cljs | 4 +- .../delete_profile.cljs | 13 +- .../privacy_and_security_settings/views.cljs | 10 +- .../ui/screens/profile/contact/views.cljs | 65 +++-- .../ui/screens/profile/group_chat/views.cljs | 18 +- .../ui/screens/profile/user/edit_picture.cljs | 8 +- .../ui/screens/profile/user/views.cljs | 17 +- src/status_im/ui/screens/screens.cljs | 2 +- src/status_im/ui/screens/signing/views.cljs | 16 +- .../ui/screens/wallet/collectibles/views.cljs | 5 +- .../ui/screens/wallet/send/views.cljs | 10 +- .../screens/wallet/signing_phrase/views.cljs | 3 +- src/status_im/utils/gfycat/core.cljs | 14 -- src/status_im/utils/identicon.cljs | 5 - src/status_im/utils/test.cljs | 12 - .../utils/universal_links/core_test.cljs | 32 ++- src/status_im/wallet/accounts/core.cljs | 20 +- src/status_im/wallet/core.cljs | 12 +- .../common/confirmation_drawer/view.cljs | 15 +- src/status_im2/common/home/actions/view.cljs | 4 +- src/status_im2/common/home/top_nav/view.cljs | 36 +-- .../common/password_authentication/view.cljs | 8 +- .../enter_password/view.cljs | 13 +- .../contexts/chat/composer/reply/view.cljs | 10 +- .../chat/home/contact_request/view.cljs | 8 +- .../contexts/chat/lightbox/top_view.cljs | 5 +- .../contexts/chat/messages/avatar/view.cljs | 8 +- .../contact_requests/bottom_drawer.cljs | 6 +- .../chat/messages/content/deleted/view.cljs | 7 +- .../chat/messages/content/pin/view.cljs | 8 +- .../contexts/chat/messages/content/view.cljs | 4 +- .../contexts/chat/messages/drawers/view.cljs | 3 +- .../chat/messages/link_preview/events.cljs | 10 +- src/status_im2/contexts/contacts/events.cljs | 1 + .../select_photo/method_menu/view.cljs | 1 - src/status_im2/contexts/profile/events.cljs | 4 +- .../contexts/profile/login/events.cljs | 12 +- .../contexts/profile/settings/effects.cljs | 40 +++ .../contexts/profile/settings/events.cljs | 140 +++++++++++ src/status_im2/contexts/profile/utils.cljs | 23 ++ .../quo_preview/drawers/drawer_top.cljs | 6 +- .../notification/common/view.cljs | 8 +- src/status_im2/contexts/shell/share/view.cljs | 11 +- .../contexts/syncing/setup_syncing/view.cljs | 2 +- .../contexts/wallet/create_account/view.cljs | 4 +- src/status_im2/events.cljs | 1 + src/status_im2/navigation/core.cljs | 2 +- src/status_im2/navigation/events.cljs | 2 +- src/status_im2/subs/chats.cljs | 8 +- src/status_im2/subs/communities.cljs | 23 +- src/status_im2/subs/contact.cljs | 50 +--- src/status_im2/subs/messages.cljs | 6 +- src/status_im2/subs/profile.cljs | 22 +- src/status_im2/subs/shell.cljs | 16 +- 76 files changed, 566 insertions(+), 913 deletions(-) delete mode 100644 src/status_im/multiaccounts/core.cljs delete mode 100644 src/status_im/utils/gfycat/core.cljs delete mode 100644 src/status_im/utils/identicon.cljs create mode 100644 src/status_im2/contexts/profile/settings/effects.cljs create mode 100644 src/status_im2/contexts/profile/settings/events.cljs create mode 100644 src/status_im2/contexts/profile/utils.cljs diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d1af6b5224..dfae31d571 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -765,7 +765,7 @@ SPEC CHECKSUMS: RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467 RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071 - RNReanimated: 62e43ee6baafb9ba3d3af1857d7fd23a1d41bff0 + RNReanimated: 42f56dc5c032a11177b9ea12cdb57285318b432e RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8 RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9 diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index c39ec85a6e..39d823dbd9 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -1194,21 +1194,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL return getPublicStorageDirectory().getAbsolutePath(); } - @ReactMethod(isBlockingSynchronousMethod = true) - public String generateAlias(final String seed) { - return Statusgo.generateAlias(seed); - } - - @ReactMethod - public void generateAliasAsync(final String seed, final Callback callback) throws JSONException { - executeRunnableStatusGoMethod(() -> Statusgo.generateAlias(seed), callback); - } - - @ReactMethod(isBlockingSynchronousMethod = true) - public String identicon(final String seed) { - return Statusgo.identicon(seed); - } - @ReactMethod(isBlockingSynchronousMethod = true) public String encodeTransfer(final String to, final String value) { return Statusgo.encodeTransfer(to, value); @@ -1269,31 +1254,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL executeRunnableStatusGoMethod(() -> Statusgo.identicon(seed), callback); } - @ReactMethod - public void generateAliasAndIdenticonAsync(final String seed, final Callback callback) { - - Log.d(TAG, "generateAliasAndIdenticonAsync"); - if (!checkAvailability()) { - callback.invoke(false); - return; - } - - Runnable r = new Runnable() { - @Override - public void run() { - String resIdenticon = Statusgo.identicon(seed); - String resAlias = Statusgo.generateAlias(seed); - - Log.d(TAG, resIdenticon); - Log.d(TAG, resAlias); - callback.invoke(resAlias, resIdenticon); - } - }; - - StatusThreadPoolExecutor.getInstance().execute(r); - - } - @Override public @Nullable Map getConstants() { diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index d4cc1a4926..3a6b2afe1a 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -880,10 +880,6 @@ RCT_EXPORT_METHOD(callRPC:(NSString *)payload }); } -RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(generateAlias:(NSString *)publicKey) { - return StatusgoGenerateAlias(publicKey); -} - RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(keystoreDir) { NSFileManager *fileManager = [NSFileManager defaultManager]; NSURL *rootUrl =[[fileManager @@ -943,19 +939,6 @@ RCT_EXPORT_METHOD(initLogging:(BOOL)enabled callback(@[initResult]); } -RCT_EXPORT_METHOD(generateAliasAsync:(NSString *)publicKey - callback:(RCTResponseSenderBlock)callback) { -#if DEBUG - NSLog(@"generateAliasAsync() method called"); -#endif - NSString *result = StatusgoGenerateAlias(publicKey); - callback(@[result]); -} - -RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) { - return StatusgoIdenticon(publicKey); -} - RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(encodeTransfer:(NSString *)to value:(NSString *)value) { return StatusgoEncodeTransfer(to,value); @@ -1011,15 +994,6 @@ RCT_EXPORT_METHOD(validateMnemonic:(NSString *)seed callback(@[result]); } -RCT_EXPORT_METHOD(identiconAsync:(NSString *)publicKey - callback:(RCTResponseSenderBlock)callback) { -#if DEBUG - NSLog(@"identiconAsync() method called"); -#endif - NSString *result = StatusgoIdenticon(publicKey); - callback(@[result]); -} - RCT_EXPORT_METHOD(createAccountAndLogin:(NSString *)request) { #if DEBUG NSLog(@"createAccountAndLogin() method called"); @@ -1034,16 +1008,6 @@ RCT_EXPORT_METHOD(restoreAccountAndLogin:(NSString *)request) { StatusgoRestoreAccountAndLogin(request); } -RCT_EXPORT_METHOD(generateAliasAndIdenticonAsync:(NSString *)publicKey - callback:(RCTResponseSenderBlock)callback) { -#if DEBUG - NSLog(@"generateAliasAndIdenticonAsync() method called"); -#endif - NSString *identiconResult = StatusgoIdenticon(publicKey); - NSString *aliasResult = StatusgoGenerateAlias(publicKey); - callback(@[aliasResult, identiconResult]); -} - RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload callback:(RCTResponseSenderBlock)callback) { dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ diff --git a/modules/react-native-status/nodejs/status.cpp b/modules/react-native-status/nodejs/status.cpp index 2db082a3d0..d183a37a08 100644 --- a/modules/react-native-status/nodejs/status.cpp +++ b/modules/react-native-status/nodejs/status.cpp @@ -354,38 +354,6 @@ void _StopCPUProfiling(const FunctionCallbackInfo& args) { } -void _Identicon(const FunctionCallbackInfo& args) { - Isolate* isolate = args.GetIsolate(); - Local 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 Identicon"))); - return; - } - - // Check the argument types - - if (!args[0]->IsString()) { - isolate->ThrowException(Exception::TypeError( - String::NewFromUtf8Literal(isolate, "Wrong argument type for 'pk'"))); - return; - } - - - String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked()); - char *arg0 = *arg0Obj; - - // Call exported Go function, which returns a C string - char *c = Identicon(arg0); - - Local ret = String::NewFromUtf8(isolate, c).ToLocalChecked(); - args.GetReturnValue().Set(ret); - delete c; - -} - void _EncodeTransfer(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); @@ -864,38 +832,6 @@ void _CreateAccountAndLogin(const FunctionCallbackInfo& args) { } -void _GenerateAlias(const FunctionCallbackInfo& args) { - Isolate* isolate = args.GetIsolate(); - Local 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 GenerateAlias"))); - return; - } - - // Check the argument types - - if (!args[0]->IsString()) { - isolate->ThrowException(Exception::TypeError( - String::NewFromUtf8Literal(isolate, "Wrong argument type for 'pk'"))); - return; - } - - - String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked()); - char *arg0 = *arg0Obj; - - // Call exported Go function, which returns a C string - char *c = GenerateAlias(arg0); - - Local ret = String::NewFromUtf8(isolate, c).ToLocalChecked(); - args.GetReturnValue().Set(ret); - delete c; - -} - void _ValidateMnemonic(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); Local context = isolate->GetCurrentContext(); @@ -1953,7 +1889,6 @@ void init(Local exports) { NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount); NODE_SET_METHOD(exports, "initKeystore", _InitKeystore); NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling); - NODE_SET_METHOD(exports, "identicon", _Identicon); NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer); NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall); NODE_SET_METHOD(exports, "decodeParameters", _DecodeParameters); @@ -1968,7 +1903,6 @@ void init(Local exports) { NODE_SET_METHOD(exports, "resetChainData", _ResetChainData); NODE_SET_METHOD(exports, "saveAccountAndLogin", _SaveAccountAndLogin); NODE_SET_METHOD(exports, "createAccountAndLogin", _CreateAccountAndLogin); - NODE_SET_METHOD(exports, "generateAlias", _GenerateAlias); NODE_SET_METHOD(exports, "validateMnemonic", _ValidateMnemonic); NODE_SET_METHOD(exports, "multiformatSerializePublicKey", _MultiformatSerializePublicKey); NODE_SET_METHOD(exports, "saveAccountAndLoginWithKeycard", _SaveAccountAndLoginWithKeycard); diff --git a/src/native_module/core.cljs b/src/native_module/core.cljs index d1d8571e5d..c549912fa3 100644 --- a/src/native_module/core.cljs +++ b/src/native_module/core.cljs @@ -4,8 +4,7 @@ [clojure.string :as string] [react-native.platform :as platform] [taoensso.timbre :as log] - [utils.transforms :as types] - [utils.validators :as validators])) + [utils.transforms :as types])) (defn status [] @@ -431,19 +430,6 @@ ;; in unknown scenarios we also consider the device rooted to avoid degrading security :else (callback true))) -(defn generate-gfycat - "Generate a 3 words random name based on the user public-key, synchronously" - [public-key] - (log/debug "[native-module] generate-gfycat") - (when (validators/valid-public-key? public-key) - (.generateAlias ^js (status) public-key))) - -(defn identicon - "Generate a icon based on a string, synchronously" - [seed] - (log/debug "[native-module] identicon") - (.identicon ^js (status) seed)) - (defn encode-transfer [to-norm amount-hex] (log/debug "[native-module] encode-transfer") @@ -501,12 +487,6 @@ (log/debug "[native-module] to-checksum-address") (.toChecksumAddress ^js (status) address)) -(defn gfycat-identicon-async - "Generate an icon based on a string and 3 words random name asynchronously" - [seed callback] - (log/debug "[native-module] gfycat-identicon-async") - (.generateAliasAndIdenticonAsync ^js (status) seed callback)) - (defn validate-mnemonic "Validate that a mnemonic conforms to BIP39 dictionary/checksum standards" [mnemonic callback] diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index 52339e1b57..fa775fe3ee 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -11,9 +11,3 @@ :group/selected-contacts #{} :new-chat-name "")} (navigation/navigate-to :contact-toggle-list nil))) - -(defn displayed-photo - [{:keys [images]}] - (or (:large images) - (:thumbnail images) - (first images))) diff --git a/src/status_im/contact/db.cljs b/src/status_im/contact/db.cljs index bfb992a1d4..22dd05394b 100644 --- a/src/status_im/contact/db.cljs +++ b/src/status_im/contact/db.cljs @@ -2,21 +2,12 @@ (:require [clojure.set :as set] [clojure.string :as string] - [status-im.utils.gfycat.core :as gfycat] [status-im2.constants :as constants] [utils.address :as address])) -(defn public-key->new-contact - [public-key] - (let [alias (gfycat/generate-gfy public-key)] - {:alias alias - :name alias - :primary-name alias - :public-key public-key})) - (defn public-key-and-ens-name->new-contact [public-key ens-name] - (let [contact (public-key->new-contact public-key)] + (let [contact {:public-key public-key}] (if ens-name (-> contact (assoc :ens-name ens-name) @@ -27,8 +18,7 @@ (defn public-key->contact [contacts public-key] (when public-key - (or (get contacts public-key) - (public-key->new-contact public-key)))) + (get contacts public-key {:public-key public-key}))) (defn- contact-by-address [[addr contact] address] @@ -66,8 +56,13 @@ (assoc public-key current-contact))] (->> members (map #(or (get all-contacts %) - (public-key->new-contact %))) - (sort-by (comp string/lower-case #(or (:primary-name %) (:name %) (:alias %)))) + {:public-key %})) + (sort-by (comp string/lower-case + (fn [{:keys [primary-name name alias public-key]}] + (or primary-name + name + alias + public-key)))) (map #(if (get admins (:public-key %)) (assoc % :admin? true) %))))) diff --git a/src/status_im/contact/db_test.cljs b/src/status_im/contact/db_test.cljs index bcbf0fd77c..3cfb302c26 100644 --- a/src/status_im/contact/db_test.cljs +++ b/src/status_im/contact/db_test.cljs @@ -1,55 +1,49 @@ (ns status-im.contact.db-test - (:require - [cljs.test :refer-macros [deftest is testing]] - [status-im.contact.db :as contact.db] - [status-im.utils.gfycat.core :as gfycat])) + (:require [cljs.test :refer-macros [deftest is testing]] + [status-im.contact.db :as contact.db])) (deftest contacts-subs (testing "get-all-contacts-in-group-chat" - (with-redefs [gfycat/generate-gfy (constantly "generated")] - (let - [chat-contact-ids - #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917" - "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" - "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"} - admins - #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"} + (let + [chat-contact-ids + #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917" + "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" + "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"} + admins + #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"} - contacts - {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" - {:last-updated 0 - :name "User B" - :primary-name "User B" - :last-online 0 - :public-key - "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}} - current-multiaccount - {:last-updated 0 - :signed-up? true - :sharing-usage-data? false - :primary-name "User A" - :name "User A" + contacts + {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" + {:last-updated 0 + :name "User B" + :primary-name "User B" + :last-online 0 + :public-key + "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}} + current-multiaccount + {:last-updated 0 + :signed-up? true + :sharing-usage-data? false + :primary-name "User A" + :name "User A" + :public-key + "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}] + (is + (= + (contact.db/get-all-contacts-in-group-chat chat-contact-ids + admins + contacts + current-multiaccount) + [{:admin? true :public-key - "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}] - (is - (= - (contact.db/get-all-contacts-in-group-chat chat-contact-ids - admins - contacts - current-multiaccount) - [{:name "generated" - :primary-name "generated" - :alias "generated" - :admin? true - :public-key - "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"} - {:alias "User A" - :primary-name "User A" - :public-key - "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"} - {:last-updated 0 - :name "User B" - :primary-name "User B" - :last-online 0 - :public-key - "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}])))))) + "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"} + {:alias "User A" + :primary-name "User A" + :public-key + "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"} + {:last-updated 0 + :name "User B" + :primary-name "User B" + :last-online 0 + :public-key + "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}]))))) diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 37441ebb21..f98b71d5ef 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -118,7 +118,7 @@ (let [current-theme-type (get-in cofx [:db :profile/profile :appearance])] (when (and (multiaccounts.model/logged-in? db) (= current-theme-type status-im2.constants/theme-type-system)) - {:multiaccounts.ui/switch-theme-fx + {:profile.settings/switch-theme-fx [(get-in db [:profile/profile :appearance]) (:view-id db) true]}))) diff --git a/src/status_im/keycard/fx.cljs b/src/status_im/keycard/fx.cljs index ca85b8a317..f8c1e3e9d4 100644 --- a/src/status_im/keycard/fx.cljs +++ b/src/status_im/keycard/fx.cljs @@ -2,7 +2,6 @@ (:require ["@react-native-async-storage/async-storage" :default AsyncStorage] ["react-native" :refer (BackHandler)] - [native-module.core :as native-module] [re-frame.core :as re-frame] [status-im.keycard.card :as card] [status-im.utils.deprecated-types :as types] @@ -200,15 +199,6 @@ (fn [^js listener] (.remove listener))) -(re-frame/reg-fx - :keycard/generate-name - (fn [{:keys [public-key on-success]}] - (native-module/gfycat-identicon-async - public-key - (fn [whisper-name photo-path] - (re-frame/dispatch - [on-success whisper-name photo-path]))))) - (re-frame/reg-fx :keycard/save-multiaccount-and-login card/save-multiaccount-and-login) diff --git a/src/status_im/keycard/recovery.cljs b/src/status_im/keycard/recovery.cljs index 1cef9a3070..f37297296d 100644 --- a/src/status_im/keycard/recovery.cljs +++ b/src/status_im/keycard/recovery.cljs @@ -179,37 +179,30 @@ ;; name might have been generated during recovery via passphrase (get-in db [:intro-wizard :derived constants/path-whisper-keyword]) {:name name})] - ;; if a name is still `nil` we have to generate it before multiaccount's - ;; creation otherwise spec validation will fail - (if (nil? name) - {:keycard/generate-name - {:public-key whisper-public-key - :on-success ::on-name-generated}} - (rf/merge cofx - {:db (-> db - (assoc-in [:keycard :setup-step] nil) - (dissoc :intro-wizard))} - (multiaccounts.create/on-multiaccount-created - {:recovered (or recovered (get-in db [:intro-wizard :recovering?])) - :derived {constants/path-wallet-root-keyword - {:public-key wallet-root-public-key - :address (eip55/address->checksum wallet-root-address)} - constants/path-whisper-keyword - {:public-key whisper-public-key - :address (eip55/address->checksum whisper-address) - :name name} - constants/path-default-wallet-keyword - {:public-key wallet-public-key - :address (eip55/address->checksum wallet-address)}} - :address address - :public-key public-key - :keycard-instance-uid instance-uid - :key-uid (address/normalized-hex key-uid) - :keycard-pairing pairing - :keycard-paired-on paired-on - :chat-key whisper-private-key} - encryption-public-key - {}))))) + (rf/merge cofx + {:db (-> db + (assoc-in [:keycard :setup-step] nil) + (dissoc :intro-wizard))} + (multiaccounts.create/on-multiaccount-created + {:recovered (or recovered (get-in db [:intro-wizard :recovering?])) + :derived {constants/path-wallet-root-keyword + {:public-key wallet-root-public-key + :address (eip55/address->checksum wallet-root-address)} + constants/path-whisper-keyword + {:public-key whisper-public-key + :address (eip55/address->checksum whisper-address)} + constants/path-default-wallet-keyword + {:public-key wallet-public-key + :address (eip55/address->checksum wallet-address)}} + :address address + :public-key public-key + :keycard-instance-uid instance-uid + :key-uid (address/normalized-hex key-uid) + :keycard-pairing pairing + :keycard-paired-on paired-on + :chat-key whisper-private-key} + encryption-public-key + {})))) (rf/defn return-to-keycard-login [{:keys [db] :as cofx}] @@ -381,17 +374,3 @@ {:on-card-connected :keycard/load-recovering-key-screen :handler (common/dispatch-event :keycard/import-multiaccount)})) -(rf/defn on-name-generated - {:events [::on-name-generated] - :interceptors [(re-frame/inject-cofx :random-guid-generator) - (re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]} - [{:keys [db] :as cofx} whisper-name] - (rf/merge - cofx - {:db (update-in db - [:keycard :profile/profile] - (fn [multiacc] - (assoc multiacc - :recovered (get db :recovered-account?) - :name whisper-name)))} - (create-keycard-multiaccount))) diff --git a/src/status_im/keycard/simulated_keycard.cljs b/src/status_im/keycard/simulated_keycard.cljs index 559cfb42e5..734208c0ca 100644 --- a/src/status_im/keycard/simulated_keycard.cljs +++ b/src/status_im/keycard/simulated_keycard.cljs @@ -265,16 +265,10 @@ constants/path-default-wallet] (fn [result] (let [derived-data (multiaccounts.create/normalize-derived-data-keys - (types/json->clj result)) - public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] - (native-module/gfycat-identicon-async - public-key - (fn [name _] - (let [derived-data-extended - (update derived-data constants/path-whisper-keyword assoc :name name)] - (reset! derived-acc - {:root-key root-data - :derived derived-data-extended}))))))))))) + (types/json->clj result))] + (reset! derived-acc + {:root-key root-data + :derived derived-data})))))))) (when (= password (get @state :password)) (swap! state assoc-in [:application-info :paired?] true) (later #(on-success (str (rand-int 10000000)))))) diff --git a/src/status_im/multiaccounts/core.cljs b/src/status_im/multiaccounts/core.cljs deleted file mode 100644 index fccbfe451b..0000000000 --- a/src/status_im/multiaccounts/core.cljs +++ /dev/null @@ -1,234 +0,0 @@ -(ns status-im.multiaccounts.core - (:require - [clojure.string :as string] - [native-module.core :as native-module] - [quo.foundations.colors :as colors] - [re-frame.core :as re-frame] - [react-native.platform :as platform] - [status-im.bottom-sheet.events :as bottom-sheet] - [status-im.contact.db :as contact.db] - [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.utils.gfycat.core :as gfycat] - [status-im2.common.theme.core :as theme] - [status-im2.constants :as constants] - [status-im2.contexts.shell.jump-to.utils :as shell.utils] - [status-im2.setup.hot-reload :as hot-reload] - [taoensso.timbre :as log] - [utils.re-frame :as rf])) - -;; validate that the given mnemonic was generated from Status Dictionary -(re-frame/reg-fx - ::validate-mnemonic - (fn [[passphrase callback]] - (native-module/validate-mnemonic passphrase callback))) - -(defn displayed-name - "Use preferred name, display-name, name or alias in that order" - [{:keys [name display-name preferred-name alias public-key ens-verified primary-name]}] - (let [display-name (if (string/blank? display-name) nil display-name) - preferred-name (if (string/blank? preferred-name) nil preferred-name) - ens-name (or preferred-name - display-name - name)] - ;; Preferred name is our own otherwise we make sure it's verified - (if (or preferred-name (and ens-verified name)) - ens-name - (or display-name primary-name alias (gfycat/generate-gfy public-key))))) - -(defn contact-by-identity - [contacts contact-identity] - (or (get contacts contact-identity) - (contact.db/public-key->new-contact contact-identity))) - -(defn contact-two-names-by-identity - [contact profile contact-identity] - (let [{:keys [public-key preferred-name display-name]} profile - {:keys [primary-name secondary-name]} contact - me? (= public-key contact-identity)] - (if me? - [(cond - (not (string/blank? preferred-name)) preferred-name - (not (string/blank? display-name)) display-name - (not (string/blank? primary-name)) primary-name - :else (gfycat/generate-gfy contact-identity))] - [primary-name secondary-name]))) - -(defn displayed-photo - [{:keys [images]}] - (or (:thumbnail images) - (:large images) - (first images))) - -(re-frame/reg-fx - ::webview-debug-changed - (fn [value] - (when platform/android? - (native-module/toggle-webview-debug value)))) - -(re-frame/reg-fx - ::blank-preview-flag-changed - (fn [flag] - (native-module/set-blank-preview-flag flag))) - -(rf/defn confirm-wallet-set-up - {:events [:multiaccounts.ui/wallet-set-up-confirmed]} - [cofx] - (multiaccounts.update/multiaccount-update cofx - :wallet-set-up-passed? - true - {})) - -(rf/defn switch-webview-debug - {:events [:multiaccounts.ui/switch-webview-debug]} - [{:keys [db] :as cofx} value] - (rf/merge cofx - {::webview-debug-changed value} - (multiaccounts.update/multiaccount-update - :webview-debug - (boolean value) - {}))) - -(rf/defn switch-preview-privacy-mode - {:events [:multiaccounts.ui/preview-privacy-mode-switched]} - [{:keys [db] :as cofx} private?] - (rf/merge cofx - {::blank-preview-flag-changed private?} - (multiaccounts.update/multiaccount-update - :preview-privacy? - (boolean private?) - {}))) - -(rf/defn switch-webview-permission-requests? - {:events [:multiaccounts.ui/webview-permission-requests-switched]} - [cofx enabled?] - (multiaccounts.update/multiaccount-update - cofx - :webview-allow-permission-requests? - (boolean enabled?) - {})) - -(rf/defn switch-default-sync-period - {:events [:multiaccounts.ui/default-sync-period-switched]} - [cofx value] - (multiaccounts.update/multiaccount-update - cofx - :default-sync-period - value - {})) - -(rf/defn switch-preview-privacy-mode-flag - [{:keys [db]}] - (let [private? (get-in db [:profile/profile :preview-privacy?])] - {::blank-preview-flag-changed private?})) - -(re-frame/reg-fx - :multiaccounts.ui/switch-theme-fx - (fn [[theme-type view-id reload-ui?]] - (let [[theme status-bar-theme nav-bar-color] - ;; Status bar theme represents status bar icons colors, so opposite to app theme - (if (or (= theme-type constants/theme-type-dark) - (and (= theme-type constants/theme-type-system) - (theme/device-theme-dark?))) - [:dark :light colors/neutral-100] - [:light :dark colors/white])] - (theme/set-theme theme) - (re-frame/dispatch [:change-shell-status-bar-style - (if (shell.utils/home-stack-open?) status-bar-theme :light)]) - (when reload-ui? - (rf/dispatch [:dissmiss-all-overlays]) - (hot-reload/reload) - (when-not (= view-id :shell-stack) - (re-frame/dispatch [:change-shell-nav-bar-color nav-bar-color])))))) - -(rf/defn switch-appearance - {:events [:multiaccounts.ui/appearance-switched]} - [cofx theme] - (rf/merge cofx - {:multiaccounts.ui/switch-theme-fx [theme :appearance true]} - (multiaccounts.update/multiaccount-update :appearance theme {}))) - -(rf/defn switch-theme - {:events [:multiaccounts.ui/switch-theme]} - [cofx theme view-id] - (let [theme (or theme - (get-in cofx [:db :profile/profile :appearance]) - constants/theme-type-dark)] - {:multiaccounts.ui/switch-theme-fx [theme view-id false]})) - -(rf/defn switch-profile-picture-show-to - {:events [:multiaccounts.ui/profile-picture-show-to-switched]} - [cofx id] - (rf/merge cofx - {:json-rpc/call [{:method "wakuext_changeIdentityImageShowTo" - :params [id] - :on-success #(log/debug "picture settings changed successfully")}]} - (multiaccounts.update/optimistic :profile-pictures-show-to id))) - -(rf/defn switch-appearance-profile - {:events [:multiaccounts.ui/appearance-profile-switched]} - [cofx id] - (multiaccounts.update/multiaccount-update cofx :profile-pictures-visibility id {})) - -(defn clean-path - [path] - (if path - (string/replace-first path #"file://" "") - (log/warn "[native-module] Empty path was provided"))) - -(rf/defn save-profile-picture - {:events [::save-profile-picture]} - [cofx path ax ay bx by] - (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] - (rf/merge cofx - {:json-rpc/call [{:method "multiaccounts_storeIdentityImage" - :params [key-uid (clean-path path) ax ay bx by] - ;; NOTE: In case of an error we can show a toast error - :on-success #(re-frame/dispatch [::update-local-picture %])}]} - (bottom-sheet/hide-bottom-sheet-old)))) - -(rf/defn save-profile-picture-from-url - {:events [::save-profile-picture-from-url]} - [cofx url] - (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] - (rf/merge cofx - {:json-rpc/call [{:method "multiaccounts_storeIdentityImageFromURL" - :params [key-uid url] - :on-error #(log/error "::save-profile-picture-from-url error" %) - :on-success #(re-frame/dispatch [::update-local-picture %])}]} - (bottom-sheet/hide-bottom-sheet-old)))) - -(comment - (re-frame/dispatch - [::save-profile-picture-from-url - "https://lh3.googleusercontent.com/XuKjNm3HydsaxbPkbpGs9YyCKhn5QQk5oDC8XF2jzmPyYXeZofxFtfUDZuQ3EVmacS_BlBKzbX2ypm37YNX3n1fDJA3WndeFcPsp7Z0=w600"])) - -(rf/defn delete-profile-picture - {:events [::delete-profile-picture]} - [cofx name] - (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] - (rf/merge cofx - {:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" - :params [key-uid] - ;; NOTE: In case of an error we could fallback to previous image in - ;; UI with a toast error - :on-success #(log/info "[multiaccount] Delete profile image" %)}]} - (multiaccounts.update/optimistic :images nil) - (bottom-sheet/hide-bottom-sheet-old)))) - -(rf/defn get-profile-picture - [cofx] - (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] - {:json-rpc/call [{:method "multiaccounts_getIdentityImages" - :params [key-uid] - :on-success #(re-frame/dispatch [::update-local-picture %])}]})) - -(rf/defn store-profile-picture - {:events [::update-local-picture]} - [cofx pics] - (multiaccounts.update/optimistic cofx :images pics)) - -(comment - ;; Test seed for Dim Venerated Yaffle, it's not here by mistake, this is just a test account - (native-module/validate-mnemonic - "rocket mixed rebel affair umbrella legal resemble scene virus park deposit cargo" - prn)) diff --git a/src/status_im/multiaccounts/logout/core.cljs b/src/status_im/multiaccounts/logout/core.cljs index 43ac739110..4df946aec7 100644 --- a/src/status_im/multiaccounts/logout/core.cljs +++ b/src/status_im/multiaccounts/logout/core.cljs @@ -2,7 +2,6 @@ (:require [native-module.core :as native-module] [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im.wallet.core :as wallet] [status-im2.common.keychain.events :as keychain] [status-im2.db :as db] @@ -30,15 +29,15 @@ [{:keys [db] :as cofx} {:keys [auth-method logout?]}] (let [key-uid (get-in db [:profile/profile :key-uid])] (rf/merge cofx - {:set-root :progress - :chat.ui/clear-inputs nil - :shell/reset-state nil - :hide-popover nil - ::logout nil - ::multiaccounts/webview-debug-changed false - :keychain/clear-user-password key-uid - :profile/get-profiles-overview #(rf/dispatch - [:profile/get-profiles-overview-success %])} + {:set-root :progress + :chat.ui/clear-inputs nil + :shell/reset-state nil + :hide-popover nil + ::logout nil + :profile.settings/webview-debug-changed false + :keychain/clear-user-password key-uid + :profile/get-profiles-overview #(rf/dispatch + [:profile/get-profiles-overview-success %])} (keychain/save-auth-method key-uid auth-method) (wallet/clear-timeouts) (initialize-app-db)))) diff --git a/src/status_im/multiaccounts/recover/core.cljs b/src/status_im/multiaccounts/recover/core.cljs index f0481e97e2..6b97076366 100644 --- a/src/status_im/multiaccounts/recover/core.cljs +++ b/src/status_im/multiaccounts/recover/core.cljs @@ -26,12 +26,6 @@ constants/path-default-wallet] (fn [result] (let [derived-data (multiaccounts.create/normalize-derived-data-keys - (types/json->clj result)) - public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] - (native-module/gfycat-identicon-async - public-key - (fn [name _] - (let [derived-data-extended - (update derived-data constants/path-whisper-keyword assoc :name name)] - (re-frame/dispatch [success-event root-data derived-data-extended])))))))))))) + (types/json->clj result))] + (re-frame/dispatch [success-event root-data derived-data]))))))))) diff --git a/src/status_im/ui/components/chat_icon/screen.cljs b/src/status_im/ui/components/chat_icon/screen.cljs index ac9cada3b3..66526ac44f 100644 --- a/src/status_im/ui/components/chat_icon/screen.cljs +++ b/src/status_im/ui/components/chat_icon/screen.cljs @@ -7,12 +7,12 @@ [re-frame.core :as re-frame.core] [react-native.core :as rn] [status-im.ethereum.ens :as ens] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.chat-icon.styles :as styles] [status-im.ui.components.colors :as colors] [status-im.ui.components.icons.icons :as icons] [status-im.ui.screens.chat.photos :as photos] - [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils])) + [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] + [status-im2.contexts.profile.utils :as profile.utils])) ;;TODO REWORK THIS NAMESPACE @@ -161,14 +161,14 @@ (defn contact-icon-view [contact {:keys [container] :as styles}] [rn/view container - [photos/photo (multiaccounts/displayed-photo contact) styles]]) + [photos/photo (profile.utils/photo contact) styles]]) (defn contact-icon-contacts-tab - [{:keys [primary-name] :as contact}] + [profile] [rn/view styles/container-chat-list [quo/user-avatar - {:full-name primary-name - :profile-picture (multiaccounts/displayed-photo contact) + {:full-name (profile.utils/displayed-name profile) + :profile-picture (profile.utils/photo profile) :size :small :status-indicator? false}]]) diff --git a/src/status_im/ui/screens/advanced_settings/views.cljs b/src/status_im/ui/screens/advanced_settings/views.cljs index 42a0e248e2..3a70aa54d2 100644 --- a/src/status_im/ui/screens/advanced_settings/views.cljs +++ b/src/status_im/ui/screens/advanced_settings/views.cljs @@ -92,7 +92,7 @@ :container-margin-bottom 8 :on-press #(re-frame/dispatch - [:multiaccounts.ui/switch-webview-debug (not webview-debug)]) + [:profile.settings/change-webview-debug (not webview-debug)]) :accessory :switch :active webview-debug} {:size :small diff --git a/src/status_im/ui/screens/appearance/views.cljs b/src/status_im/ui/screens/appearance/views.cljs index de6c327534..69df7b8bdc 100644 --- a/src/status_im/ui/screens/appearance/views.cljs +++ b/src/status_im/ui/screens/appearance/views.cljs @@ -11,7 +11,7 @@ (defn button [label icon theme selected?] [react/touchable-highlight - {:on-press #(re-frame/dispatch [:multiaccounts.ui/appearance-switched theme])} + {:on-press #(re-frame/dispatch [:profile.settings/change-appearance theme])} [react/view (merge {:align-items :center :padding 8 :border-radius 20} (when selected? diff --git a/src/status_im/ui/screens/communities/members.cljs b/src/status_im/ui/screens/communities/members.cljs index c3b896ba46..37db0f635f 100644 --- a/src/status_im/ui/screens/communities/members.cljs +++ b/src/status_im/ui/screens/communities/members.cljs @@ -3,7 +3,6 @@ [react-native.core :as rn] [reagent.core :as reagent] [status-im.communities.core :as communities] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.chat-icon.screen :as chat-icon] [status-im.ui.components.core :as quo] [status-im.ui.components.list.item :as list.item] @@ -11,6 +10,7 @@ [status-im.ui.components.topbar :as topbar] [status-im.ui.components.unviewed-indicator :as unviewed-indicator] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -69,7 +69,7 @@ :accessibility-label :member-item :icon [chat-icon/profile-photo-plus-dot-view {:public-key public-key - :photo-path (multiaccounts/displayed-photo member)}] + :photo-path (profile.utils/photo member)}] :accessory (when (not= public-key my-public-key) [quo/button {:on-press diff --git a/src/status_im/ui/screens/contacts_list/views.cljs b/src/status_im/ui/screens/contacts_list/views.cljs index 8a4ff8cbae..0289fb13e2 100644 --- a/src/status_im/ui/screens/contacts_list/views.cljs +++ b/src/status_im/ui/screens/contacts_list/views.cljs @@ -1,13 +1,13 @@ (ns status-im.ui.screens.contacts-list.views (:require [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.chat-icon.screen :as chat-icon.screen] [status-im.ui.components.colors :as colors] [status-im.ui.components.invite.views :as invite] [status-im.ui.components.list.item :as list.item] [status-im.ui.components.list.views :as list.views] [status-im.ui.components.react :as react] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) @@ -21,7 +21,7 @@ {:public-key public-key :full-name primary-name :customization-color (or customization-color :primary) - :photo-path (multiaccounts/displayed-photo contact)}] + :photo-path (profile.utils/photo contact)}] :chevron true :on-press #(re-frame/dispatch [:chat.ui/show-profile public-key])}])) diff --git a/src/status_im/ui/screens/default_sync_period_settings/view.cljs b/src/status_im/ui/screens/default_sync_period_settings/view.cljs index 61605f4753..fe04f5ecae 100644 --- a/src/status_im/ui/screens/default_sync_period_settings/view.cljs +++ b/src/status_im/ui/screens/default_sync_period_settings/view.cljs @@ -21,7 +21,7 @@ {:active (= value id) :accessory :radio :title (get titles id) - :on-press #(re-frame/dispatch [:multiaccounts.ui/default-sync-period-switched id])}]) + :on-press #(re-frame/dispatch [:profile.settings/update-value :default-sync-period id])}]) (views/defview default-sync-period-settings [] diff --git a/src/status_im/ui/screens/keycard/recovery/views.cljs b/src/status_im/ui/screens/keycard/recovery/views.cljs index 74afc22c83..2f7b80164a 100644 --- a/src/status_im/ui/screens/keycard/recovery/views.cljs +++ b/src/status_im/ui/screens/keycard/recovery/views.cljs @@ -14,8 +14,6 @@ [status-im.ui.screens.keycard.styles :as styles] [status-im.ui.screens.keycard.views :as keycard.views] [status-im.utils.core :as utils.core] - [status-im.utils.gfycat.core :as gfy] - [status-im.utils.identicon :as identicon] [status-im2.constants :as constants] [utils.i18n :as i18n]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) @@ -207,24 +205,13 @@ [react/view {:margin-horizontal 16 :flex-direction :column} - [react/view - {:justify-content :center - :align-items :center - :margin-bottom 11} - [react/image - {:source {:uri (identicon/identicon whisper-public-key)} - :style {:width 61 - :height 61 - :border-radius 30 - :border-width 1 - :border-color colors/black-transparent}}]] [react/text {:style {:text-align :center :color colors/black :font-weight "500"} :number-of-lines 1 :ellipsize-mode :middle} - (gfy/generate-gfy whisper-public-key)] + whisper-public-key] [quo/text {:style {:margin-top 4} :monospace true diff --git a/src/status_im/ui/screens/keycard/views.cljs b/src/status_im/ui/screens/keycard/views.cljs index 60509cd855..05fffaeaff 100644 --- a/src/status_im/ui/screens/keycard/views.cljs +++ b/src/status_im/ui/screens/keycard/views.cljs @@ -5,7 +5,6 @@ [reagent.core :as reagent] [status-im.bottom-sheet.events :as bottom-sheet] [status-im.keycard.login :as keycard.login] - [status-im.multiaccounts.core :as multiaccounts] [status-im.react-native.resources :as resources] [status-im.ui.components.colors :as colors] [status-im.ui.components.core :as quo] @@ -19,6 +18,7 @@ [status-im.ui.screens.keycard.pin.views :as pin.views] [status-im.ui.screens.keycard.styles :as styles] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [status-im2.navigation.events :as navigation] [utils.i18n :as i18n] [utils.re-frame :as rf]) @@ -212,7 +212,7 @@ :reagent-render (fn [account small-screen?] ;;TODO this should be done in a subscription - [photos/photo (multiaccounts/displayed-photo account) + [photos/photo (profile.utils/photo account) {:size (if small-screen? 45 61)}])})) (defn access-is-reset diff --git a/src/status_im/ui/screens/privacy_and_security_settings/delete_profile.cljs b/src/status_im/ui/screens/privacy_and_security_settings/delete_profile.cljs index 50ee0aeec5..07eea6a8e0 100644 --- a/src/status_im/ui/screens/privacy_and_security_settings/delete_profile.cljs +++ b/src/status_im/ui/screens/privacy_and_security_settings/delete_profile.cljs @@ -3,12 +3,12 @@ [re-frame.core :as re-frame] [reagent.core :as reagent] status-im.keycard.delete-key - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.chat-icon.screen :as chat-icon.screen] [status-im.ui.components.core :as quo] [status-im.ui.components.list.item :as list.item] [status-im.ui.components.react :as react] [status-im.ui.screens.privacy-and-security-settings.events :as delete-profile] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.security.core :as security])) @@ -33,10 +33,11 @@ (let [password (reagent/atom nil) text-input-ref (atom nil)] (fn [] - (let [keycard? @(re-frame/subscribe [:keycard-multiaccount?]) - multiaccount @(re-frame/subscribe [:profile/profile]) + (let [profile @(re-frame/subscribe [:profile/profile]) + keycard? @(re-frame/subscribe [:keycard-multiaccount?]) error @(re-frame/subscribe [:delete-profile/error]) - keep-keys-on-keycard? @(re-frame/subscribe [:delete-profile/keep-keys-on-keycard?])] + keep-keys-on-keycard? @(re-frame/subscribe + [:delete-profile/keep-keys-on-keycard?])] (when (and @text-input-ref error (not @password)) (.clear ^js @text-input-ref)) [react/keyboard-avoiding-view {:style {:flex 1}} @@ -47,8 +48,8 @@ :size :x-large} (i18n/label :t/delete-profile)]] [list.item/list-item - {:title (multiaccounts/displayed-name multiaccount) - :icon [chat-icon.screen/contact-icon-contacts-tab multiaccount]}] + {:title (profile.utils/displayed-name profile) + :icon [chat-icon.screen/contact-icon-contacts-tab profile]}] (when keycard? [react/view [quo/list-header (i18n/label :t/actions)] diff --git a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs index e38a73457b..6fe74eb3dd 100644 --- a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs +++ b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs @@ -64,7 +64,7 @@ :active preview-privacy? :accessory :switch :on-press #(re-frame/dispatch - [:multiaccounts.ui/preview-privacy-mode-switched + [:profile.settings/change-preview-privacy ((complement boolean) preview-privacy?)])}] (when config/collectibles-enabled? [list.item/list-item @@ -111,7 +111,8 @@ :subtitle (i18n/label :t/webview-camera-permission-requests-subtitle) :subtitle-max-lines 2 :on-press #(re-frame/dispatch - [:multiaccounts.ui/webview-permission-requests-switched + [:profile.settings/update-value + :webview-allow-permission-requests? ((complement boolean) webview-allow-permission-requests?)])}]) [separator] [quo/list-header (i18n/label :t/privacy-photos)] @@ -148,7 +149,7 @@ {:active (= value id) :accessory :radio :title (get titles id) - :on-press #(re-frame/dispatch [:multiaccounts.ui/profile-picture-show-to-switched id])}]) + :on-press #(re-frame/dispatch [:profile.settings/change-profile-pictures-show-to id])}]) (views/defview profile-pic-show-to [] @@ -168,7 +169,8 @@ {:active (= value id) :accessory :radio :title (get titles id) - :on-press #(re-frame/dispatch [:multiaccounts.ui/appearance-profile-switched id])}]) + :on-press #(re-frame/dispatch [:profile.settings/update-value :profile-pictures-visibility + id])}]) (views/defview profile-pic [] diff --git a/src/status_im/ui/screens/profile/contact/views.cljs b/src/status_im/ui/screens/profile/contact/views.cljs index e9532555ce..be4fed60b5 100644 --- a/src/status_im/ui/screens/profile/contact/views.cljs +++ b/src/status_im/ui/screens/profile/contact/views.cljs @@ -5,7 +5,6 @@ [quo.theme :as theme] [re-frame.core :as re-frame] [reagent.core :as reagent] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.colors :as colors] [status-im.ui.components.core :as quo] [status-im.ui.components.keyboard-avoid-presentation :as kb-presentation] @@ -16,11 +15,12 @@ [status-im.ui.components.topbar :as topbar] [status-im.ui.screens.profile.components.sheets :as sheets] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.re-frame :as rf])) (defn actions - [{:keys [public-key added? blocked? ens-name mutual?] :as contact} muted?] + [{:keys [public-key added? blocked? ens-name mutual?] :as profile} muted?] (concat [{:label (i18n/label :t/chat) :icon :main-icons/message :disabled (not mutual?) @@ -33,7 +33,7 @@ :icon :main-icons/remove-contact :selected true :accessibility-label :in-contacts-button - :action #(re-frame/dispatch [:contact.ui/remove-contact-pressed contact])}] + :action #(re-frame/dispatch [:contact.ui/remove-contact-pressed profile])}] [{:label (i18n/label :t/add-to-contacts) :icon :main-icons/add-contact :disabled blocked? @@ -114,15 +114,15 @@ (defn nickname-view [] - (let [{:keys [public-key primary-name nickname]} (rf/sub [:contacts/current-contact]) - entered-nickname (reagent/atom nickname)] + (let [{:keys [public-key nickname] :as profile} (rf/sub [:contacts/current-contact]) + entered-nickname (reagent/atom nickname)] (fn [] [kb-presentation/keyboard-avoiding-view {:style {:flex 1} :ignore-offset true} [topbar/topbar {:title (i18n/label :t/nickname) - :subtitle primary-name + :subtitle (profile.utils/displayed-name profile) :modal? true}] [react/view {:flex 1 :padding 16} [react/text {:style {:color colors/gray :margin-bottom 16}} @@ -173,29 +173,25 @@ :number-of-lines 2} label]]]) -(defn profile +(defn profile-view [] (let [{:keys [public-key + secondary-name name ens-verified + customization-color compressed-key] - :as contact} - @(re-frame/subscribe - [:contacts/current-contact]) - - muted? @(re-frame/subscribe [:chats/muted - public-key]) - {:keys [primary-name secondary-name customization-color]} contact + :as profile} @(re-frame/subscribe [:contacts/current-contact]) + muted? @(re-frame/subscribe [:chats/muted public-key]) customization-color (or customization-color :primary) - on-share #(re-frame/dispatch - [:show-popover - (merge - {:view :share-chat-key - :address (or compressed-key - public-key)} - (when (and ens-verified name) - {:ens-name name}))])] - (when contact + on-share #(re-frame/dispatch [:show-popover + (merge + {:view :share-chat-key + :address (or compressed-key + public-key)} + (when (and ens-verified name) + {:ens-name name}))])] + (when profile [:<> [quo/header {:right-accessories [{:icon :main-icons/share @@ -206,27 +202,26 @@ :on-press #(re-frame/dispatch [:navigate-back])}]}] [:<> [(profile-header/extended-header - {:on-press on-share + {:on-press on-share :bottom-separator false - :title primary-name - :color - (user-avatar.style/customization-color customization-color - (theme/get-theme)) - :photo (multiaccounts/displayed-photo contact) - :monospace (not ens-verified) - :subtitle secondary-name - :compressed-key compressed-key - :public-key public-key})] + :title (profile.utils/displayed-name profile) + :color (user-avatar.style/customization-color customization-color + (theme/get-theme)) + :photo (profile.utils/photo profile) + :monospace (not ens-verified) + :subtitle secondary-name + :compressed-key compressed-key + :public-key public-key})] [react/view {:height 1 :background-color colors/gray-lighter :margin-top 8}] - [nickname-settings contact] + [nickname-settings profile] [react/view {:height 1 :background-color colors/gray-lighter}] [react/view {:padding-top 17 :flex-direction :row :align-items :stretch :flex 1} - (for [{:keys [label] :as action} (actions contact muted?) + (for [{:keys [label] :as action} (actions profile muted?) :when label] ^{:key label} [button-item action])]]]))) diff --git a/src/status_im/ui/screens/profile/group_chat/views.cljs b/src/status_im/ui/screens/profile/group_chat/views.cljs index ec36e9290f..bcee485404 100644 --- a/src/status_im/ui/screens/profile/group_chat/views.cljs +++ b/src/status_im/ui/screens/profile/group_chat/views.cljs @@ -1,7 +1,6 @@ (ns status-im.ui.screens.profile.group-chat.views (:require [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.chat-icon.screen :as chat-icon] [status-im.ui.components.colors :as colors] [status-im.ui.components.common.common :as components.common] @@ -16,6 +15,7 @@ [status-im.ui.screens.chat.utils :as chat.utils] [status-im.ui.screens.profile.components.styles :as profile.components.styles] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [utils.debounce :as debounce] [utils.i18n :as i18n]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) @@ -26,15 +26,14 @@ [list.item/list-item {:theme :accent :icon [chat-icon/contact-icon-contacts-tab member] - :title (:primary-name member) + :title (profile.utils/displayed-name member) :subtitle (i18n/label :t/view-profile) :accessibility-label :view-chat-details-button :chevron true :on-press #(chat.sheets/hide-sheet-and-dispatch [:chat.ui/show-profile (:public-key member)])}] - (when (and us-admin? - (not (:admin? member))) + (when (and us-admin? (not (:admin? member))) [list.item/list-item {:theme :accent :title (i18n/label :t/make-admin) @@ -54,10 +53,10 @@ (defn render-member [{:keys [public-key] :as member} _ _ {:keys [chat-id admin? current-user-identity]}] - (let [{:keys [primary-name secondary-name]} member] + (let [{:keys [secondary-name]} member] [list.item/list-item (merge - {:title primary-name + {:title (profile.utils/displayed-name member) :subtitle secondary-name :accessibility-label :member-item :icon [chat-icon/contact-icon-contacts-tab member] @@ -118,7 +117,7 @@ (chat.utils/format-author-old contact)] [react/view {:flex-direction :row :align-items :flex-end} [react/view {:padding-left 16 :padding-top 4} - [photos/photo (multiaccounts/displayed-photo contact) {:size 36}]]]] + [photos/photo (profile.utils/photo contact) {:size 36}]]]] [list.item/list-item {:theme :accent :disabled (not allow-adding-members?) @@ -137,9 +136,10 @@ (defn contacts-list-item [{:keys [from] :as invitation}] - (let [contact (or @(re-frame/subscribe [:contacts/contact-by-identity from]) {:public-key from})] + (let [contact (or @(re-frame/subscribe [:contacts/contact-by-identity from]) + {:public-key from})] [list.item/list-item - {:title (multiaccounts/displayed-name contact) + {:title (profile.utils/displayed-name contact) :icon [chat-icon/contact-icon-contacts-tab contact] :on-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old {:content (fn [] diff --git a/src/status_im/ui/screens/profile/user/edit_picture.cljs b/src/status_im/ui/screens/profile/user/edit_picture.cljs index 8177adba96..8660e59441 100644 --- a/src/status_im/ui/screens/profile/user/edit_picture.cljs +++ b/src/status_im/ui/screens/profile/user/edit_picture.cljs @@ -1,10 +1,10 @@ (ns status-im.ui.screens.profile.user.edit-picture (:require [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.list.item :as list.item] [status-im.ui.components.react :as react] [status-im2.config :as config] + [status-im2.contexts.profile.settings.events] [utils.i18n :as i18n])) (def crop-size 1000) @@ -18,14 +18,14 @@ [] (re-frame/dispatch [:bottom-sheet/hide-old]) (react/show-image-picker - #(re-frame/dispatch [::multiaccounts/save-profile-picture (.-path ^js %) 0 0 crop-size crop-size]) + #(re-frame/dispatch [:profile.settings/save-profile-picture (.-path ^js %) 0 0 crop-size crop-size]) crop-opts)) (defn take-pic [] (re-frame/dispatch [:bottom-sheet/hide-old]) (react/show-image-picker-camera - #(re-frame/dispatch [::multiaccounts/save-profile-picture (.-path ^js %) 0 0 crop-size crop-size]) + #(re-frame/dispatch [:profile.settings/save-profile-picture (.-path ^js %) 0 0 crop-size crop-size]) crop-opts)) (defn bottom-sheet @@ -51,4 +51,4 @@ :icon :main-icons/delete :theme :accent :title (i18n/label :t/profile-pic-remove) - :on-press #(re-frame/dispatch [::multiaccounts/delete-profile-picture nil])}])])) + :on-press #(re-frame/dispatch [:profile.settings/delete-profile-picture nil])}])])) diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index d1e69d131b..00b7c88acd 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -5,7 +5,6 @@ [re-frame.core :as re-frame] [reagent.core :as reagent] [status-im.ethereum.stateofus :as stateofus] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.colors :as colors] [status-im.ui.components.common.common :as components.common] [status-im.ui.components.copyable-text :as copyable-text] @@ -18,11 +17,11 @@ [status-im.ui.screens.profile.user.edit-picture :as edit] [status-im.ui.screens.profile.user.styles :as styles] [status-im.ui.screens.profile.visibility-status.views :as visibility-status] - [status-im.utils.gfycat.core :as gfy] [status-im.utils.universal-links.utils :as universal-links] [status-im.utils.utils :as utils] [status-im2.common.qr-codes.view :as qr-codes] [status-im2.config :as config] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n]) (:require-macros [status-im.utils.views :as views])) @@ -198,8 +197,8 @@ ens-verified preferred-name key-uid] - :as account} - @(re-frame/subscribe [:profile/multiaccount]) + :as profile} + @(re-frame/subscribe [:profile/profile-with-image]) customization-color (or (:color @(re-frame/subscribe [:onboarding-2/profile])) @(re-frame/subscribe [:profile/customization-color key-uid])) on-share #(re-frame/dispatch [:show-popover @@ -224,12 +223,8 @@ has-picture)}]) :color (user-avatar.style/customization-color customization-color (theme/get-theme)) - :title (multiaccounts/displayed-name account) - :photo (multiaccounts/displayed-photo account) + :title (profile.utils/displayed-name profile) + :photo (profile.utils/photo profile) :monospace (not ens-verified) - :subtitle (if (and ens-verified public-key) - (gfy/generate-gfy public-key) - (utils/get-shortened-address (or - compressed-key - public-key)))})} + :subtitle (utils/get-shortened-address (or compressed-key public-key))})} [content]]]))) diff --git a/src/status_im/ui/screens/screens.cljs b/src/status_im/ui/screens/screens.cljs index e0ab98d157..fc910f5c5f 100644 --- a/src/status_im/ui/screens/screens.cljs +++ b/src/status_im/ui/screens/screens.cljs @@ -521,7 +521,7 @@ ;;TODO custom toolbar :options {:insets {:bottom? true :top? true}} - :component contact/profile} + :component contact/profile-view} ;KEYCARD {:name :keycard-onboarding-intro diff --git a/src/status_im/ui/screens/signing/views.cljs b/src/status_im/ui/screens/signing/views.cljs index c59f89cfde..5fe58507c3 100644 --- a/src/status_im/ui/screens/signing/views.cljs +++ b/src/status_im/ui/screens/signing/views.cljs @@ -7,7 +7,6 @@ [reagent.core :as reagent] [status-im.ethereum.tokens :as tokens] [status-im.keycard.common :as keycard.common] - [status-im.multiaccounts.core :as multiaccounts] [status-im.react-native.resources :as resources] [status-im.signing.eip1559 :as eip1559] [status-im.ui.components.bottom-panel.views :as bottom-panel] @@ -26,6 +25,7 @@ [status-im.utils.deprecated-types :as types] [status-im.utils.utils :as utils] [status-im.wallet.utils :as wallet.utils] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.security.core :as security])) @@ -33,16 +33,10 @@ [] [react/view {:height 1 :background-color colors/gray-lighter}]) -(defn displayed-name - [contact] - (if (or (:preferred-name contact) (:name contact)) - (multiaccounts/displayed-name contact) - (utils/get-shortened-checksum-address (:address contact)))) - (defn contact-item - [title contact] + [title {:keys [address] :as profile}] [copyable-text/copyable-text-view - {:copied-text (:address contact)} + {:copied-text address} [list.item/list-item {:title title :title-prefix-width 45 @@ -52,7 +46,7 @@ {:ellipsize-mode :middle :number-of-lines 1 :monospace true} - (displayed-name contact)]}]]) + (profile.utils/displayed-name profile)]}]]) (defn token-item [{:keys [icon color] :as token} display-symbol] @@ -103,7 +97,7 @@ {:style {:color colors/gray} :ellipsize-mode :middle :number-of-lines 1} (i18n/label :t/to-capitalized) " " - [{:style {:color colors/black}} (displayed-name contact)]] + [{:style {:color colors/black}} (profile.utils/displayed-name contact)]] [react/text {:style {:margin-top 6 :color colors/gray}} (str fee " " fee-display-symbol " " (string/lower-case (i18n/label :t/network-fee)))])] [react/view {:padding-horizontal 24} diff --git a/src/status_im/ui/screens/wallet/collectibles/views.cljs b/src/status_im/ui/screens/wallet/collectibles/views.cljs index 977722d517..73812112df 100644 --- a/src/status_im/ui/screens/wallet/collectibles/views.cljs +++ b/src/status_im/ui/screens/wallet/collectibles/views.cljs @@ -4,7 +4,6 @@ [clojure.string :as string] [re-frame.core :as re-frame] [reagent.core :as reagent] - [status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.react-native.resources :as resources] [status-im.ui.components.accordion :as accordion] @@ -308,8 +307,8 @@ [list.item/list-item {:title (i18n/label :t/use-as-profile-picture) :theme :accent - :on-press #(re-frame/dispatch - [::multiaccounts/save-profile-picture-from-url (:image_url nft)]) + :on-press #(re-frame/dispatch [:profile.settings/save-profile-picture-from-url + (:image_url nft)]) :icon :main-icons/profile :accessibility-label :set-nft-as-pfp}]])])) diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index fac57dcc0d..35d58360d2 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -4,7 +4,6 @@ [quo.core :as quo] [re-frame.core :as re-frame] [status-im.commands.core :as commands] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.bottom-panel.views :as bottom-panel] [status-im.ui.components.chat-icon.screen :as chat-icon] [status-im.ui.components.colors :as colors] @@ -20,6 +19,7 @@ [status-im.ui.screens.wallet.send.styles :as styles] [status-im.utils.utils :as utils] [status-im.wallet.utils :as wallet.utils] + [status-im2.contexts.profile.utils :as profile.utils] [utils.address :as address] [utils.i18n :as i18n] [utils.money :as money])) @@ -78,14 +78,14 @@ :content-height 300}]))}]) (defn render-contact - [contact from-chat?] + [{:keys [address] :as contact} from-chat?] (if from-chat? [list.item/list-item - {:title (multiaccounts/displayed-name contact) + {:title (profile.utils/displayed-name contact) :subtitle [components.core/text {:monospace true :color :secondary} - (utils/get-shortened-checksum-address (:address contact))] + (utils/get-shortened-checksum-address address)] :icon [chat-icon/contact-icon-contacts-tab contact]}] [list.item/list-item (merge {:title (if-not contact @@ -94,7 +94,7 @@ {:size :large :monospace true} (utils/get-shortened-checksum-address - (if (string? contact) contact (:address contact)))]) + (if (string? contact) contact address))]) :accessibility-label :choose-recipient-button :on-press #(do (re-frame/dispatch [:dismiss-keyboard]) diff --git a/src/status_im/ui/screens/wallet/signing_phrase/views.cljs b/src/status_im/ui/screens/wallet/signing_phrase/views.cljs index b047ebcb6a..53b93a5c8a 100644 --- a/src/status_im/ui/screens/wallet/signing_phrase/views.cljs +++ b/src/status_im/ui/screens/wallet/signing_phrase/views.cljs @@ -47,7 +47,8 @@ [quo/button {:on-press #(do (when-not wallet-set-up-passed? - (re-frame/dispatch [:multiaccounts.ui/wallet-set-up-confirmed])) + (re-frame/dispatch [:profile.settings/update-value + :wallet-set-up-passed? true])) (re-frame/dispatch [:hide-popover])) :type :secondary} (i18n/label :t/ok-got-it)]]]])) diff --git a/src/status_im/utils/gfycat/core.cljs b/src/status_im/utils/gfycat/core.cljs deleted file mode 100644 index 024caea6a9..0000000000 --- a/src/status_im/utils/gfycat/core.cljs +++ /dev/null @@ -1,14 +0,0 @@ -(ns status-im.utils.gfycat.core - (:require - [native-module.core :as native-module])) - -(def unknown-gfy "Unknown") - -(defn- build-gfy - [public-key] - (case public-key - nil unknown-gfy - "0" unknown-gfy - (native-module/generate-gfycat public-key))) - -(def generate-gfy (memoize build-gfy)) diff --git a/src/status_im/utils/identicon.cljs b/src/status_im/utils/identicon.cljs deleted file mode 100644 index 288e3f513a..0000000000 --- a/src/status_im/utils/identicon.cljs +++ /dev/null @@ -1,5 +0,0 @@ -(ns status-im.utils.identicon - (:require - [native-module.core :as native-module])) - -(def identicon (memoize native-module/identicon)) diff --git a/src/status_im/utils/test.cljs b/src/status_im/utils/test.cljs index 7cacfeb95f..d3719900b4 100644 --- a/src/status_im/utils/test.cljs +++ b/src/status_im/utils/test.cljs @@ -59,15 +59,6 @@ :logout (fn [] (.logout native-status)) - :generateAlias - (fn [seed] (.generateAlias native-status seed)) - - :generateAliasAndIdenticonAsync - (fn [seed callback] - (let [generated-identicon (.identicon native-status seed) - generated-alias (.generateAlias native-status seed)] - (callback generated-alias generated-identicon))) - :multiAccountGenerateAndDeriveAddresses (fn [json callback] (callback (.multiAccountGenerateAndDeriveAddresses native-status json))) @@ -96,9 +87,6 @@ (callback (.initKeystore native-status (str test-dir "/keystore/" key-uid)))) - :identicon - (fn [pk] (.identicon native-status pk)) - :encodeTransfer (fn [to-norm amount-hex] (.encodeTransfer native-status to-norm amount-hex)) diff --git a/src/status_im/utils/universal_links/core_test.cljs b/src/status_im/utils/universal_links/core_test.cljs index 4b40b61ee3..e344c1e952 100644 --- a/src/status_im/utils/universal_links/core_test.cljs +++ b/src/status_im/utils/universal_links/core_test.cljs @@ -3,26 +3,24 @@ [cljs.test :refer-macros [deftest is testing]] [re-frame.core :as re-frame] [status-im.router.core :as router] - [status-im.utils.gfycat.core :as gfycat] [status-im.utils.universal-links.core :as links])) (deftest handle-url-test - (with-redefs [gfycat/generate-gfy (constantly "generated")] - (testing "the user is not logged in" - (testing "it stores the url for later processing" - (is (= {:db {:universal-links/url "some-url"}} - (links/handle-url {:db {}} "some-url"))))) - (testing "the user is logged in" - (let [db {:profile/profile {:public-key "pk"} - :app-state "active" - :universal-links/url "some-url"}] - (testing "it clears the url" - (is (nil? (get-in (links/handle-url {:db db} "some-url") - [:db :universal-links/url])))) - (testing "Handle a custom string" - (is (= (get-in (links/handle-url {:db db} "https://status.app/u#statuse2e") - [::router/handle-uri :uri]) - "https://status.app/u#statuse2e"))))))) + (testing "the user is not logged in" + (testing "it stores the url for later processing" + (is (= {:db {:universal-links/url "some-url"}} + (links/handle-url {:db {}} "some-url"))))) + (testing "the user is logged in" + (let [db {:profile/profile {:public-key "pk"} + :app-state "active" + :universal-links/url "some-url"}] + (testing "it clears the url" + (is (nil? (get-in (links/handle-url {:db db} "some-url") + [:db :universal-links/url])))) + (testing "Handle a custom string" + (is (= (get-in (links/handle-url {:db db} "https://status.app/u#statuse2e") + [::router/handle-uri :uri]) + "https://status.app/u#statuse2e")))))) (deftest url-event-listener (testing "the url is not nil" diff --git a/src/status_im/wallet/accounts/core.cljs b/src/status_im/wallet/accounts/core.cljs index 3535847aa6..fac5c861fa 100644 --- a/src/status_im/wallet/accounts/core.cljs +++ b/src/status_im/wallet/accounts/core.cljs @@ -7,7 +7,6 @@ [status-im.ethereum.eip681 :as eip681] [status-im.ethereum.mnemonic :as mnemonic] [status-im.ethereum.stateofus :as stateofus] - [status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.ui.components.colors :as colors] [status-im.ui.components.list-selection :as list-selection] @@ -123,7 +122,7 @@ (native-module/verify address hashed-password - #(re-frame/dispatch [:wallet-legacy.accounts/add-new-account-password-verifyied % + #(re-frame/dispatch [:wallet-legacy.accounts/add-new-account-password-verified % hashed-password])))) (re-frame/reg-fx @@ -150,6 +149,11 @@ (string/trim (security/unmask private-key)) (store-account key-uid constants/path-default-wallet hashed-password :key)))) +(re-frame/reg-fx + ::validate-mnemonic + (fn [[passphrase callback]] + (native-module/validate-mnemonic passphrase callback))) + (rf/defn generate-new-account [{:keys [db]} hashed-password] (let [{:keys [key-uid wallet-root-address]} @@ -165,10 +169,10 @@ (rf/defn import-new-account-seed [{:keys [db]} passphrase hashed-password] - {:db (assoc-in db [:add-account :step] :generating) - ::multiaccounts/validate-mnemonic [(security/safe-unmask-data passphrase) - #(re-frame/dispatch [:wallet-legacy.accounts/seed-validated - % passphrase hashed-password])]}) + {:db (assoc-in db [:add-account :step] :generating) + ::validate-mnemonic [(security/safe-unmask-data passphrase) + #(re-frame/dispatch [:wallet-legacy.accounts/seed-validated % passphrase + hashed-password])]}) (rf/defn new-account-seed-validated {:events [:wallet-legacy.accounts/seed-validated]} @@ -254,8 +258,8 @@ {:address (eip55/address->checksum (address/normalized-hex address)) :type :watch}))) -(rf/defn add-new-account-password-verifyied - {:events [:wallet-legacy.accounts/add-new-account-password-verifyied]} +(rf/defn add-new-account-password-verified + {:events [:wallet-legacy.accounts/add-new-account-password-verified]} [{:keys [db] :as cofx} result hashed-password] (let [{:keys [error]} (types/json->clj result)] (if (not (string/blank? error)) diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 13ce3bcee5..bc059434f6 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -465,9 +465,7 @@ {:from (wallet.utils/get-default-account (:profile/wallet-accounts db)) :to (or (get-in db [:contacts/contacts identity]) - (-> identity - contact.db/public-key->new-contact - contact.db/enrich-contact)) + (contact.db/enrich-contact {:public-key identity})) :request-parameters request-parameters :chat-id chat-id :symbol symbol @@ -513,9 +511,7 @@ (let [identity (:current-chat-id db) {:keys [ens-verified name] :as contact} (or (get-in db [:contacts/contacts identity]) - (-> identity - contact.db/public-key->new-contact - contact.db/enrich-contact))] + (contact.db/enrich-contact {:public-key identity}))] (cond-> {:db (assoc db :wallet-legacy/prepare-transaction {:from (wallet.utils/get-default-account @@ -541,9 +537,7 @@ :wallet-legacy/prepare-transaction {:from (wallet.utils/get-default-account (:profile/wallet-accounts db)) :to (or (get-in db [:contacts/contacts identity]) - (-> identity - contact.db/public-key->new-contact - contact.db/enrich-contact)) + (contact.db/enrich-contact {:public-key identity})) :symbol :ETH :from-chat? true :request-command? true}) diff --git a/src/status_im2/common/confirmation_drawer/view.cljs b/src/status_im2/common/confirmation_drawer/view.cljs index 8eabcf69bf..f5537ed661 100644 --- a/src/status_im2/common/confirmation_drawer/view.cljs +++ b/src/status_im2/common/confirmation_drawer/view.cljs @@ -37,14 +37,15 @@ (let [{:keys [group-chat chat-id public-key color profile-picture name]} context id (or chat-id public-key) - contact-name-by-identity (when-not group-chat - (rf/sub [:contacts/contact-name-by-identity id])) + [primary-name _] (when-not group-chat + (rf/sub [:contacts/contact-two-names-by-identity id])) display-name (cond - (= contact-name-by-identity - "Unknown") name - (= contact-name-by-identity - nil) name - :else contact-name-by-identity) + (= primary-name "Unknown") + name + (= primary-name nil) + name + :else + primary-name) photo-path (or profile-picture (rf/sub [:chats/photo-path id]))] [rn/view {:style {:margin-horizontal 20} diff --git a/src/status_im2/common/home/actions/view.cljs b/src/status_im2/common/home/actions/view.cljs index 10fd92e0b5..3325f9f831 100644 --- a/src/status_im2/common/home/actions/view.cljs +++ b/src/status_im2/common/home/actions/view.cljs @@ -342,9 +342,9 @@ (defn remove-from-group-entry [{:keys [public-key]} chat-id] - (let [username (first (rf/sub [:contacts/contact-two-names-by-identity public-key]))] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity public-key])] (entry {:icon :i/placeholder - :label (i18n/label :t/remove-user-from-group {:username username}) + :label (i18n/label :t/remove-user-from-group {:username primary-name}) :on-press #(hide-sheet-and-dispatch [:group-chats.ui/remove-member-pressed chat-id public-key true]) :danger? true diff --git a/src/status_im2/common/home/top_nav/view.cljs b/src/status_im2/common/home/top_nav/view.cljs index e9006d952b..0d7008cc2a 100644 --- a/src/status_im2/common/home/top_nav/view.cljs +++ b/src/status_im2/common/home/top_nav/view.cljs @@ -1,9 +1,9 @@ (ns status-im2.common.home.top-nav.view (:require [quo.core :as quo] - [status-im.multiaccounts.core :as multiaccounts] [status-im2.common.home.top-nav.style :as style] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [utils.debounce :refer [dispatch-and-chill]] [utils.re-frame :as rf])) @@ -14,22 +14,24 @@ :jump-to? true/false :container-style passed to outer view of component}" [{:keys [container-style blur? jump-to?]}] - (let [{:keys [public-key]} (rf/sub [:profile/profile]) - online? (rf/sub [:visibility-status-updates/online? public-key]) - account (rf/sub [:profile/multiaccount]) - customization-color (rf/sub [:profile/customization-color]) - avatar {:online? online? - :full-name (multiaccounts/displayed-name account) - :profile-picture (multiaccounts/displayed-photo account)} - unread-count (rf/sub [:activity-center/unread-count]) - indicator (rf/sub [:activity-center/unread-indicator]) - notification-type (case indicator - :unread-indicator/seen :mention-seen ; should be `seen` - TODO discuss - ; with design team about - ; notifications for activity centre - :unread-indicator/new :mention ; should be :notification TODO - ; https://github.com/status-im/status-mobile/issues/17102 - nil)] + (let [{:keys [public-key] :as profile} (rf/sub [:profile/profile-with-image]) + online? (rf/sub [:visibility-status-updates/online? + public-key]) + customization-color (rf/sub [:profile/customization-color]) + avatar {:online? online? + :full-name (profile.utils/displayed-name profile) + :profile-picture (profile.utils/photo profile)} + + unread-count (rf/sub [:activity-center/unread-count]) + indicator (rf/sub [:activity-center/unread-indicator]) + notification-type (case indicator + ; should be `seen` TODO discuss with design team + ; notifications for activity centre + :unread-indicator/seen :mention-seen + ; should be :notification TODO + ; https://github.com/status-im/status-mobile/issues/17102 + :unread-indicator/new :mention + nil)] [quo/top-nav {:avatar-on-press #(rf/dispatch [:navigate-to :my-profile]) :scan-on-press #(js/alert "to be implemented") diff --git a/src/status_im2/common/password_authentication/view.cljs b/src/status_im2/common/password_authentication/view.cljs index c7fee1e82c..7a4c30c979 100644 --- a/src/status_im2/common/password_authentication/view.cljs +++ b/src/status_im2/common/password_authentication/view.cljs @@ -4,7 +4,7 @@ [quo.core :as quo] [react-native.core :as rn] [reagent.core :as reagent] - [status-im.multiaccounts.core :as multiaccounts] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -12,7 +12,7 @@ [] (let [entered-password (reagent/atom "")] (fn [] - (let [account (rf/sub [:profile/multiaccount]) + (let [profile (rf/sub [:profile/profile-with-image]) {:keys [error button]} (rf/sub [:password-authentication])] [rn/view {:padding-horizontal 20} [quo/text {:size :heading-1 :weight :semi-bold} @@ -20,8 +20,8 @@ [rn/view {:style {:margin-top 8 :margin-bottom 20}} [quo/context-tag {:size 24 - :profile-picture (multiaccounts/displayed-photo account) - :full-name (multiaccounts/displayed-name account)}]] + :full-name (profile.utils/displayed-name profile) + :profile-picture (profile.utils/photo profile)}]] [quo/input {:type :password :label (i18n/label :t/profile-password) diff --git a/src/status_im2/common/standard_authentication/enter_password/view.cljs b/src/status_im2/common/standard_authentication/enter_password/view.cljs index a49360790b..d507457aba 100644 --- a/src/status_im2/common/standard_authentication/enter_password/view.cljs +++ b/src/status_im2/common/standard_authentication/enter_password/view.cljs @@ -2,18 +2,17 @@ (:require [quo.core :as quo] [react-native.core :as rn] - [status-im.multiaccounts.core :as multiaccounts] [status-im2.common.standard-authentication.enter-password.style :as style] [status-im2.common.standard-authentication.password-input.view :as password-input] + [status-im2.contexts.profile.utils :as profile.utils] [utils.i18n :as i18n] [utils.re-frame :as rf])) (defn view [{:keys [on-enter-password button-label button-icon-left customization-color]}] - (let [{:keys [key-uid display-name] :as account} (rf/sub [:profile/multiaccount]) - {:keys [error processing password]} (rf/sub [:profile/login]) - sign-in-enabled? (rf/sub [:sign-in-enabled?]) - profile-picture (multiaccounts/displayed-photo account)] + (let [{:keys [key-uid] :as profile} (rf/sub [:profile/profile-with-image]) + {:keys [error processing password]} (rf/sub [:profile/login]) + sign-in-enabled? (rf/sub [:sign-in-enabled?])] [:<> [rn/view {:style style/enter-password-container} [rn/view @@ -28,8 +27,8 @@ [quo/context-tag {:type :default :blur? true - :profile-picture profile-picture - :full-name display-name + :profile-picture (profile.utils/photo profile) + :full-name (profile.utils/displayed-name profile) :customization-color customization-color :size 24}]] [password-input/view diff --git a/src/status_im2/contexts/chat/composer/reply/view.cljs b/src/status_im2/contexts/chat/composer/reply/view.cljs index b400e22521..146761d64a 100644 --- a/src/status_im2/contexts/chat/composer/reply/view.cljs +++ b/src/status_im2/contexts/chat/composer/reply/view.cljs @@ -66,11 +66,11 @@ (defn reply-from [{:keys [from contact-name current-public-key pin?]}] - (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity from])) - photo-path (rf/sub [:chats/photo-path from])] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from]) + photo-path (rf/sub [:chats/photo-path from])] [rn/view {:style style/reply-from} [quo/user-avatar - {:full-name display-name + {:full-name primary-name :profile-picture photo-path :status-indicator? false :size :xxxs @@ -86,7 +86,7 @@ [{:keys [from content-type contentType parsed-text content deleted? deleted-for-me? album-images-count]} in-chat-input? pin? recording-audio?] - (let [contact-name (rf/sub [:contacts/contact-name-by-identity from]) + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from]) current-public-key (rf/sub [:multiaccount/public-key]) content-type (or content-type contentType) text (get-quoted-text-with-mentions (or parsed-text (:parsed-text content)))] @@ -106,7 +106,7 @@ [reply-from {:pin? pin? :from from - :contact-name contact-name + :contact-name primary-name :current-public-key current-public-key}] (when (not-empty text) [quo/text diff --git a/src/status_im2/contexts/chat/home/contact_request/view.cljs b/src/status_im2/contexts/chat/home/contact_request/view.cljs index ce8101b49d..5e155c18b1 100644 --- a/src/status_im2/contexts/chat/home/contact_request/view.cljs +++ b/src/status_im2/contexts/chat/home/contact_request/view.cljs @@ -12,11 +12,11 @@ (defn get-display-name [{:keys [chat-id message]}] - (let [name (first (rf/sub [:contacts/contact-two-names-by-identity chat-id])) - no-ens-name (string/blank? (get-in message [:content :ens-name]))] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id]) + no-ens-name (string/blank? (get-in message [:content :ens-name]))] (if no-ens-name - (first (string/split name " ")) - name))) + (first (string/split primary-name " ")) + primary-name))) (defn requests-summary [requests] diff --git a/src/status_im2/contexts/chat/lightbox/top_view.cljs b/src/status_im2/contexts/chat/lightbox/top_view.cljs index ad1fe54b52..71daaa6b53 100644 --- a/src/status_im2/contexts/chat/lightbox/top_view.cljs +++ b/src/status_im2/contexts/chat/lightbox/top_view.cljs @@ -70,8 +70,7 @@ (defn top-view [messages insets index animations derived landscape? screen-width] (let [{:keys [from timestamp]} (first messages) - display-name (first (rf/sub [:contacts/contact-two-names-by-identity - from])) + [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from]) bg-color (if landscape? colors/neutral-100-opa-70 colors/neutral-100-opa-0) @@ -102,7 +101,7 @@ [quo/text {:weight :semi-bold :size :paragraph-1 - :style {:color colors/white}} display-name] + :style {:color colors/white}} primary-name] [quo/text {:weight :medium :size :paragraph-2 diff --git a/src/status_im2/contexts/chat/messages/avatar/view.cljs b/src/status_im2/contexts/chat/messages/avatar/view.cljs index 0941feee48..b1d0e09720 100644 --- a/src/status_im2/contexts/chat/messages/avatar/view.cljs +++ b/src/status_im2/contexts/chat/messages/avatar/view.cljs @@ -6,15 +6,15 @@ (defn avatar [{:keys [public-key size hide-ring?]}] - (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity public-key])) - photo-path (rf/sub [:chats/photo-path public-key]) - online? (rf/sub [:visibility-status-updates/online? public-key])] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity public-key]) + photo-path (rf/sub [:chats/photo-path public-key]) + online? (rf/sub [:visibility-status-updates/online? public-key])] [rn/view {:style {:padding-top 4}} [rn/touchable-opacity {:active-opacity 1 :on-press #(rf/dispatch [:chat.ui/show-profile public-key])} [quo/user-avatar - {:full-name display-name + {:full-name primary-name :ring? (not hide-ring?) :profile-picture photo-path :online? online? diff --git a/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs b/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs index 7fbdde5072..b115f25dcc 100644 --- a/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs +++ b/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs @@ -12,7 +12,7 @@ (defn view [contact-id contact-request-state group-chat] (let [customization-color (rf/sub [:profile/customization-color]) - names (rf/sub [:contacts/contact-two-names-by-identity contact-id])] + [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity contact-id])] [rn/view [permission-context/view [quo/button @@ -29,11 +29,11 @@ (or (not contact-request-state) (= contact-request-state constants/contact-request-state-none)) - (i18n/label :t/contact-request-chat-add {:name (first names)}) + (i18n/label :t/contact-request-chat-add {:name primary-name}) (= contact-request-state constants/contact-request-state-received) - (str (first names) " sent you a contact request") + (str primary-name " sent you a contact request") (= contact-request-state constants/contact-request-state-sent) diff --git a/src/status_im2/contexts/chat/messages/content/deleted/view.cljs b/src/status_im2/contexts/chat/messages/content/deleted/view.cljs index 2d75c835ea..0287fd56b3 100644 --- a/src/status_im2/contexts/chat/messages/content/deleted/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/deleted/view.cljs @@ -36,9 +36,8 @@ (defn deleted-by-message [{:keys [deleted-by timestamp-str from on-long-press animation-duration]}] (let [;; deleted message with nil deleted-by is deleted by (:from message) - display-name (first (rf/sub [:contacts/contact-two-names-by-identity - (or deleted-by from)])) - photo-path (rf/sub [:chats/photo-path (or deleted-by from)])] + [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity (or deleted-by from)]) + photo-path (rf/sub [:chats/photo-path (or deleted-by from)])] [quo/system-message {:type :deleted :animate-bg-color? animation-duration @@ -46,7 +45,7 @@ :on-long-press on-long-press :timestamp timestamp-str :child [user-xxx-deleted-this-message - {:display-name display-name :profile-picture photo-path}]}])) + {:display-name primary-name :profile-picture photo-path}]}])) (defn deleted-message [{:keys [deleted? deleted-for-me? deleted-by pinned timestamp-str from diff --git a/src/status_im2/contexts/chat/messages/content/pin/view.cljs b/src/status_im2/contexts/chat/messages/content/pin/view.cljs index 07f4ae2368..e7b8157a13 100644 --- a/src/status_im2/contexts/chat/messages/content/pin/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/pin/view.cljs @@ -11,10 +11,10 @@ (defn pinned-by-view [pinned-by] (let [{:keys [public-key]} (rf/sub [:multiaccount/contact]) - contact-names (rf/sub [:contacts/contact-two-names-by-identity pinned-by]) + [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity pinned-by]) author-name (if (= pinned-by public-key) (i18n/label :t/You) - (first contact-names))] + primary-name)] [rn/view {:style style/pin-indicator-container :accessibility-label :pinned-by} @@ -29,11 +29,11 @@ (defn pinned-message [{:keys [from quoted-message timestamp-str]}] - (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity from])) + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from]) customization-color (rf/sub [:profile/customization-color])] [quo/system-message {:type :pinned - :pinned-by display-name + :pinned-by primary-name :customization-color customization-color :child [reply/quoted-message quoted-message false true] :timestamp timestamp-str}])) diff --git a/src/status_im2/contexts/chat/messages/content/view.cljs b/src/status_im2/contexts/chat/messages/content/view.cljs index 91315f994e..4e264a644f 100644 --- a/src/status_im2/contexts/chat/messages/content/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/view.cljs @@ -72,7 +72,7 @@ (defn system-message-contact-request [{:keys [chat-id timestamp-str from]} type] - (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity chat-id])) + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity chat-id]) contact (rf/sub [:contacts/contact-by-address chat-id]) photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id])) customization-color (rf/sub [:profile/customization-color]) @@ -80,7 +80,7 @@ [quo/system-message {:type type :timestamp timestamp-str - :display-name display-name + :display-name primary-name :customization-color customization-color :photo-path photo-path :incoming? (not= public-key from)}])) diff --git a/src/status_im2/contexts/chat/messages/drawers/view.cljs b/src/status_im2/contexts/chat/messages/drawers/view.cljs index 3bec8d8568..7918ddcf87 100644 --- a/src/status_im2/contexts/chat/messages/drawers/view.cljs +++ b/src/status_im2/contexts/chat/messages/drawers/view.cljs @@ -15,8 +15,7 @@ (defn contact-list-item-fn [{:keys [from compressed-key]}] - (let [[primary-name secondary-name] (rf/sub [:contacts/contact-two-names-by-identity - from]) + (let [[primary-name secondary-name] (rf/sub [:contacts/contact-two-names-by-identity from]) {:keys [ens-verified added?]} (rf/sub [:contacts/contact-by-address from])] ^{:key compressed-key} [contact-list-item/contact-list-item diff --git a/src/status_im2/contexts/chat/messages/link_preview/events.cljs b/src/status_im2/contexts/chat/messages/link_preview/events.cljs index 743cfd9b14..c9e15deced 100644 --- a/src/status_im2/contexts/chat/messages/link_preview/events.cljs +++ b/src/status_im2/contexts/chat/messages/link_preview/events.cljs @@ -2,7 +2,7 @@ (:require [camel-snake-kebab.core :as csk] [status-im.communities.core :as models.communities] - [status-im.multiaccounts.update.core :as multiaccounts.update] + [status-im2.contexts.profile.settings.events :as profile.settings.events] [taoensso.timbre :as log] [utils.collection] [utils.re-frame :as rf])) @@ -15,7 +15,7 @@ {:events [:chat.ui/cache-link-preview-data]} [{{:profile/keys [profile]} :db :as cofx} site data] (let [link-previews-cache (get profile :link-previews-cache {})] - (multiaccounts.update/optimistic + (profile.settings.events/optimistic-profile-update cofx :link-previews-cache (assoc link-previews-cache site (utils.collection/map-keys csk/->kebab-case-keyword data))))) @@ -35,7 +35,7 @@ (rf/defn should-suggest-link-preview {:events [:chat.ui/should-suggest-link-preview]} [{:keys [db] :as cofx} enabled?] - (multiaccounts.update/multiaccount-update + (profile.settings.events/profile-update cofx :link-preview-request-enabled (boolean enabled?) @@ -87,7 +87,7 @@ (rf/defn enable {:events [:chat.ui/enable-link-previews]} [{{:profile/keys [profile]} :db :as cofx} site enabled?] - (multiaccounts.update/multiaccount-update + (profile.settings.events/profile-update cofx :link-previews-enabled-sites (if enabled? @@ -98,7 +98,7 @@ (rf/defn enable-all {:events [:chat.ui/enable-all-link-previews]} [cofx link-previews-whitelist enabled?] - (multiaccounts.update/multiaccount-update + (profile.settings.events/profile-update cofx :link-previews-enabled-sites (if enabled? diff --git a/src/status_im2/contexts/contacts/events.cljs b/src/status_im2/contexts/contacts/events.cljs index 4c8499f53a..61dda3c955 100644 --- a/src/status_im2/contexts/contacts/events.cljs +++ b/src/status_im2/contexts/contacts/events.cljs @@ -129,3 +129,4 @@ :on-success on-success :js-response true :on-error #(log/error "failed to unblock contact" % contact-id)}]}) + diff --git a/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs b/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs index 4ba66ddf1e..8f72c9eba4 100644 --- a/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs +++ b/src/status_im2/contexts/onboarding/select_photo/method_menu/view.cljs @@ -2,7 +2,6 @@ (:require ["react-native-image-crop-picker" :default image-picker] [quo.core :as quo] - [status-im.multiaccounts.core] [utils.i18n :as i18n] [utils.re-frame :as rf])) diff --git a/src/status_im2/contexts/profile/events.cljs b/src/status_im2/contexts/profile/events.cljs index ac81b5b78b..2490fd0404 100644 --- a/src/status_im2/contexts/profile/events.cljs +++ b/src/status_im2/contexts/profile/events.cljs @@ -2,7 +2,7 @@ (:require [native-module.core :as native-module] [re-frame.core :as re-frame] - [status-im2.contexts.profile.login.events :as login] + [status-im2.contexts.profile.login.events :as profile.login] [status-im2.contexts.profile.rpc :as profile.rpc] [status-im2.navigation.events :as navigation] [utils.re-frame :as rf])) @@ -46,7 +46,7 @@ (init-profiles-overview profiles key-uid) ;;we check if biometric is available, and try to login with it, ;;if succeed "node.login" signal will be triggered - (login/login-with-biometric-if-available key-uid))) + (profile.login/login-with-biometric-if-available key-uid))) (navigation/init-root cofx :intro))) (rf/defn update-setting-from-backup diff --git a/src/status_im2/contexts/profile/login/events.cljs b/src/status_im2/contexts/profile/login/events.cljs index a4b0158da8..58bf31f97a 100644 --- a/src/status_im2/contexts/profile/login/events.cljs +++ b/src/status_im2/contexts/profile/login/events.cljs @@ -10,7 +10,6 @@ [status-im.data-store.visibility-status-updates :as visibility-status-updates-store] [status-im.group-chats.core :as group-chats] [status-im.mobile-sync-settings.core :as mobile-network] - [status-im.multiaccounts.core :as multiaccounts] [status-im.transport.core :as transport] [status-im2.common.biometric.events :as biometric] [status-im2.common.keychain.events :as keychain] @@ -20,6 +19,7 @@ [status-im2.contexts.contacts.events :as contacts] [status-im2.contexts.profile.config :as profile.config] [status-im2.contexts.profile.rpc :as profile.rpc] + [status-im2.contexts.profile.settings.events :as profile.settings.events] [status-im2.contexts.push-notifications.events :as notifications] [status-im2.contexts.shell.activity-center.events :as activity-center] [status-im2.contexts.wallet.events :as wallet] @@ -62,7 +62,7 @@ :else (rf/merge cofx - (multiaccounts/switch-theme nil :shell-stack) + (profile.settings.events/switch-theme nil :shell-stack) (navigation/init-root :shell-stack))))) ;; login phase 1, we want to load and show chats faster so we split login into 2 phases @@ -71,14 +71,14 @@ (let [{:networks/keys [current-network networks] :as settings} (data-store.settings/rpc->settings settings) - profile (profile.rpc/rpc->profiles-overview account)] + profile-overview (profile.rpc/rpc->profiles-overview account)] (rf/merge cofx {:db (assoc db :chats/loading? true :networks/current-network current-network :wallet/tokens-loading? true :networks/networks (merge networks config/default-networks-by-id) - :profile/profile (merge profile settings))} + :profile/profile (merge profile-overview settings))} (notifications/load-preferences) (data-store.chats/fetch-chats-preview {:on-success @@ -122,8 +122,8 @@ (browser/initialize-browser) (mobile-network/on-network-status-change) (group-chats/get-group-chat-invitations) - (multiaccounts/get-profile-picture) - (multiaccounts/switch-preview-privacy-mode-flag) + (profile.settings.events/get-profile-picture) + (profile.settings.events/change-preview-privacy) (link-preview/request-link-preview-whitelist) (visibility-status-updates-store/fetch-visibility-status-updates-rpc) (switcher-cards-store/fetch-switcher-cards-rpc)))) diff --git a/src/status_im2/contexts/profile/settings/effects.cljs b/src/status_im2/contexts/profile/settings/effects.cljs new file mode 100644 index 0000000000..01a7381cdc --- /dev/null +++ b/src/status_im2/contexts/profile/settings/effects.cljs @@ -0,0 +1,40 @@ +(ns status-im2.contexts.profile.settings.effects + (:require [native-module.core :as native-module] + [quo.foundations.colors :as colors] + [re-frame.core :as re-frame] + [react-native.platform :as platform] + [status-im2.common.theme.core :as theme] + [status-im2.constants :as constants] + [status-im2.contexts.shell.jump-to.utils :as shell.utils] + [status-im2.setup.hot-reload :as hot-reload])) + +(re-frame/reg-fx + :profile.settings/blank-preview-flag-changed + (fn [flag] + (native-module/set-blank-preview-flag flag))) + +(re-frame/reg-fx + :profile.settings/webview-debug-changed + (fn [value] + (when platform/android? + (native-module/toggle-webview-debug value)))) + +(re-frame/reg-fx + :profile.settings/switch-theme-fx + (fn [[theme-type view-id reload-ui?]] + (let [[theme status-bar-theme nav-bar-color] + ;; Status bar theme represents status bar icons colors, so opposite to app theme + (if (or (= theme-type constants/theme-type-dark) + (and (= theme-type constants/theme-type-system) + (theme/device-theme-dark?))) + [:dark :light colors/neutral-100] + [:light :dark colors/white])] + (theme/set-theme theme) + (re-frame/dispatch [:change-shell-status-bar-style + (if (shell.utils/home-stack-open?) status-bar-theme :light)]) + (when reload-ui? + (re-frame/dispatch [:dismiss-all-overlays]) + (when js/goog.DEBUG + (hot-reload/reload)) + (when-not (= view-id :shell-stack) + (re-frame/dispatch [:change-shell-nav-bar-color nav-bar-color])))))) diff --git a/src/status_im2/contexts/profile/settings/events.cljs b/src/status_im2/contexts/profile/settings/events.cljs new file mode 100644 index 0000000000..eaa5f02e20 --- /dev/null +++ b/src/status_im2/contexts/profile/settings/events.cljs @@ -0,0 +1,140 @@ +(ns status-im2.contexts.profile.settings.events + (:require [clojure.string :as string] + [status-im.bottom-sheet.events :as bottom-sheet.events] + [status-im2.constants :as constants] + status-im2.contexts.profile.settings.effects + [taoensso.timbre :as log] + [utils.re-frame :as rf])) + +(rf/defn send-contact-update + [{:keys [db]}] + (let [{:keys [name preferred-name display-name]} (:profile/profile db)] + {:json-rpc/call [{:method "wakuext_sendContactUpdates" + :params [(or preferred-name display-name name) ""] + :on-success #(log/debug "sent contact update")}]})) + +(rf/defn profile-update + [{:keys [db] :as cofx} + setting setting-value + {:keys [dont-sync? on-success] :or {on-success #()}}] + (rf/merge + cofx + {:db (if setting-value + (assoc-in db [:profile/profile setting] setting-value) + (update db :profile/profile dissoc setting)) + :json-rpc/call + [{:method "settings_saveSetting" + :params [setting setting-value] + :on-success on-success}]} + + (when (#{:name :preferred-name} setting) + (constantly {:profile/get-profiles-overview #(rf/dispatch [:multiaccounts.ui/update-name %])})) + + (when (and (not dont-sync?) (#{:name :preferred-name} setting)) + (send-contact-update)))) + +(rf/defn optimistic-profile-update + [{:keys [db]} setting setting-value] + {:db (if setting-value + (assoc-in db [:profile/profile setting] setting-value) + (update db :profile/profile dissoc setting))}) + +(rf/defn change-preview-privacy + [{:keys [db]}] + (let [private? (get-in db [:profile/profile :preview-privacy?])] + {:profile.settings/blank-preview-flag-changed private?})) + +(rf/defn update-value + {:events [:profile.settings/update-value]} + [cofx key value] + (profile-update cofx key value {})) + +(rf/defn change-webview-debug + {:events [:profile.settings/change-webview-debug]} + [{:keys [db] :as cofx} value] + (rf/merge cofx + {:profile.settings/webview-debug-changed value} + (profile-update :webview-debug (boolean value) {}))) + +(rf/defn change-preview-privacy-flag + {:events [:profile.settings/change-preview-privacy]} + [{:keys [db] :as cofx} private?] + (rf/merge cofx + {:profile.settings/blank-preview-flag-changed private?} + (profile-update + :preview-privacy? + (boolean private?) + {}))) + + +(rf/defn change-profile-pictures-show-to + {:events [:profile.settings/change-profile-pictures-show-to]} + [cofx id] + (rf/merge cofx + {:json-rpc/call [{:method "wakuext_changeIdentityImageShowTo" + :params [id] + :on-success #(log/debug "picture settings changed successfully")}]} + (optimistic-profile-update :profile-pictures-show-to id))) + +(rf/defn change-appearance + {:events [:profile.settings/change-appearance]} + [cofx theme] + (rf/merge cofx + {:profile.settings/switch-theme-fx [theme :appearance true]} + (profile-update :appearance theme {}))) + +(rf/defn switch-theme + {:events [:profile.settings/switch-theme]} + [cofx theme view-id] + (let [theme (or theme + (get-in cofx [:db :profile/profile :appearance]) + constants/theme-type-dark)] + {:profile.settings/switch-theme-fx [theme view-id false]})) + +(rf/defn get-profile-picture + {:events [:profile.settings/get-profile-picture]} + [cofx] + (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] + {:json-rpc/call [{:method "multiaccounts_getIdentityImages" + :params [key-uid] + :on-success [:profile.settings/update-local-picture]}]})) + +(rf/defn save-profile-picture + {:events [:profile.settings/save-profile-picture]} + [cofx path ax ay bx by] + (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] + (rf/merge cofx + {:json-rpc/call [{:method "multiaccounts_storeIdentityImage" + :params [key-uid (string/replace-first path #"file://" "") ax ay bx + by] + :on-success [:profile.settings/update-local-picture]}]} + (bottom-sheet.events/hide-bottom-sheet-old)))) + +(rf/defn save-profile-picture-from-url + {:events [:profile.settings/save-profile-picture-from-url]} + [cofx url] + (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] + (rf/merge cofx + {:json-rpc/call [{:method "multiaccounts_storeIdentityImageFromURL" + :params [key-uid url] + :on-error #(log/error "::save-profile-picture-from-url error" %) + :on-success [:profile.settings/update-local-picture]}]} + (bottom-sheet.events/hide-bottom-sheet-old)))) + +(rf/defn delete-profile-picture + {:events [:profile.settings/delete-profile-picture]} + [cofx name] + (let [key-uid (get-in cofx [:db :profile/profile :key-uid])] + (rf/merge cofx + {:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" + :params [key-uid] + ;; NOTE: In case of an error we could fallback to previous image in + ;; UI with a toast error + :on-success #(log/info "[profile] Delete profile image" %)}]} + (optimistic-profile-update :images nil) + (bottom-sheet.events/hide-bottom-sheet-old)))) + +(rf/defn store-profile-picture + {:events [:profile.settings/update-local-picture]} + [cofx pics] + (optimistic-profile-update cofx :images pics)) diff --git a/src/status_im2/contexts/profile/utils.cljs b/src/status_im2/contexts/profile/utils.cljs new file mode 100644 index 0000000000..095cb04ec8 --- /dev/null +++ b/src/status_im2/contexts/profile/utils.cljs @@ -0,0 +1,23 @@ +(ns status-im2.contexts.profile.utils + (:require [clojure.string :as string])) + +(defn displayed-name + [{:keys [name display-name preferred-name alias ens-verified primary-name]}] + ;; `preferred-name` is our own name + ;; otherwise we make sure the `name` is verified and use it + (let [display-name (when-not (string/blank? display-name) + display-name) + preferred-name (when-not (string/blank? preferred-name) + preferred-name) + ens-name (or preferred-name + display-name + name)] + (if (or preferred-name (and ens-verified name)) + ens-name + (or display-name primary-name alias)))) + +(defn photo + [{:keys [images]}] + (or (:large images) + (:thumbnail images) + (first images))) diff --git a/src/status_im2/contexts/quo_preview/drawers/drawer_top.cljs b/src/status_im2/contexts/quo_preview/drawers/drawer_top.cljs index 9d19d1c933..99277ee63a 100644 --- a/src/status_im2/contexts/quo_preview/drawers/drawer_top.cljs +++ b/src/status_im2/contexts/quo_preview/drawers/drawer_top.cljs @@ -3,8 +3,8 @@ [quo.core :as quo] [react-native.core :as rn] [reagent.core :as reagent] - [status-im.multiaccounts.core :as multiaccounts] [status-im2.common.resources :as resources] + [status-im2.contexts.profile.utils :as profile.utils] [status-im2.contexts.quo-preview.preview :as preview] [utils.re-frame :as rf])) @@ -38,7 +38,7 @@ (defn view [] - (let [account (rf/sub [:profile/multiaccount]) + (let [profile (rf/sub [:profile/profile-with-image]) state (reagent/atom {:blur? false :title "Title" @@ -55,7 +55,7 @@ :icon-avatar :i/placeholder :on-button-press #(js/alert "on press") :on-button-long-press #(js/alert "on long press") - :profile-picture (multiaccounts/displayed-photo account)})] + :profile-picture (profile.utils/photo profile)})] (fn [] [preview/preview-container {:state state diff --git a/src/status_im2/contexts/shell/activity_center/notification/common/view.cljs b/src/status_im2/contexts/shell/activity_center/notification/common/view.cljs index 2b54d30f24..1342f274cc 100644 --- a/src/status_im2/contexts/shell/activity_center/notification/common/view.cljs +++ b/src/status_im2/contexts/shell/activity_center/notification/common/view.cljs @@ -4,19 +4,19 @@ [quo.foundations.colors :as colors] [react-native.core :as rn] [react-native.gesture :as gesture] - [status-im.multiaccounts.core :as multiaccounts] + [status-im2.contexts.profile.utils :as profile.utils] [status-im2.contexts.shell.activity-center.notification.common.style :as style] [utils.i18n :as i18n] [utils.re-frame :as rf])) (defn user-avatar-tag [user-id] - (let [{:keys [primary-name] :as contact} (rf/sub [:contacts/contact-by-identity user-id])] + (let [profile (rf/sub [:contacts/contact-by-identity user-id])] [quo/context-tag {:blur? true :size 24 - :full-name primary-name - :profile-picture (multiaccounts/displayed-photo contact)}])) + :full-name (profile.utils/displayed-name profile) + :profile-picture (profile.utils/photo profile)}])) (defn- render-swipe-action [{:keys [active-swipeable diff --git a/src/status_im2/contexts/shell/share/view.cljs b/src/status_im2/contexts/shell/share/view.cljs index fdb5f8bb10..0c71a9650d 100644 --- a/src/status_im2/contexts/shell/share/view.cljs +++ b/src/status_im2/contexts/shell/share/view.cljs @@ -8,9 +8,9 @@ [react-native.platform :as platform] [react-native.safe-area :as safe-area] [reagent.core :as reagent] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.list-selection :as list-selection] [status-im2.common.qr-codes.view :as qr-codes] + [status-im2.contexts.profile.utils :as profile.utils] [status-im2.contexts.shell.share.style :as style] [utils.address :as address] [utils.i18n :as i18n] @@ -46,10 +46,11 @@ (defn profile-tab [] - (let [{:keys [emoji-hash compressed-key customization-color display-name] + (let [{:keys [emoji-hash + compressed-key + customization-color] :as profile} (rf/sub [:profile/profile]) profile-url (str image-server/status-profile-base-url compressed-key) - profile-photo-uri (:uri (multiaccounts/displayed-photo profile)) abbreviated-url (address/get-abbreviated-profile-url image-server/status-profile-base-url-without-https compressed-key) @@ -68,8 +69,8 @@ :on-text-long-press #(rf/dispatch [:share/copy-text-and-show-toast {:text-to-copy profile-url :post-copy-message (i18n/label :t/link-to-profile-copied)}]) - :profile-picture profile-photo-uri - :full-name display-name + :profile-picture (:uri (profile.utils/photo profile)) + :full-name (profile.utils/displayed-name profile) :customization-color customization-color}]] [rn/view {:style style/emoji-hash-container} diff --git a/src/status_im2/contexts/syncing/setup_syncing/view.cljs b/src/status_im2/contexts/syncing/setup_syncing/view.cljs index d8954743f8..5bcee87df2 100644 --- a/src/status_im2/contexts/syncing/setup_syncing/view.cljs +++ b/src/status_im2/contexts/syncing/setup_syncing/view.cljs @@ -25,7 +25,7 @@ (defn view [] - (let [{:keys [customization-color]} (rf/sub [:profile/multiaccount]) + (let [{:keys [customization-color]} (rf/sub [:profile/profile-with-image]) valid-for-ms (reagent/atom code-valid-for-ms) code (reagent/atom nil) delay-ms (reagent/atom nil) diff --git a/src/status_im2/contexts/wallet/create_account/view.cljs b/src/status_im2/contexts/wallet/create_account/view.cljs index 3705b5e2a0..187e9326c9 100644 --- a/src/status_im2/contexts/wallet/create_account/view.cljs +++ b/src/status_im2/contexts/wallet/create_account/view.cljs @@ -51,7 +51,7 @@ derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts)) {:keys [public-key]} (rf/sub [:profile/profile]) on-change-text #(reset! account-name %) - display-name (first (rf/sub [:contacts/contact-two-names-by-identity public-key])) + [primary-name _] (first (rf/sub [:contacts/contact-two-names-by-identity public-key])) {window-width :width} (rn/get-window)] (fn [{:keys [theme]}] [rn/view @@ -108,7 +108,7 @@ [quo/category {:list-type :settings :label (i18n/label :t/origin) - :data (get-keypair-data display-name @derivation-path)}] + :data (get-keypair-data primary-name @derivation-path)}] [standard-auth/view {:size :size-48 :track-text (i18n/label :t/slide-to-create-account) diff --git a/src/status_im2/events.cljs b/src/status_im2/events.cljs index 095c9a5c40..9091d85fc3 100644 --- a/src/status_im2/events.cljs +++ b/src/status_im2/events.cljs @@ -16,6 +16,7 @@ status-im2.contexts.onboarding.common.overlay.events status-im2.contexts.onboarding.events status-im2.contexts.profile.events + status-im2.contexts.profile.settings.events status-im2.contexts.shell.share.events status-im2.contexts.syncing.events status-im2.contexts.wallet.events diff --git a/src/status_im2/navigation/core.cljs b/src/status_im2/navigation/core.cljs index 20fe434455..86fda6baac 100644 --- a/src/status_im2/navigation/core.cljs +++ b/src/status_im2/navigation/core.cljs @@ -78,7 +78,7 @@ (fn [root-id] (let [root (get (roots/roots) root-id)] (dismiss-all-modals) - (re-frame/dispatch [:multiaccounts.ui/switch-theme + (re-frame/dispatch [:profile.settings/switch-theme (get roots/themes root-id) root-id]) (reset! state/root-id (or (get-in root [:root :stack :id]) root-id)) diff --git a/src/status_im2/navigation/events.cljs b/src/status_im2/navigation/events.cljs index 1c2af144da..5d72d033be 100644 --- a/src/status_im2/navigation/events.cljs +++ b/src/status_im2/navigation/events.cljs @@ -167,7 +167,7 @@ {:set-root (if keycard-account? :multiaccounts-keycard :multiaccounts)})) (rf/defn dismiss-all-overlays - {:events [:dissmiss-all-overlays]} + {:events [:dismiss-all-overlays]} [{:keys [db]}] {:dispatch-n [[:hide-popover] [:hide-visibility-status-popover] diff --git a/src/status_im2/subs/chats.cljs b/src/status_im2/subs/chats.cljs index 6a8355c577..6fe7bb6f29 100644 --- a/src/status_im2/subs/chats.cljs +++ b/src/status_im2/subs/chats.cljs @@ -3,12 +3,12 @@ [clojure.string :as string] [re-frame.core :as re-frame] [status-im.communities.core :as communities] - [status-im.contact.core :as contact] [status-im.group-chats.core :as group-chat] [status-im.group-chats.db :as group-chats.db] [status-im2.constants :as constants] [status-im2.contexts.chat.composer.constants :as composer.constants] - [status-im2.contexts.chat.events :as chat.events])) + [status-im2.contexts.chat.events :as chat.events] + [status-im2.contexts.profile.utils :as profile.utils])) (def memo-chats-stack-items (atom nil)) @@ -313,10 +313,10 @@ (re-frame/reg-sub :chats/photo-path :<- [:contacts/contacts] - :<- [:profile/multiaccount] + :<- [:profile/profile-with-image] (fn [[contacts {:keys [public-key] :as multiaccount}] [_ id]] (let [contact (or (when (= id public-key) multiaccount) (get contacts id))] - (contact/displayed-photo contact)))) + (profile.utils/photo contact)))) (re-frame/reg-sub :chats/unread-messages-number diff --git a/src/status_im2/subs/communities.cljs b/src/status_im2/subs/communities.cljs index 8f2592bf0d..f0917b135e 100644 --- a/src/status_im2/subs/communities.cljs +++ b/src/status_im2/subs/communities.cljs @@ -2,7 +2,6 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] [status-im2.constants :as constants] [utils.i18n :as i18n])) @@ -52,20 +51,16 @@ (re-frame/reg-sub :communities/sorted-community-members (fn [[_ community-id]] - (let [contacts (re-frame/subscribe [:contacts/contacts]) - multiaccount (re-frame/subscribe [:profile/profile]) - members (re-frame/subscribe [:communities/community-members community-id])] - [contacts multiaccount members])) - (fn [[contacts multiaccount members] _] + (let [profile (re-frame/subscribe [:profile/profile]) + members (re-frame/subscribe [:communities/community-members community-id])] + [profile members])) + (fn [[profile members] _] (let [names (reduce (fn [acc contact-identity] - (let [me? (= (:public-key multiaccount) contact-identity) - contact (when-not me? - (multiaccounts/contact-by-identity contacts contact-identity)) - name (first (multiaccounts/contact-two-names-by-identity - contact - multiaccount - contact-identity))] - (assoc acc contact-identity name))) + (assoc acc + contact-identity + (when (= (:public-key profile) contact-identity) + (:primary-name profile) + contact-identity))) {} (keys members))] (->> members diff --git a/src/status_im2/subs/contact.cljs b/src/status_im2/subs/contact.cljs index 113be2f904..5432f7961c 100644 --- a/src/status_im2/subs/contact.cljs +++ b/src/status_im2/subs/contact.cljs @@ -4,10 +4,9 @@ [quo.theme :as theme] [re-frame.core :as re-frame] [status-im.contact.db :as contact.db] - [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] - [status-im.utils.gfycat.core :as gfycat] [status-im2.constants :as constants] + [status-im2.contexts.profile.utils :as profile.utils] [utils.address :as address] [utils.collection] [utils.i18n :as i18n] @@ -213,7 +212,7 @@ :contacts/contact-by-identity :<- [:contacts/contacts] (fn [contacts [_ contact-identity]] - (multiaccounts/contact-by-identity contacts contact-identity))) + (get contacts contact-identity {:public-key contact-identity}))) (re-frame/reg-sub :contacts/contact-added? @@ -234,40 +233,17 @@ (fn [[_ contact-identity] _] [(re-frame/subscribe [:contacts/contact-by-identity contact-identity]) (re-frame/subscribe [:profile/profile])]) - (fn [[contact current-multiaccount] [_ contact-identity]] - (multiaccounts/contact-two-names-by-identity contact - current-multiaccount - contact-identity))) - -(re-frame/reg-sub - :contacts/contact-name-by-identity - (fn [[_ contact-identity] _] - [(re-frame/subscribe [:contacts/contact-two-names-by-identity contact-identity])]) - (fn [[names] _] - (first names))) - -(re-frame/reg-sub - :messages/quote-info - :<- [:chats/messages] - :<- [:contacts/contacts] - :<- [:profile/profile] - (fn [[messages contacts current-multiaccount] [_ message-id]] - (when-let [message (get messages message-id)] - (let [from-identity (:from message) - me? (= (:public-key current-multiaccount) from-identity)] - (if me? - {:quote {:from from-identity - :text (get-in message [:content :text])} - :ens-name (:preferred-name current-multiaccount) - :alias (gfycat/generate-gfy from-identity)} - (let [contact (or (contacts from-identity) - (contact.db/public-key->new-contact from-identity))] - {:quote {:from from-identity - :text (get-in message [:content :text])} - :ens-name (when (:ens-verified contact) - (:name contact)) - :alias (or (:alias contact) - (gfycat/generate-gfy from-identity))})))))) + (fn [[{:keys [primary-name] :as contact} + {:keys [public-key preferred-name display-name]}] + [_ contact-identity]] + [(if (= public-key contact-identity) + (cond + (not (string/blank? preferred-name)) preferred-name + (not (string/blank? display-name)) display-name + (not (string/blank? primary-name)) primary-name + :else public-key) + (profile.utils/displayed-name contact)) + (:secondary-name contact)])) (re-frame/reg-sub :contacts/all-contacts-not-in-current-chat diff --git a/src/status_im2/subs/messages.cljs b/src/status_im2/subs/messages.cljs index 5a8b96097f..4b32c7d1c0 100644 --- a/src/status_im2/subs/messages.cljs +++ b/src/status_im2/subs/messages.cljs @@ -278,8 +278,8 @@ (re-frame/reg-sub :messages/resolve-mention (fn [[_ mention] _] - [(re-frame/subscribe [:contacts/contact-name-by-identity mention])]) - (fn [[contact-name] [_ mention]] + [(re-frame/subscribe [:contacts/contact-two-names-by-identity mention])]) + (fn [[contact-names] [_ mention]] (if (= mention constants/everyone-mention-id) (i18n/label :t/everyone-mention) - contact-name))) + (first contact-names)))) diff --git a/src/status_im2/subs/profile.cljs b/src/status_im2/subs/profile.cljs index fe493cdef1..5d1a1a1528 100644 --- a/src/status_im2/subs/profile.cljs +++ b/src/status_im2/subs/profile.cljs @@ -39,11 +39,11 @@ :<- [:profile/profiles-overview] :<- [:mediaserver/port] :<- [:initials-avatar-font-file] - (fn [[multiaccounts port font-file] [_ target-key-uid]] - (let [{:keys [images ens-name?] :as multiaccount} (get multiaccounts target-key-uid) - image-name (-> images first :type) - override-ring? (when ens-name? false)] - (when multiaccount + (fn [[profiles port font-file] [_ target-key-uid]] + (let [{:keys [images ens-name?] :as profile} (get profiles target-key-uid) + image-name (-> images first :type) + override-ring? (when ens-name? false)] + (when profile {:fn (if image-name (image-server/get-account-image-uri-fn {:port port @@ -249,8 +249,8 @@ (pos? (count (get multiaccount :images))))) (defn- replace-multiaccount-image-uri - [multiaccount ens-names port font-file avatar-opts] - (let [{:keys [key-uid ens-name? images]} multiaccount + [profile ens-names port font-file avatar-opts] + (let [{:keys [key-uid ens-name? images]} profile ens-name? (or ens-name? (seq ens-names)) theme (theme/get-theme) avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false)) @@ -271,16 +271,16 @@ :theme theme :font-file font-file} avatar-opts))}])] - (assoc multiaccount :images new-images))) + (assoc profile :images new-images))) (re-frame/reg-sub - :profile/multiaccount + :profile/profile-with-image :<- [:profile/profile] :<- [:ens/names] :<- [:mediaserver/port] :<- [:initials-avatar-font-file] - (fn [[multiaccount ens-names port font-file] [_ avatar-opts]] - (replace-multiaccount-image-uri multiaccount ens-names port font-file avatar-opts))) + (fn [[profile ens-names port font-file] [_ avatar-opts]] + (replace-multiaccount-image-uri profile ens-names port font-file avatar-opts))) (re-frame/reg-sub :profile/login-profile diff --git a/src/status_im2/subs/shell.cljs b/src/status_im2/subs/shell.cljs index 45a94508ec..a745071873 100644 --- a/src/status_im2/subs/shell.cljs +++ b/src/status_im2/subs/shell.cljs @@ -1,7 +1,6 @@ (ns status-im2.subs.shell (:require [re-frame.core :as re-frame] - [status-im.multiaccounts.core :as multiaccounts] [status-im2.common.resources :as resources] [status-im2.config :as config] [status-im2.constants :as constants] @@ -186,15 +185,12 @@ (re-frame/subscribe [:contacts/contacts]) (re-frame/subscribe [:profile/profile]) (re-frame/subscribe [:profile/customization-color])]) - (fn [[chat communities contacts current-multiaccount profile-customization-color] [_ id]] - (let [from (get-in chat [:last-message :from]) - contact (when from (multiaccounts/contact-by-identity contacts from)) - primary-name (when from - (first (multiaccounts/contact-two-names-by-identity - contact - current-multiaccount - from)))] - (private-group-chat-card chat id communities primary-name profile-customization-color)))) + (fn [[chat communities contacts current-profile profile-customization-color] [_ id]] + (let [from (get-in chat [:last-message :from]) + contact (if from + (get contacts from {:public-key from}) + current-profile)] + (private-group-chat-card chat id communities (:primary-name contact) profile-customization-color)))) (re-frame/reg-sub :shell/community-card