Getting rid of status-im.multiaccounts.core + removing three word random names (#17384)

This commit is contained in:
Alexander 2023-11-06 14:38:14 +01:00 committed by GitHub
parent fb8a7d2d8e
commit dc571b6067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
76 changed files with 566 additions and 913 deletions

View File

@ -765,7 +765,7 @@ SPEC CHECKSUMS:
RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e
RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467 RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467
RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071 RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071
RNReanimated: 62e43ee6baafb9ba3d3af1857d7fd23a1d41bff0 RNReanimated: 42f56dc5c032a11177b9ea12cdb57285318b432e
RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c
RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8 RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9 RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9

View File

@ -1194,21 +1194,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
return getPublicStorageDirectory().getAbsolutePath(); 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) @ReactMethod(isBlockingSynchronousMethod = true)
public String encodeTransfer(final String to, final String value) { public String encodeTransfer(final String to, final String value) {
return Statusgo.encodeTransfer(to, value); return Statusgo.encodeTransfer(to, value);
@ -1269,31 +1254,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
executeRunnableStatusGoMethod(() -> Statusgo.identicon(seed), callback); 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 @Override
public @Nullable public @Nullable
Map<String, Object> getConstants() { Map<String, Object> getConstants() {

View File

@ -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) { RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(keystoreDir) {
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *rootUrl =[[fileManager NSURL *rootUrl =[[fileManager
@ -943,19 +939,6 @@ RCT_EXPORT_METHOD(initLogging:(BOOL)enabled
callback(@[initResult]); 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 RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(encodeTransfer:(NSString *)to
value:(NSString *)value) { value:(NSString *)value) {
return StatusgoEncodeTransfer(to,value); return StatusgoEncodeTransfer(to,value);
@ -1011,15 +994,6 @@ RCT_EXPORT_METHOD(validateMnemonic:(NSString *)seed
callback(@[result]); 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) { RCT_EXPORT_METHOD(createAccountAndLogin:(NSString *)request) {
#if DEBUG #if DEBUG
NSLog(@"createAccountAndLogin() method called"); NSLog(@"createAccountAndLogin() method called");
@ -1034,16 +1008,6 @@ RCT_EXPORT_METHOD(restoreAccountAndLogin:(NSString *)request) {
StatusgoRestoreAccountAndLogin(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 RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

View File

@ -354,38 +354,6 @@ void _StopCPUProfiling(const FunctionCallbackInfo<Value>& args) {
} }
void _Identicon(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
if (args.Length() != 1) {
// Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for 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<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
delete c;
}
void _EncodeTransfer(const FunctionCallbackInfo<Value>& args) { void _EncodeTransfer(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
@ -864,38 +832,6 @@ void _CreateAccountAndLogin(const FunctionCallbackInfo<Value>& args) {
} }
void _GenerateAlias(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
if (args.Length() != 1) {
// Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for 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<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
delete c;
}
void _ValidateMnemonic(const FunctionCallbackInfo<Value>& args) { void _ValidateMnemonic(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
@ -1953,7 +1889,6 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount); NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount);
NODE_SET_METHOD(exports, "initKeystore", _InitKeystore); NODE_SET_METHOD(exports, "initKeystore", _InitKeystore);
NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling); NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling);
NODE_SET_METHOD(exports, "identicon", _Identicon);
NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer); NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer);
NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall); NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall);
NODE_SET_METHOD(exports, "decodeParameters", _DecodeParameters); NODE_SET_METHOD(exports, "decodeParameters", _DecodeParameters);
@ -1968,7 +1903,6 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "resetChainData", _ResetChainData); NODE_SET_METHOD(exports, "resetChainData", _ResetChainData);
NODE_SET_METHOD(exports, "saveAccountAndLogin", _SaveAccountAndLogin); NODE_SET_METHOD(exports, "saveAccountAndLogin", _SaveAccountAndLogin);
NODE_SET_METHOD(exports, "createAccountAndLogin", _CreateAccountAndLogin); NODE_SET_METHOD(exports, "createAccountAndLogin", _CreateAccountAndLogin);
NODE_SET_METHOD(exports, "generateAlias", _GenerateAlias);
NODE_SET_METHOD(exports, "validateMnemonic", _ValidateMnemonic); NODE_SET_METHOD(exports, "validateMnemonic", _ValidateMnemonic);
NODE_SET_METHOD(exports, "multiformatSerializePublicKey", _MultiformatSerializePublicKey); NODE_SET_METHOD(exports, "multiformatSerializePublicKey", _MultiformatSerializePublicKey);
NODE_SET_METHOD(exports, "saveAccountAndLoginWithKeycard", _SaveAccountAndLoginWithKeycard); NODE_SET_METHOD(exports, "saveAccountAndLoginWithKeycard", _SaveAccountAndLoginWithKeycard);

View File

@ -4,8 +4,7 @@
[clojure.string :as string] [clojure.string :as string]
[react-native.platform :as platform] [react-native.platform :as platform]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.transforms :as types] [utils.transforms :as types]))
[utils.validators :as validators]))
(defn status (defn status
[] []
@ -431,19 +430,6 @@
;; in unknown scenarios we also consider the device rooted to avoid degrading security ;; in unknown scenarios we also consider the device rooted to avoid degrading security
:else (callback true))) :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 (defn encode-transfer
[to-norm amount-hex] [to-norm amount-hex]
(log/debug "[native-module] encode-transfer") (log/debug "[native-module] encode-transfer")
@ -501,12 +487,6 @@
(log/debug "[native-module] to-checksum-address") (log/debug "[native-module] to-checksum-address")
(.toChecksumAddress ^js (status) 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 (defn validate-mnemonic
"Validate that a mnemonic conforms to BIP39 dictionary/checksum standards" "Validate that a mnemonic conforms to BIP39 dictionary/checksum standards"
[mnemonic callback] [mnemonic callback]

View File

@ -11,9 +11,3 @@
:group/selected-contacts #{} :group/selected-contacts #{}
:new-chat-name "")} :new-chat-name "")}
(navigation/navigate-to :contact-toggle-list nil))) (navigation/navigate-to :contact-toggle-list nil)))
(defn displayed-photo
[{:keys [images]}]
(or (:large images)
(:thumbnail images)
(first images)))

View File

@ -2,21 +2,12 @@
(:require (:require
[clojure.set :as set] [clojure.set :as set]
[clojure.string :as string] [clojure.string :as string]
[status-im.utils.gfycat.core :as gfycat]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[utils.address :as address])) [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 (defn public-key-and-ens-name->new-contact
[public-key ens-name] [public-key ens-name]
(let [contact (public-key->new-contact public-key)] (let [contact {:public-key public-key}]
(if ens-name (if ens-name
(-> contact (-> contact
(assoc :ens-name ens-name) (assoc :ens-name ens-name)
@ -27,8 +18,7 @@
(defn public-key->contact (defn public-key->contact
[contacts public-key] [contacts public-key]
(when public-key (when public-key
(or (get contacts public-key) (get contacts public-key {:public-key public-key})))
(public-key->new-contact public-key))))
(defn- contact-by-address (defn- contact-by-address
[[addr contact] address] [[addr contact] address]
@ -66,8 +56,13 @@
(assoc public-key current-contact))] (assoc public-key current-contact))]
(->> members (->> members
(map #(or (get all-contacts %) (map #(or (get all-contacts %)
(public-key->new-contact %))) {:public-key %}))
(sort-by (comp string/lower-case #(or (:primary-name %) (:name %) (:alias %)))) (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 %)) (map #(if (get admins (:public-key %))
(assoc % :admin? true) (assoc % :admin? true)
%))))) %)))))

View File

@ -1,55 +1,49 @@
(ns status-im.contact.db-test (ns status-im.contact.db-test
(:require (:require [cljs.test :refer-macros [deftest is testing]]
[cljs.test :refer-macros [deftest is testing]] [status-im.contact.db :as contact.db]))
[status-im.contact.db :as contact.db]
[status-im.utils.gfycat.core :as gfycat]))
(deftest contacts-subs (deftest contacts-subs
(testing "get-all-contacts-in-group-chat" (testing "get-all-contacts-in-group-chat"
(with-redefs [gfycat/generate-gfy (constantly "generated")] (let
(let [chat-contact-ids
[chat-contact-ids #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"
#{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917" "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"} admins
admins #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
#{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
contacts contacts
{"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f" {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
{:last-updated 0 {:last-updated 0
:name "User B" :name "User B"
:primary-name "User B" :primary-name "User B"
:last-online 0 :last-online 0
:public-key :public-key
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}} "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}}
current-multiaccount current-multiaccount
{:last-updated 0 {:last-updated 0
:signed-up? true :signed-up? true
:sharing-usage-data? false :sharing-usage-data? false
:primary-name "User A" :primary-name "User A"
: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 :public-key
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}] "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
(is {:alias "User A"
(= :primary-name "User A"
(contact.db/get-all-contacts-in-group-chat chat-contact-ids :public-key
admins "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
contacts {:last-updated 0
current-multiaccount) :name "User B"
[{:name "generated" :primary-name "User B"
:primary-name "generated" :last-online 0
:alias "generated" :public-key
:admin? true "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}])))))
: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"}]))))))

View File

@ -118,7 +118,7 @@
(let [current-theme-type (get-in cofx [:db :profile/profile :appearance])] (let [current-theme-type (get-in cofx [:db :profile/profile :appearance])]
(when (and (multiaccounts.model/logged-in? db) (when (and (multiaccounts.model/logged-in? db)
(= current-theme-type status-im2.constants/theme-type-system)) (= 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]) [(get-in db [:profile/profile :appearance])
(:view-id db) true]}))) (:view-id db) true]})))

View File

@ -2,7 +2,6 @@
(:require (:require
["@react-native-async-storage/async-storage" :default AsyncStorage] ["@react-native-async-storage/async-storage" :default AsyncStorage]
["react-native" :refer (BackHandler)] ["react-native" :refer (BackHandler)]
[native-module.core :as native-module]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.keycard.card :as card] [status-im.keycard.card :as card]
[status-im.utils.deprecated-types :as types] [status-im.utils.deprecated-types :as types]
@ -200,15 +199,6 @@
(fn [^js listener] (fn [^js listener]
(.remove 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 (re-frame/reg-fx
:keycard/save-multiaccount-and-login :keycard/save-multiaccount-and-login
card/save-multiaccount-and-login) card/save-multiaccount-and-login)

View File

@ -179,37 +179,30 @@
;; name might have been generated during recovery via passphrase ;; name might have been generated during recovery via passphrase
(get-in db [:intro-wizard :derived constants/path-whisper-keyword]) (get-in db [:intro-wizard :derived constants/path-whisper-keyword])
{:name name})] {:name name})]
;; if a name is still `nil` we have to generate it before multiaccount's (rf/merge cofx
;; creation otherwise spec validation will fail {:db (-> db
(if (nil? name) (assoc-in [:keycard :setup-step] nil)
{:keycard/generate-name (dissoc :intro-wizard))}
{:public-key whisper-public-key (multiaccounts.create/on-multiaccount-created
:on-success ::on-name-generated}} {:recovered (or recovered (get-in db [:intro-wizard :recovering?]))
(rf/merge cofx :derived {constants/path-wallet-root-keyword
{:db (-> db {:public-key wallet-root-public-key
(assoc-in [:keycard :setup-step] nil) :address (eip55/address->checksum wallet-root-address)}
(dissoc :intro-wizard))} constants/path-whisper-keyword
(multiaccounts.create/on-multiaccount-created {:public-key whisper-public-key
{:recovered (or recovered (get-in db [:intro-wizard :recovering?])) :address (eip55/address->checksum whisper-address)}
:derived {constants/path-wallet-root-keyword constants/path-default-wallet-keyword
{:public-key wallet-root-public-key {:public-key wallet-public-key
:address (eip55/address->checksum wallet-root-address)} :address (eip55/address->checksum wallet-address)}}
constants/path-whisper-keyword :address address
{:public-key whisper-public-key :public-key public-key
:address (eip55/address->checksum whisper-address) :keycard-instance-uid instance-uid
:name name} :key-uid (address/normalized-hex key-uid)
constants/path-default-wallet-keyword :keycard-pairing pairing
{:public-key wallet-public-key :keycard-paired-on paired-on
:address (eip55/address->checksum wallet-address)}} :chat-key whisper-private-key}
:address address encryption-public-key
: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 (rf/defn return-to-keycard-login
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -381,17 +374,3 @@
{:on-card-connected :keycard/load-recovering-key-screen {:on-card-connected :keycard/load-recovering-key-screen
:handler (common/dispatch-event :keycard/import-multiaccount)})) :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)))

View File

@ -265,16 +265,10 @@
constants/path-default-wallet] constants/path-default-wallet]
(fn [result] (fn [result]
(let [derived-data (multiaccounts.create/normalize-derived-data-keys (let [derived-data (multiaccounts.create/normalize-derived-data-keys
(types/json->clj result)) (types/json->clj result))]
public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] (reset! derived-acc
(native-module/gfycat-identicon-async {:root-key root-data
public-key :derived derived-data}))))))))
(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})))))))))))
(when (= password (get @state :password)) (when (= password (get @state :password))
(swap! state assoc-in [:application-info :paired?] true) (swap! state assoc-in [:application-info :paired?] true)
(later #(on-success (str (rand-int 10000000)))))) (later #(on-success (str (rand-int 10000000))))))

View File

@ -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))

View File

@ -2,7 +2,6 @@
(:require (:require
[native-module.core :as native-module] [native-module.core :as native-module]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.wallet.core :as wallet] [status-im.wallet.core :as wallet]
[status-im2.common.keychain.events :as keychain] [status-im2.common.keychain.events :as keychain]
[status-im2.db :as db] [status-im2.db :as db]
@ -30,15 +29,15 @@
[{:keys [db] :as cofx} {:keys [auth-method logout?]}] [{:keys [db] :as cofx} {:keys [auth-method logout?]}]
(let [key-uid (get-in db [:profile/profile :key-uid])] (let [key-uid (get-in db [:profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:set-root :progress {:set-root :progress
:chat.ui/clear-inputs nil :chat.ui/clear-inputs nil
:shell/reset-state nil :shell/reset-state nil
:hide-popover nil :hide-popover nil
::logout nil ::logout nil
::multiaccounts/webview-debug-changed false :profile.settings/webview-debug-changed false
:keychain/clear-user-password key-uid :keychain/clear-user-password key-uid
:profile/get-profiles-overview #(rf/dispatch :profile/get-profiles-overview #(rf/dispatch
[:profile/get-profiles-overview-success %])} [:profile/get-profiles-overview-success %])}
(keychain/save-auth-method key-uid auth-method) (keychain/save-auth-method key-uid auth-method)
(wallet/clear-timeouts) (wallet/clear-timeouts)
(initialize-app-db)))) (initialize-app-db))))

View File

@ -26,12 +26,6 @@
constants/path-default-wallet] constants/path-default-wallet]
(fn [result] (fn [result]
(let [derived-data (multiaccounts.create/normalize-derived-data-keys (let [derived-data (multiaccounts.create/normalize-derived-data-keys
(types/json->clj result)) (types/json->clj result))]
public-key (get-in derived-data [constants/path-whisper-keyword :public-key])] (re-frame/dispatch [success-event root-data derived-data])))))))))
(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]))))))))))))

View File

@ -7,12 +7,12 @@
[re-frame.core :as re-frame.core] [re-frame.core :as re-frame.core]
[react-native.core :as rn] [react-native.core :as rn]
[status-im.ethereum.ens :as ens] [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.chat-icon.styles :as styles]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.icons :as icons] [status-im.ui.components.icons.icons :as icons]
[status-im.ui.screens.chat.photos :as photos] [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 ;;TODO REWORK THIS NAMESPACE
@ -161,14 +161,14 @@
(defn contact-icon-view (defn contact-icon-view
[contact {:keys [container] :as styles}] [contact {:keys [container] :as styles}]
[rn/view container [rn/view container
[photos/photo (multiaccounts/displayed-photo contact) styles]]) [photos/photo (profile.utils/photo contact) styles]])
(defn contact-icon-contacts-tab (defn contact-icon-contacts-tab
[{:keys [primary-name] :as contact}] [profile]
[rn/view styles/container-chat-list [rn/view styles/container-chat-list
[quo/user-avatar [quo/user-avatar
{:full-name primary-name {:full-name (profile.utils/displayed-name profile)
:profile-picture (multiaccounts/displayed-photo contact) :profile-picture (profile.utils/photo profile)
:size :small :size :small
:status-indicator? false}]]) :status-indicator? false}]])

View File

@ -92,7 +92,7 @@
:container-margin-bottom 8 :container-margin-bottom 8
:on-press :on-press
#(re-frame/dispatch #(re-frame/dispatch
[:multiaccounts.ui/switch-webview-debug (not webview-debug)]) [:profile.settings/change-webview-debug (not webview-debug)])
:accessory :switch :accessory :switch
:active webview-debug} :active webview-debug}
{:size :small {:size :small

View File

@ -11,7 +11,7 @@
(defn button (defn button
[label icon theme selected?] [label icon theme selected?]
[react/touchable-highlight [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 [react/view
(merge {:align-items :center :padding 8 :border-radius 20} (merge {:align-items :center :padding 8 :border-radius 20}
(when selected? (when selected?

View File

@ -3,7 +3,6 @@
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.communities.core :as communities] [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.chat-icon.screen :as chat-icon]
[status-im.ui.components.core :as quo] [status-im.ui.components.core :as quo]
[status-im.ui.components.list.item :as list.item] [status-im.ui.components.list.item :as list.item]
@ -11,6 +10,7 @@
[status-im.ui.components.topbar :as topbar] [status-im.ui.components.topbar :as topbar]
[status-im.ui.components.unviewed-indicator :as unviewed-indicator] [status-im.ui.components.unviewed-indicator :as unviewed-indicator]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -69,7 +69,7 @@
:accessibility-label :member-item :accessibility-label :member-item
:icon [chat-icon/profile-photo-plus-dot-view :icon [chat-icon/profile-photo-plus-dot-view
{:public-key public-key {:public-key public-key
:photo-path (multiaccounts/displayed-photo member)}] :photo-path (profile.utils/photo member)}]
:accessory (when (not= public-key my-public-key) :accessory (when (not= public-key my-public-key)
[quo/button [quo/button
{:on-press {:on-press

View File

@ -1,13 +1,13 @@
(ns status-im.ui.screens.contacts-list.views (ns status-im.ui.screens.contacts-list.views
(:require (:require
[re-frame.core :as re-frame] [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.chat-icon.screen :as chat-icon.screen]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.invite.views :as invite] [status-im.ui.components.invite.views :as invite]
[status-im.ui.components.list.item :as list.item] [status-im.ui.components.list.item :as list.item]
[status-im.ui.components.list.views :as list.views] [status-im.ui.components.list.views :as list.views]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
@ -21,7 +21,7 @@
{:public-key public-key {:public-key public-key
:full-name primary-name :full-name primary-name
:customization-color (or customization-color :primary) :customization-color (or customization-color :primary)
:photo-path (multiaccounts/displayed-photo contact)}] :photo-path (profile.utils/photo contact)}]
:chevron true :chevron true
:on-press #(re-frame/dispatch [:chat.ui/show-profile public-key])}])) :on-press #(re-frame/dispatch [:chat.ui/show-profile public-key])}]))

View File

@ -21,7 +21,7 @@
{:active (= value id) {:active (= value id)
:accessory :radio :accessory :radio
:title (get titles id) :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 (views/defview default-sync-period-settings
[] []

View File

@ -14,8 +14,6 @@
[status-im.ui.screens.keycard.styles :as styles] [status-im.ui.screens.keycard.styles :as styles]
[status-im.ui.screens.keycard.views :as keycard.views] [status-im.ui.screens.keycard.views :as keycard.views]
[status-im.utils.core :as utils.core] [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] [status-im2.constants :as constants]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
@ -207,24 +205,13 @@
[react/view [react/view
{:margin-horizontal 16 {:margin-horizontal 16
:flex-direction :column} :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 [react/text
{:style {:text-align :center {:style {:text-align :center
:color colors/black :color colors/black
:font-weight "500"} :font-weight "500"}
:number-of-lines 1 :number-of-lines 1
:ellipsize-mode :middle} :ellipsize-mode :middle}
(gfy/generate-gfy whisper-public-key)] whisper-public-key]
[quo/text [quo/text
{:style {:margin-top 4} {:style {:margin-top 4}
:monospace true :monospace true

View File

@ -5,7 +5,6 @@
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.bottom-sheet.events :as bottom-sheet] [status-im.bottom-sheet.events :as bottom-sheet]
[status-im.keycard.login :as keycard.login] [status-im.keycard.login :as keycard.login]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.core :as quo] [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.pin.views :as pin.views]
[status-im.ui.screens.keycard.styles :as styles] [status-im.ui.screens.keycard.styles :as styles]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[status-im2.navigation.events :as navigation] [status-im2.navigation.events :as navigation]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf]) [utils.re-frame :as rf])
@ -212,7 +212,7 @@
:reagent-render :reagent-render
(fn [account small-screen?] (fn [account small-screen?]
;;TODO this should be done in a subscription ;;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)}])})) {:size (if small-screen? 45 61)}])}))
(defn access-is-reset (defn access-is-reset

View File

@ -3,12 +3,12 @@
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
status-im.keycard.delete-key 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.chat-icon.screen :as chat-icon.screen]
[status-im.ui.components.core :as quo] [status-im.ui.components.core :as quo]
[status-im.ui.components.list.item :as list.item] [status-im.ui.components.list.item :as list.item]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im.ui.screens.privacy-and-security-settings.events :as delete-profile] [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.i18n :as i18n]
[utils.security.core :as security])) [utils.security.core :as security]))
@ -33,10 +33,11 @@
(let [password (reagent/atom nil) (let [password (reagent/atom nil)
text-input-ref (atom nil)] text-input-ref (atom nil)]
(fn [] (fn []
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?]) (let [profile @(re-frame/subscribe [:profile/profile])
multiaccount @(re-frame/subscribe [:profile/profile]) keycard? @(re-frame/subscribe [:keycard-multiaccount?])
error @(re-frame/subscribe [:delete-profile/error]) 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)) (when (and @text-input-ref error (not @password))
(.clear ^js @text-input-ref)) (.clear ^js @text-input-ref))
[react/keyboard-avoiding-view {:style {:flex 1}} [react/keyboard-avoiding-view {:style {:flex 1}}
@ -47,8 +48,8 @@
:size :x-large} :size :x-large}
(i18n/label :t/delete-profile)]] (i18n/label :t/delete-profile)]]
[list.item/list-item [list.item/list-item
{:title (multiaccounts/displayed-name multiaccount) {:title (profile.utils/displayed-name profile)
:icon [chat-icon.screen/contact-icon-contacts-tab multiaccount]}] :icon [chat-icon.screen/contact-icon-contacts-tab profile]}]
(when keycard? (when keycard?
[react/view [react/view
[quo/list-header (i18n/label :t/actions)] [quo/list-header (i18n/label :t/actions)]

View File

@ -64,7 +64,7 @@
:active preview-privacy? :active preview-privacy?
:accessory :switch :accessory :switch
:on-press #(re-frame/dispatch :on-press #(re-frame/dispatch
[:multiaccounts.ui/preview-privacy-mode-switched [:profile.settings/change-preview-privacy
((complement boolean) preview-privacy?)])}] ((complement boolean) preview-privacy?)])}]
(when config/collectibles-enabled? (when config/collectibles-enabled?
[list.item/list-item [list.item/list-item
@ -111,7 +111,8 @@
:subtitle (i18n/label :t/webview-camera-permission-requests-subtitle) :subtitle (i18n/label :t/webview-camera-permission-requests-subtitle)
:subtitle-max-lines 2 :subtitle-max-lines 2
:on-press #(re-frame/dispatch :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?)])}]) ((complement boolean) webview-allow-permission-requests?)])}])
[separator] [separator]
[quo/list-header (i18n/label :t/privacy-photos)] [quo/list-header (i18n/label :t/privacy-photos)]
@ -148,7 +149,7 @@
{:active (= value id) {:active (= value id)
:accessory :radio :accessory :radio
:title (get titles id) :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 (views/defview profile-pic-show-to
[] []
@ -168,7 +169,8 @@
{:active (= value id) {:active (= value id)
:accessory :radio :accessory :radio
:title (get titles id) :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 (views/defview profile-pic
[] []

View File

@ -5,7 +5,6 @@
[quo.theme :as theme] [quo.theme :as theme]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.core :as quo] [status-im.ui.components.core :as quo]
[status-im.ui.components.keyboard-avoid-presentation :as kb-presentation] [status-im.ui.components.keyboard-avoid-presentation :as kb-presentation]
@ -16,11 +15,12 @@
[status-im.ui.components.topbar :as topbar] [status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.profile.components.sheets :as sheets] [status-im.ui.screens.profile.components.sheets :as sheets]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn actions (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) (concat [{:label (i18n/label :t/chat)
:icon :main-icons/message :icon :main-icons/message
:disabled (not mutual?) :disabled (not mutual?)
@ -33,7 +33,7 @@
:icon :main-icons/remove-contact :icon :main-icons/remove-contact
:selected true :selected true
:accessibility-label :in-contacts-button :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) [{:label (i18n/label :t/add-to-contacts)
:icon :main-icons/add-contact :icon :main-icons/add-contact
:disabled blocked? :disabled blocked?
@ -114,15 +114,15 @@
(defn nickname-view (defn nickname-view
[] []
(let [{:keys [public-key primary-name nickname]} (rf/sub [:contacts/current-contact]) (let [{:keys [public-key nickname] :as profile} (rf/sub [:contacts/current-contact])
entered-nickname (reagent/atom nickname)] entered-nickname (reagent/atom nickname)]
(fn [] (fn []
[kb-presentation/keyboard-avoiding-view [kb-presentation/keyboard-avoiding-view
{:style {:flex 1} {:style {:flex 1}
:ignore-offset true} :ignore-offset true}
[topbar/topbar [topbar/topbar
{:title (i18n/label :t/nickname) {:title (i18n/label :t/nickname)
:subtitle primary-name :subtitle (profile.utils/displayed-name profile)
:modal? true}] :modal? true}]
[react/view {:flex 1 :padding 16} [react/view {:flex 1 :padding 16}
[react/text {:style {:color colors/gray :margin-bottom 16}} [react/text {:style {:color colors/gray :margin-bottom 16}}
@ -173,29 +173,25 @@
:number-of-lines 2} :number-of-lines 2}
label]]]) label]]])
(defn profile (defn profile-view
[] []
(let [{:keys [public-key (let [{:keys [public-key
secondary-name
name name
ens-verified ens-verified
customization-color
compressed-key] compressed-key]
:as contact} :as profile} @(re-frame/subscribe [:contacts/current-contact])
@(re-frame/subscribe muted? @(re-frame/subscribe [:chats/muted public-key])
[:contacts/current-contact])
muted? @(re-frame/subscribe [:chats/muted
public-key])
{:keys [primary-name secondary-name customization-color]} contact
customization-color (or customization-color :primary) customization-color (or customization-color :primary)
on-share #(re-frame/dispatch on-share #(re-frame/dispatch [:show-popover
[:show-popover (merge
(merge {:view :share-chat-key
{:view :share-chat-key :address (or compressed-key
:address (or compressed-key public-key)}
public-key)} (when (and ens-verified name)
(when (and ens-verified name) {:ens-name name}))])]
{:ens-name name}))])] (when profile
(when contact
[:<> [:<>
[quo/header [quo/header
{:right-accessories [{:icon :main-icons/share {:right-accessories [{:icon :main-icons/share
@ -206,27 +202,26 @@
:on-press #(re-frame/dispatch [:navigate-back])}]}] :on-press #(re-frame/dispatch [:navigate-back])}]}]
[:<> [:<>
[(profile-header/extended-header [(profile-header/extended-header
{:on-press on-share {:on-press on-share
:bottom-separator false :bottom-separator false
:title primary-name :title (profile.utils/displayed-name profile)
:color :color (user-avatar.style/customization-color customization-color
(user-avatar.style/customization-color customization-color (theme/get-theme))
(theme/get-theme)) :photo (profile.utils/photo profile)
:photo (multiaccounts/displayed-photo contact) :monospace (not ens-verified)
:monospace (not ens-verified) :subtitle secondary-name
:subtitle secondary-name :compressed-key compressed-key
:compressed-key compressed-key :public-key public-key})]
:public-key public-key})]
[react/view [react/view
{:height 1 :background-color colors/gray-lighter :margin-top 8}] {: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 {:height 1 :background-color colors/gray-lighter}]
[react/view [react/view
{:padding-top 17 {:padding-top 17
:flex-direction :row :flex-direction :row
:align-items :stretch :align-items :stretch
:flex 1} :flex 1}
(for [{:keys [label] :as action} (actions contact muted?) (for [{:keys [label] :as action} (actions profile muted?)
:when label] :when label]
^{:key label} ^{:key label}
[button-item action])]]]))) [button-item action])]]])))

View File

@ -1,7 +1,6 @@
(ns status-im.ui.screens.profile.group-chat.views (ns status-im.ui.screens.profile.group-chat.views
(:require (:require
[re-frame.core :as re-frame] [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.chat-icon.screen :as chat-icon]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.common.common :as components.common] [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.chat.utils :as chat.utils]
[status-im.ui.screens.profile.components.styles :as profile.components.styles] [status-im.ui.screens.profile.components.styles :as profile.components.styles]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.debounce :as debounce] [utils.debounce :as debounce]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :refer [defview letsubs]])) (:require-macros [status-im.utils.views :refer [defview letsubs]]))
@ -26,15 +26,14 @@
[list.item/list-item [list.item/list-item
{:theme :accent {:theme :accent
:icon [chat-icon/contact-icon-contacts-tab member] :icon [chat-icon/contact-icon-contacts-tab member]
:title (:primary-name member) :title (profile.utils/displayed-name member)
:subtitle (i18n/label :t/view-profile) :subtitle (i18n/label :t/view-profile)
:accessibility-label :view-chat-details-button :accessibility-label :view-chat-details-button
:chevron true :chevron true
:on-press #(chat.sheets/hide-sheet-and-dispatch :on-press #(chat.sheets/hide-sheet-and-dispatch
[:chat.ui/show-profile [:chat.ui/show-profile
(:public-key member)])}] (:public-key member)])}]
(when (and us-admin? (when (and us-admin? (not (:admin? member)))
(not (:admin? member)))
[list.item/list-item [list.item/list-item
{:theme :accent {:theme :accent
:title (i18n/label :t/make-admin) :title (i18n/label :t/make-admin)
@ -54,10 +53,10 @@
(defn render-member (defn render-member
[{:keys [public-key] :as member} _ _ {:keys [chat-id admin? current-user-identity]}] [{: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 [list.item/list-item
(merge (merge
{:title primary-name {:title (profile.utils/displayed-name member)
:subtitle secondary-name :subtitle secondary-name
:accessibility-label :member-item :accessibility-label :member-item
:icon [chat-icon/contact-icon-contacts-tab member] :icon [chat-icon/contact-icon-contacts-tab member]
@ -118,7 +117,7 @@
(chat.utils/format-author-old contact)] (chat.utils/format-author-old contact)]
[react/view {:flex-direction :row :align-items :flex-end} [react/view {:flex-direction :row :align-items :flex-end}
[react/view {:padding-left 16 :padding-top 4} [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 [list.item/list-item
{:theme :accent {:theme :accent
:disabled (not allow-adding-members?) :disabled (not allow-adding-members?)
@ -137,9 +136,10 @@
(defn contacts-list-item (defn contacts-list-item
[{:keys [from] :as invitation}] [{: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 [list.item/list-item
{:title (multiaccounts/displayed-name contact) {:title (profile.utils/displayed-name contact)
:icon [chat-icon/contact-icon-contacts-tab contact] :icon [chat-icon/contact-icon-contacts-tab contact]
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old :on-press #(re-frame/dispatch [:bottom-sheet/show-sheet-old
{:content (fn [] {:content (fn []

View File

@ -1,10 +1,10 @@
(ns status-im.ui.screens.profile.user.edit-picture (ns status-im.ui.screens.profile.user.edit-picture
(:require (:require
[re-frame.core :as re-frame] [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.list.item :as list.item]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im2.config :as config] [status-im2.config :as config]
[status-im2.contexts.profile.settings.events]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
(def crop-size 1000) (def crop-size 1000)
@ -18,14 +18,14 @@
[] []
(re-frame/dispatch [:bottom-sheet/hide-old]) (re-frame/dispatch [:bottom-sheet/hide-old])
(react/show-image-picker (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)) crop-opts))
(defn take-pic (defn take-pic
[] []
(re-frame/dispatch [:bottom-sheet/hide-old]) (re-frame/dispatch [:bottom-sheet/hide-old])
(react/show-image-picker-camera (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)) crop-opts))
(defn bottom-sheet (defn bottom-sheet
@ -51,4 +51,4 @@
:icon :main-icons/delete :icon :main-icons/delete
:theme :accent :theme :accent
:title (i18n/label :t/profile-pic-remove) :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])}])]))

View File

@ -5,7 +5,6 @@
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.ethereum.stateofus :as stateofus] [status-im.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.common.common :as components.common] [status-im.ui.components.common.common :as components.common]
[status-im.ui.components.copyable-text :as copyable-text] [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.edit-picture :as edit]
[status-im.ui.screens.profile.user.styles :as styles] [status-im.ui.screens.profile.user.styles :as styles]
[status-im.ui.screens.profile.visibility-status.views :as visibility-status] [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.universal-links.utils :as universal-links]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im2.common.qr-codes.view :as qr-codes] [status-im2.common.qr-codes.view :as qr-codes]
[status-im2.config :as config] [status-im2.config :as config]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [status-im.utils.views :as views])) (:require-macros [status-im.utils.views :as views]))
@ -198,8 +197,8 @@
ens-verified ens-verified
preferred-name preferred-name
key-uid] key-uid]
:as account} :as profile}
@(re-frame/subscribe [:profile/multiaccount]) @(re-frame/subscribe [:profile/profile-with-image])
customization-color (or (:color @(re-frame/subscribe [:onboarding-2/profile])) customization-color (or (:color @(re-frame/subscribe [:onboarding-2/profile]))
@(re-frame/subscribe [:profile/customization-color key-uid])) @(re-frame/subscribe [:profile/customization-color key-uid]))
on-share #(re-frame/dispatch [:show-popover on-share #(re-frame/dispatch [:show-popover
@ -224,12 +223,8 @@
has-picture)}]) has-picture)}])
:color (user-avatar.style/customization-color customization-color :color (user-avatar.style/customization-color customization-color
(theme/get-theme)) (theme/get-theme))
:title (multiaccounts/displayed-name account) :title (profile.utils/displayed-name profile)
:photo (multiaccounts/displayed-photo account) :photo (profile.utils/photo profile)
:monospace (not ens-verified) :monospace (not ens-verified)
:subtitle (if (and ens-verified public-key) :subtitle (utils/get-shortened-address (or compressed-key public-key))})}
(gfy/generate-gfy public-key)
(utils/get-shortened-address (or
compressed-key
public-key)))})}
[content]]]))) [content]]])))

View File

@ -521,7 +521,7 @@
;;TODO custom toolbar ;;TODO custom toolbar
:options {:insets {:bottom? true :options {:insets {:bottom? true
:top? true}} :top? true}}
:component contact/profile} :component contact/profile-view}
;KEYCARD ;KEYCARD
{:name :keycard-onboarding-intro {:name :keycard-onboarding-intro

View File

@ -7,7 +7,6 @@
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.ethereum.tokens :as tokens] [status-im.ethereum.tokens :as tokens]
[status-im.keycard.common :as keycard.common] [status-im.keycard.common :as keycard.common]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.signing.eip1559 :as eip1559] [status-im.signing.eip1559 :as eip1559]
[status-im.ui.components.bottom-panel.views :as bottom-panel] [status-im.ui.components.bottom-panel.views :as bottom-panel]
@ -26,6 +25,7 @@
[status-im.utils.deprecated-types :as types] [status-im.utils.deprecated-types :as types]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.wallet.utils :as wallet.utils] [status-im.wallet.utils :as wallet.utils]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.security.core :as security])) [utils.security.core :as security]))
@ -33,16 +33,10 @@
[] []
[react/view {:height 1 :background-color colors/gray-lighter}]) [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 (defn contact-item
[title contact] [title {:keys [address] :as profile}]
[copyable-text/copyable-text-view [copyable-text/copyable-text-view
{:copied-text (:address contact)} {:copied-text address}
[list.item/list-item [list.item/list-item
{:title title {:title title
:title-prefix-width 45 :title-prefix-width 45
@ -52,7 +46,7 @@
{:ellipsize-mode :middle {:ellipsize-mode :middle
:number-of-lines 1 :number-of-lines 1
:monospace true} :monospace true}
(displayed-name contact)]}]]) (profile.utils/displayed-name profile)]}]])
(defn token-item (defn token-item
[{:keys [icon color] :as token} display-symbol] [{:keys [icon color] :as token} display-symbol]
@ -103,7 +97,7 @@
{:style {:color colors/gray} {:style {:color colors/gray}
:ellipsize-mode :middle :ellipsize-mode :middle
:number-of-lines 1} (i18n/label :t/to-capitalized) " " :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}} [react/text {:style {:margin-top 6 :color colors/gray}}
(str fee " " fee-display-symbol " " (string/lower-case (i18n/label :t/network-fee)))])] (str fee " " fee-display-symbol " " (string/lower-case (i18n/label :t/network-fee)))])]
[react/view {:padding-horizontal 24} [react/view {:padding-horizontal 24}

View File

@ -4,7 +4,6 @@
[clojure.string :as string] [clojure.string :as string]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.ui.components.accordion :as accordion] [status-im.ui.components.accordion :as accordion]
@ -308,8 +307,8 @@
[list.item/list-item [list.item/list-item
{:title (i18n/label :t/use-as-profile-picture) {:title (i18n/label :t/use-as-profile-picture)
:theme :accent :theme :accent
:on-press #(re-frame/dispatch :on-press #(re-frame/dispatch [:profile.settings/save-profile-picture-from-url
[::multiaccounts/save-profile-picture-from-url (:image_url nft)]) (:image_url nft)])
:icon :main-icons/profile :icon :main-icons/profile
:accessibility-label :accessibility-label
:set-nft-as-pfp}]])])) :set-nft-as-pfp}]])]))

View File

@ -4,7 +4,6 @@
[quo.core :as quo] [quo.core :as quo]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.commands.core :as commands] [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.bottom-panel.views :as bottom-panel]
[status-im.ui.components.chat-icon.screen :as chat-icon] [status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
@ -20,6 +19,7 @@
[status-im.ui.screens.wallet.send.styles :as styles] [status-im.ui.screens.wallet.send.styles :as styles]
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.wallet.utils :as wallet.utils] [status-im.wallet.utils :as wallet.utils]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.address :as address] [utils.address :as address]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.money :as money])) [utils.money :as money]))
@ -78,14 +78,14 @@
:content-height 300}]))}]) :content-height 300}]))}])
(defn render-contact (defn render-contact
[contact from-chat?] [{:keys [address] :as contact} from-chat?]
(if from-chat? (if from-chat?
[list.item/list-item [list.item/list-item
{:title (multiaccounts/displayed-name contact) {:title (profile.utils/displayed-name contact)
:subtitle [components.core/text :subtitle [components.core/text
{:monospace true {:monospace true
:color :secondary} :color :secondary}
(utils/get-shortened-checksum-address (:address contact))] (utils/get-shortened-checksum-address address)]
:icon [chat-icon/contact-icon-contacts-tab contact]}] :icon [chat-icon/contact-icon-contacts-tab contact]}]
[list.item/list-item [list.item/list-item
(merge {:title (if-not contact (merge {:title (if-not contact
@ -94,7 +94,7 @@
{:size :large {:size :large
:monospace true} :monospace true}
(utils/get-shortened-checksum-address (utils/get-shortened-checksum-address
(if (string? contact) contact (:address contact)))]) (if (string? contact) contact address))])
:accessibility-label :choose-recipient-button :accessibility-label :choose-recipient-button
:on-press #(do :on-press #(do
(re-frame/dispatch [:dismiss-keyboard]) (re-frame/dispatch [:dismiss-keyboard])

View File

@ -47,7 +47,8 @@
[quo/button [quo/button
{:on-press #(do {:on-press #(do
(when-not wallet-set-up-passed? (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])) (re-frame/dispatch [:hide-popover]))
:type :secondary} :type :secondary}
(i18n/label :t/ok-got-it)]]]])) (i18n/label :t/ok-got-it)]]]]))

View File

@ -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))

View File

@ -1,5 +0,0 @@
(ns status-im.utils.identicon
(:require
[native-module.core :as native-module]))
(def identicon (memoize native-module/identicon))

View File

@ -59,15 +59,6 @@
:logout :logout
(fn [] (.logout native-status)) (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 :multiAccountGenerateAndDeriveAddresses
(fn [json callback] (fn [json callback]
(callback (.multiAccountGenerateAndDeriveAddresses native-status json))) (callback (.multiAccountGenerateAndDeriveAddresses native-status json)))
@ -96,9 +87,6 @@
(callback (.initKeystore native-status (callback (.initKeystore native-status
(str test-dir "/keystore/" key-uid)))) (str test-dir "/keystore/" key-uid))))
:identicon
(fn [pk] (.identicon native-status pk))
:encodeTransfer :encodeTransfer
(fn [to-norm amount-hex] (fn [to-norm amount-hex]
(.encodeTransfer native-status to-norm amount-hex)) (.encodeTransfer native-status to-norm amount-hex))

View File

@ -3,26 +3,24 @@
[cljs.test :refer-macros [deftest is testing]] [cljs.test :refer-macros [deftest is testing]]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.router.core :as router] [status-im.router.core :as router]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.universal-links.core :as links])) [status-im.utils.universal-links.core :as links]))
(deftest handle-url-test (deftest handle-url-test
(with-redefs [gfycat/generate-gfy (constantly "generated")] (testing "the user is not logged in"
(testing "the user is not logged in" (testing "it stores the url for later processing"
(testing "it stores the url for later processing" (is (= {:db {:universal-links/url "some-url"}}
(is (= {:db {:universal-links/url "some-url"}} (links/handle-url {:db {}} "some-url")))))
(links/handle-url {:db {}} "some-url"))))) (testing "the user is logged in"
(testing "the user is logged in" (let [db {:profile/profile {:public-key "pk"}
(let [db {:profile/profile {:public-key "pk"} :app-state "active"
:app-state "active" :universal-links/url "some-url"}]
:universal-links/url "some-url"}] (testing "it clears the url"
(testing "it clears the url" (is (nil? (get-in (links/handle-url {:db db} "some-url")
(is (nil? (get-in (links/handle-url {:db db} "some-url") [:db :universal-links/url]))))
[:db :universal-links/url])))) (testing "Handle a custom string"
(testing "Handle a custom string" (is (= (get-in (links/handle-url {:db db} "https://status.app/u#statuse2e")
(is (= (get-in (links/handle-url {:db db} "https://status.app/u#statuse2e") [::router/handle-uri :uri])
[::router/handle-uri :uri]) "https://status.app/u#statuse2e"))))))
"https://status.app/u#statuse2e")))))))
(deftest url-event-listener (deftest url-event-listener
(testing "the url is not nil" (testing "the url is not nil"

View File

@ -7,7 +7,6 @@
[status-im.ethereum.eip681 :as eip681] [status-im.ethereum.eip681 :as eip681]
[status-im.ethereum.mnemonic :as mnemonic] [status-im.ethereum.mnemonic :as mnemonic]
[status-im.ethereum.stateofus :as stateofus] [status-im.ethereum.stateofus :as stateofus]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.list-selection :as list-selection] [status-im.ui.components.list-selection :as list-selection]
@ -123,7 +122,7 @@
(native-module/verify (native-module/verify
address address
hashed-password 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])))) hashed-password]))))
(re-frame/reg-fx (re-frame/reg-fx
@ -150,6 +149,11 @@
(string/trim (security/unmask private-key)) (string/trim (security/unmask private-key))
(store-account key-uid constants/path-default-wallet hashed-password :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 (rf/defn generate-new-account
[{:keys [db]} hashed-password] [{:keys [db]} hashed-password]
(let [{:keys [key-uid wallet-root-address]} (let [{:keys [key-uid wallet-root-address]}
@ -165,10 +169,10 @@
(rf/defn import-new-account-seed (rf/defn import-new-account-seed
[{:keys [db]} passphrase hashed-password] [{:keys [db]} passphrase hashed-password]
{:db (assoc-in db [:add-account :step] :generating) {:db (assoc-in db [:add-account :step] :generating)
::multiaccounts/validate-mnemonic [(security/safe-unmask-data passphrase) ::validate-mnemonic [(security/safe-unmask-data passphrase)
#(re-frame/dispatch [:wallet-legacy.accounts/seed-validated #(re-frame/dispatch [:wallet-legacy.accounts/seed-validated % passphrase
% passphrase hashed-password])]}) hashed-password])]})
(rf/defn new-account-seed-validated (rf/defn new-account-seed-validated
{:events [:wallet-legacy.accounts/seed-validated]} {:events [:wallet-legacy.accounts/seed-validated]}
@ -254,8 +258,8 @@
{:address (eip55/address->checksum (address/normalized-hex address)) {:address (eip55/address->checksum (address/normalized-hex address))
:type :watch}))) :type :watch})))
(rf/defn add-new-account-password-verifyied (rf/defn add-new-account-password-verified
{:events [:wallet-legacy.accounts/add-new-account-password-verifyied]} {:events [:wallet-legacy.accounts/add-new-account-password-verified]}
[{:keys [db] :as cofx} result hashed-password] [{:keys [db] :as cofx} result hashed-password]
(let [{:keys [error]} (types/json->clj result)] (let [{:keys [error]} (types/json->clj result)]
(if (not (string/blank? error)) (if (not (string/blank? error))

View File

@ -465,9 +465,7 @@
{:from (wallet.utils/get-default-account (:profile/wallet-accounts {:from (wallet.utils/get-default-account (:profile/wallet-accounts
db)) db))
:to (or (get-in db [:contacts/contacts identity]) :to (or (get-in db [:contacts/contacts identity])
(-> identity (contact.db/enrich-contact {:public-key identity}))
contact.db/public-key->new-contact
contact.db/enrich-contact))
:request-parameters request-parameters :request-parameters request-parameters
:chat-id chat-id :chat-id chat-id
:symbol symbol :symbol symbol
@ -513,9 +511,7 @@
(let [identity (:current-chat-id db) (let [identity (:current-chat-id db)
{:keys [ens-verified name] :as contact} {:keys [ens-verified name] :as contact}
(or (get-in db [:contacts/contacts identity]) (or (get-in db [:contacts/contacts identity])
(-> identity (contact.db/enrich-contact {:public-key identity}))]
contact.db/public-key->new-contact
contact.db/enrich-contact))]
(cond-> {:db (assoc db (cond-> {:db (assoc db
:wallet-legacy/prepare-transaction :wallet-legacy/prepare-transaction
{:from (wallet.utils/get-default-account {:from (wallet.utils/get-default-account
@ -541,9 +537,7 @@
:wallet-legacy/prepare-transaction :wallet-legacy/prepare-transaction
{:from (wallet.utils/get-default-account (:profile/wallet-accounts db)) {:from (wallet.utils/get-default-account (:profile/wallet-accounts db))
:to (or (get-in db [:contacts/contacts identity]) :to (or (get-in db [:contacts/contacts identity])
(-> identity (contact.db/enrich-contact {:public-key identity}))
contact.db/public-key->new-contact
contact.db/enrich-contact))
:symbol :ETH :symbol :ETH
:from-chat? true :from-chat? true
:request-command? true}) :request-command? true})

View File

@ -37,14 +37,15 @@
(let [{:keys [group-chat chat-id public-key color (let [{:keys [group-chat chat-id public-key color
profile-picture name]} context profile-picture name]} context
id (or chat-id public-key) id (or chat-id public-key)
contact-name-by-identity (when-not group-chat [primary-name _] (when-not group-chat
(rf/sub [:contacts/contact-name-by-identity id])) (rf/sub [:contacts/contact-two-names-by-identity id]))
display-name (cond display-name (cond
(= contact-name-by-identity (= primary-name "Unknown")
"Unknown") name name
(= contact-name-by-identity (= primary-name nil)
nil) name name
:else contact-name-by-identity) :else
primary-name)
photo-path (or profile-picture (rf/sub [:chats/photo-path id]))] photo-path (or profile-picture (rf/sub [:chats/photo-path id]))]
[rn/view [rn/view
{:style {:margin-horizontal 20} {:style {:margin-horizontal 20}

View File

@ -342,9 +342,9 @@
(defn remove-from-group-entry (defn remove-from-group-entry
[{:keys [public-key]} chat-id] [{: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 (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 :on-press #(hide-sheet-and-dispatch [:group-chats.ui/remove-member-pressed chat-id
public-key true]) public-key true])
:danger? true :danger? true

View File

@ -1,9 +1,9 @@
(ns status-im2.common.home.top-nav.view (ns status-im2.common.home.top-nav.view
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[status-im.multiaccounts.core :as multiaccounts]
[status-im2.common.home.top-nav.style :as style] [status-im2.common.home.top-nav.style :as style]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.debounce :refer [dispatch-and-chill]] [utils.debounce :refer [dispatch-and-chill]]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -14,22 +14,24 @@
:jump-to? true/false :jump-to? true/false
:container-style passed to outer view of component}" :container-style passed to outer view of component}"
[{:keys [container-style blur? jump-to?]}] [{:keys [container-style blur? jump-to?]}]
(let [{:keys [public-key]} (rf/sub [:profile/profile]) (let [{:keys [public-key] :as profile} (rf/sub [:profile/profile-with-image])
online? (rf/sub [:visibility-status-updates/online? public-key]) online? (rf/sub [:visibility-status-updates/online?
account (rf/sub [:profile/multiaccount]) public-key])
customization-color (rf/sub [:profile/customization-color]) customization-color (rf/sub [:profile/customization-color])
avatar {:online? online? avatar {:online? online?
:full-name (multiaccounts/displayed-name account) :full-name (profile.utils/displayed-name profile)
:profile-picture (multiaccounts/displayed-photo account)} :profile-picture (profile.utils/photo profile)}
unread-count (rf/sub [:activity-center/unread-count])
indicator (rf/sub [:activity-center/unread-indicator]) unread-count (rf/sub [:activity-center/unread-count])
notification-type (case indicator indicator (rf/sub [:activity-center/unread-indicator])
:unread-indicator/seen :mention-seen ; should be `seen` - TODO discuss notification-type (case indicator
; with design team about ; should be `seen` TODO discuss with design team
; notifications for activity centre ; notifications for activity centre
:unread-indicator/new :mention ; should be :notification TODO :unread-indicator/seen :mention-seen
; https://github.com/status-im/status-mobile/issues/17102 ; should be :notification TODO
nil)] ; https://github.com/status-im/status-mobile/issues/17102
:unread-indicator/new :mention
nil)]
[quo/top-nav [quo/top-nav
{:avatar-on-press #(rf/dispatch [:navigate-to :my-profile]) {:avatar-on-press #(rf/dispatch [:navigate-to :my-profile])
:scan-on-press #(js/alert "to be implemented") :scan-on-press #(js/alert "to be implemented")

View File

@ -4,7 +4,7 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.multiaccounts.core :as multiaccounts] [status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -12,7 +12,7 @@
[] []
(let [entered-password (reagent/atom "")] (let [entered-password (reagent/atom "")]
(fn [] (fn []
(let [account (rf/sub [:profile/multiaccount]) (let [profile (rf/sub [:profile/profile-with-image])
{:keys [error button]} (rf/sub [:password-authentication])] {:keys [error button]} (rf/sub [:password-authentication])]
[rn/view {:padding-horizontal 20} [rn/view {:padding-horizontal 20}
[quo/text {:size :heading-1 :weight :semi-bold} [quo/text {:size :heading-1 :weight :semi-bold}
@ -20,8 +20,8 @@
[rn/view {:style {:margin-top 8 :margin-bottom 20}} [rn/view {:style {:margin-top 8 :margin-bottom 20}}
[quo/context-tag [quo/context-tag
{:size 24 {:size 24
:profile-picture (multiaccounts/displayed-photo account) :full-name (profile.utils/displayed-name profile)
:full-name (multiaccounts/displayed-name account)}]] :profile-picture (profile.utils/photo profile)}]]
[quo/input [quo/input
{:type :password {:type :password
:label (i18n/label :t/profile-password) :label (i18n/label :t/profile-password)

View File

@ -2,18 +2,17 @@
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [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.enter-password.style :as style]
[status-im2.common.standard-authentication.password-input.view :as password-input] [status-im2.common.standard-authentication.password-input.view :as password-input]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn view (defn view
[{:keys [on-enter-password button-label button-icon-left customization-color]}] [{:keys [on-enter-password button-label button-icon-left customization-color]}]
(let [{:keys [key-uid display-name] :as account} (rf/sub [:profile/multiaccount]) (let [{:keys [key-uid] :as profile} (rf/sub [:profile/profile-with-image])
{:keys [error processing password]} (rf/sub [:profile/login]) {:keys [error processing password]} (rf/sub [:profile/login])
sign-in-enabled? (rf/sub [:sign-in-enabled?]) sign-in-enabled? (rf/sub [:sign-in-enabled?])]
profile-picture (multiaccounts/displayed-photo account)]
[:<> [:<>
[rn/view {:style style/enter-password-container} [rn/view {:style style/enter-password-container}
[rn/view [rn/view
@ -28,8 +27,8 @@
[quo/context-tag [quo/context-tag
{:type :default {:type :default
:blur? true :blur? true
:profile-picture profile-picture :profile-picture (profile.utils/photo profile)
:full-name display-name :full-name (profile.utils/displayed-name profile)
:customization-color customization-color :customization-color customization-color
:size 24}]] :size 24}]]
[password-input/view [password-input/view

View File

@ -66,11 +66,11 @@
(defn reply-from (defn reply-from
[{:keys [from contact-name current-public-key pin?]}] [{:keys [from contact-name current-public-key pin?]}]
(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])
photo-path (rf/sub [:chats/photo-path from])] photo-path (rf/sub [:chats/photo-path from])]
[rn/view {:style style/reply-from} [rn/view {:style style/reply-from}
[quo/user-avatar [quo/user-avatar
{:full-name display-name {:full-name primary-name
:profile-picture photo-path :profile-picture photo-path
:status-indicator? false :status-indicator? false
:size :xxxs :size :xxxs
@ -86,7 +86,7 @@
[{:keys [from content-type contentType parsed-text content deleted? deleted-for-me? [{:keys [from content-type contentType parsed-text content deleted? deleted-for-me?
album-images-count]} album-images-count]}
in-chat-input? pin? recording-audio?] 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]) current-public-key (rf/sub [:multiaccount/public-key])
content-type (or content-type contentType) content-type (or content-type contentType)
text (get-quoted-text-with-mentions (or parsed-text (:parsed-text content)))] text (get-quoted-text-with-mentions (or parsed-text (:parsed-text content)))]
@ -106,7 +106,7 @@
[reply-from [reply-from
{:pin? pin? {:pin? pin?
:from from :from from
:contact-name contact-name :contact-name primary-name
:current-public-key current-public-key}] :current-public-key current-public-key}]
(when (not-empty text) (when (not-empty text)
[quo/text [quo/text

View File

@ -12,11 +12,11 @@
(defn get-display-name (defn get-display-name
[{:keys [chat-id message]}] [{:keys [chat-id message]}]
(let [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])
no-ens-name (string/blank? (get-in message [:content :ens-name]))] no-ens-name (string/blank? (get-in message [:content :ens-name]))]
(if no-ens-name (if no-ens-name
(first (string/split name " ")) (first (string/split primary-name " "))
name))) primary-name)))
(defn requests-summary (defn requests-summary
[requests] [requests]

View File

@ -70,8 +70,7 @@
(defn top-view (defn top-view
[messages insets index animations derived landscape? screen-width] [messages insets index animations derived landscape? screen-width]
(let [{:keys [from timestamp]} (first messages) (let [{:keys [from timestamp]} (first messages)
display-name (first (rf/sub [:contacts/contact-two-names-by-identity [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from])
from]))
bg-color (if landscape? bg-color (if landscape?
colors/neutral-100-opa-70 colors/neutral-100-opa-70
colors/neutral-100-opa-0) colors/neutral-100-opa-0)
@ -102,7 +101,7 @@
[quo/text [quo/text
{:weight :semi-bold {:weight :semi-bold
:size :paragraph-1 :size :paragraph-1
:style {:color colors/white}} display-name] :style {:color colors/white}} primary-name]
[quo/text [quo/text
{:weight :medium {:weight :medium
:size :paragraph-2 :size :paragraph-2

View File

@ -6,15 +6,15 @@
(defn avatar (defn avatar
[{:keys [public-key size hide-ring?]}] [{:keys [public-key size hide-ring?]}]
(let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity public-key])) (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity public-key])
photo-path (rf/sub [:chats/photo-path public-key]) photo-path (rf/sub [:chats/photo-path public-key])
online? (rf/sub [:visibility-status-updates/online? public-key])] online? (rf/sub [:visibility-status-updates/online? public-key])]
[rn/view {:style {:padding-top 4}} [rn/view {:style {:padding-top 4}}
[rn/touchable-opacity [rn/touchable-opacity
{:active-opacity 1 {:active-opacity 1
:on-press #(rf/dispatch [:chat.ui/show-profile public-key])} :on-press #(rf/dispatch [:chat.ui/show-profile public-key])}
[quo/user-avatar [quo/user-avatar
{:full-name display-name {:full-name primary-name
:ring? (not hide-ring?) :ring? (not hide-ring?)
:profile-picture photo-path :profile-picture photo-path
:online? online? :online? online?

View File

@ -12,7 +12,7 @@
(defn view (defn view
[contact-id contact-request-state group-chat] [contact-id contact-request-state group-chat]
(let [customization-color (rf/sub [:profile/customization-color]) (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 [rn/view
[permission-context/view [permission-context/view
[quo/button [quo/button
@ -29,11 +29,11 @@
(or (not contact-request-state) (or (not contact-request-state)
(= contact-request-state (= contact-request-state
constants/contact-request-state-none)) 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 (= contact-request-state
constants/contact-request-state-received) constants/contact-request-state-received)
(str (first names) " sent you a contact request") (str primary-name " sent you a contact request")
(= contact-request-state (= contact-request-state
constants/contact-request-state-sent) constants/contact-request-state-sent)

View File

@ -36,9 +36,8 @@
(defn deleted-by-message (defn deleted-by-message
[{:keys [deleted-by timestamp-str from on-long-press animation-duration]}] [{:keys [deleted-by timestamp-str from on-long-press animation-duration]}]
(let [;; deleted message with nil deleted-by is deleted by (:from message) (let [;; deleted message with nil deleted-by is deleted by (:from message)
display-name (first (rf/sub [:contacts/contact-two-names-by-identity [primary-name _] (rf/sub [:contacts/contact-two-names-by-identity (or deleted-by from)])
(or deleted-by from)])) photo-path (rf/sub [:chats/photo-path (or deleted-by from)])]
photo-path (rf/sub [:chats/photo-path (or deleted-by from)])]
[quo/system-message [quo/system-message
{:type :deleted {:type :deleted
:animate-bg-color? animation-duration :animate-bg-color? animation-duration
@ -46,7 +45,7 @@
:on-long-press on-long-press :on-long-press on-long-press
:timestamp timestamp-str :timestamp timestamp-str
:child [user-xxx-deleted-this-message :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 (defn deleted-message
[{:keys [deleted? deleted-for-me? deleted-by pinned timestamp-str from [{:keys [deleted? deleted-for-me? deleted-by pinned timestamp-str from

View File

@ -11,10 +11,10 @@
(defn pinned-by-view (defn pinned-by-view
[pinned-by] [pinned-by]
(let [{:keys [public-key]} (rf/sub [:multiaccount/contact]) (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) author-name (if (= pinned-by public-key)
(i18n/label :t/You) (i18n/label :t/You)
(first contact-names))] primary-name)]
[rn/view [rn/view
{:style style/pin-indicator-container {:style style/pin-indicator-container
:accessibility-label :pinned-by} :accessibility-label :pinned-by}
@ -29,11 +29,11 @@
(defn pinned-message (defn pinned-message
[{:keys [from quoted-message timestamp-str]}] [{: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])] customization-color (rf/sub [:profile/customization-color])]
[quo/system-message [quo/system-message
{:type :pinned {:type :pinned
:pinned-by display-name :pinned-by primary-name
:customization-color customization-color :customization-color customization-color
:child [reply/quoted-message quoted-message false true] :child [reply/quoted-message quoted-message false true]
:timestamp timestamp-str}])) :timestamp timestamp-str}]))

View File

@ -72,7 +72,7 @@
(defn system-message-contact-request (defn system-message-contact-request
[{:keys [chat-id timestamp-str from]} type] [{: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]) contact (rf/sub [:contacts/contact-by-address chat-id])
photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id])) photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id]))
customization-color (rf/sub [:profile/customization-color]) customization-color (rf/sub [:profile/customization-color])
@ -80,7 +80,7 @@
[quo/system-message [quo/system-message
{:type type {:type type
:timestamp timestamp-str :timestamp timestamp-str
:display-name display-name :display-name primary-name
:customization-color customization-color :customization-color customization-color
:photo-path photo-path :photo-path photo-path
:incoming? (not= public-key from)}])) :incoming? (not= public-key from)}]))

View File

@ -15,8 +15,7 @@
(defn contact-list-item-fn (defn contact-list-item-fn
[{:keys [from compressed-key]}] [{:keys [from compressed-key]}]
(let [[primary-name secondary-name] (rf/sub [:contacts/contact-two-names-by-identity (let [[primary-name secondary-name] (rf/sub [:contacts/contact-two-names-by-identity from])
from])
{:keys [ens-verified added?]} (rf/sub [:contacts/contact-by-address from])] {:keys [ens-verified added?]} (rf/sub [:contacts/contact-by-address from])]
^{:key compressed-key} ^{:key compressed-key}
[contact-list-item/contact-list-item [contact-list-item/contact-list-item

View File

@ -2,7 +2,7 @@
(:require (:require
[camel-snake-kebab.core :as csk] [camel-snake-kebab.core :as csk]
[status-im.communities.core :as models.communities] [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] [taoensso.timbre :as log]
[utils.collection] [utils.collection]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -15,7 +15,7 @@
{:events [:chat.ui/cache-link-preview-data]} {:events [:chat.ui/cache-link-preview-data]}
[{{:profile/keys [profile]} :db :as cofx} site data] [{{:profile/keys [profile]} :db :as cofx} site data]
(let [link-previews-cache (get profile :link-previews-cache {})] (let [link-previews-cache (get profile :link-previews-cache {})]
(multiaccounts.update/optimistic (profile.settings.events/optimistic-profile-update
cofx cofx
:link-previews-cache :link-previews-cache
(assoc link-previews-cache site (utils.collection/map-keys csk/->kebab-case-keyword data))))) (assoc link-previews-cache site (utils.collection/map-keys csk/->kebab-case-keyword data)))))
@ -35,7 +35,7 @@
(rf/defn should-suggest-link-preview (rf/defn should-suggest-link-preview
{:events [:chat.ui/should-suggest-link-preview]} {:events [:chat.ui/should-suggest-link-preview]}
[{:keys [db] :as cofx} enabled?] [{:keys [db] :as cofx} enabled?]
(multiaccounts.update/multiaccount-update (profile.settings.events/profile-update
cofx cofx
:link-preview-request-enabled :link-preview-request-enabled
(boolean enabled?) (boolean enabled?)
@ -87,7 +87,7 @@
(rf/defn enable (rf/defn enable
{:events [:chat.ui/enable-link-previews]} {:events [:chat.ui/enable-link-previews]}
[{{:profile/keys [profile]} :db :as cofx} site enabled?] [{{:profile/keys [profile]} :db :as cofx} site enabled?]
(multiaccounts.update/multiaccount-update (profile.settings.events/profile-update
cofx cofx
:link-previews-enabled-sites :link-previews-enabled-sites
(if enabled? (if enabled?
@ -98,7 +98,7 @@
(rf/defn enable-all (rf/defn enable-all
{:events [:chat.ui/enable-all-link-previews]} {:events [:chat.ui/enable-all-link-previews]}
[cofx link-previews-whitelist enabled?] [cofx link-previews-whitelist enabled?]
(multiaccounts.update/multiaccount-update (profile.settings.events/profile-update
cofx cofx
:link-previews-enabled-sites :link-previews-enabled-sites
(if enabled? (if enabled?

View File

@ -129,3 +129,4 @@
:on-success on-success :on-success on-success
:js-response true :js-response true
:on-error #(log/error "failed to unblock contact" % contact-id)}]}) :on-error #(log/error "failed to unblock contact" % contact-id)}]})

View File

@ -2,7 +2,6 @@
(:require (:require
["react-native-image-crop-picker" :default image-picker] ["react-native-image-crop-picker" :default image-picker]
[quo.core :as quo] [quo.core :as quo]
[status-im.multiaccounts.core]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))

View File

@ -2,7 +2,7 @@
(:require (:require
[native-module.core :as native-module] [native-module.core :as native-module]
[re-frame.core :as re-frame] [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.contexts.profile.rpc :as profile.rpc]
[status-im2.navigation.events :as navigation] [status-im2.navigation.events :as navigation]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -46,7 +46,7 @@
(init-profiles-overview profiles key-uid) (init-profiles-overview profiles key-uid)
;;we check if biometric is available, and try to login with it, ;;we check if biometric is available, and try to login with it,
;;if succeed "node.login" signal will be triggered ;;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))) (navigation/init-root cofx :intro)))
(rf/defn update-setting-from-backup (rf/defn update-setting-from-backup

View File

@ -10,7 +10,6 @@
[status-im.data-store.visibility-status-updates :as visibility-status-updates-store] [status-im.data-store.visibility-status-updates :as visibility-status-updates-store]
[status-im.group-chats.core :as group-chats] [status-im.group-chats.core :as group-chats]
[status-im.mobile-sync-settings.core :as mobile-network] [status-im.mobile-sync-settings.core :as mobile-network]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.transport.core :as transport] [status-im.transport.core :as transport]
[status-im2.common.biometric.events :as biometric] [status-im2.common.biometric.events :as biometric]
[status-im2.common.keychain.events :as keychain] [status-im2.common.keychain.events :as keychain]
@ -20,6 +19,7 @@
[status-im2.contexts.contacts.events :as contacts] [status-im2.contexts.contacts.events :as contacts]
[status-im2.contexts.profile.config :as profile.config] [status-im2.contexts.profile.config :as profile.config]
[status-im2.contexts.profile.rpc :as profile.rpc] [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.push-notifications.events :as notifications]
[status-im2.contexts.shell.activity-center.events :as activity-center] [status-im2.contexts.shell.activity-center.events :as activity-center]
[status-im2.contexts.wallet.events :as wallet] [status-im2.contexts.wallet.events :as wallet]
@ -62,7 +62,7 @@
:else :else
(rf/merge (rf/merge
cofx cofx
(multiaccounts/switch-theme nil :shell-stack) (profile.settings.events/switch-theme nil :shell-stack)
(navigation/init-root :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 ;; 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] (let [{:networks/keys [current-network networks]
:as settings} :as settings}
(data-store.settings/rpc->settings 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 (rf/merge cofx
{:db (assoc db {:db (assoc db
:chats/loading? true :chats/loading? true
:networks/current-network current-network :networks/current-network current-network
:wallet/tokens-loading? true :wallet/tokens-loading? true
:networks/networks (merge networks config/default-networks-by-id) :networks/networks (merge networks config/default-networks-by-id)
:profile/profile (merge profile settings))} :profile/profile (merge profile-overview settings))}
(notifications/load-preferences) (notifications/load-preferences)
(data-store.chats/fetch-chats-preview (data-store.chats/fetch-chats-preview
{:on-success {:on-success
@ -122,8 +122,8 @@
(browser/initialize-browser) (browser/initialize-browser)
(mobile-network/on-network-status-change) (mobile-network/on-network-status-change)
(group-chats/get-group-chat-invitations) (group-chats/get-group-chat-invitations)
(multiaccounts/get-profile-picture) (profile.settings.events/get-profile-picture)
(multiaccounts/switch-preview-privacy-mode-flag) (profile.settings.events/change-preview-privacy)
(link-preview/request-link-preview-whitelist) (link-preview/request-link-preview-whitelist)
(visibility-status-updates-store/fetch-visibility-status-updates-rpc) (visibility-status-updates-store/fetch-visibility-status-updates-rpc)
(switcher-cards-store/fetch-switcher-cards-rpc)))) (switcher-cards-store/fetch-switcher-cards-rpc))))

View File

@ -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]))))))

View File

@ -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))

View File

@ -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)))

View File

@ -3,8 +3,8 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.multiaccounts.core :as multiaccounts]
[status-im2.common.resources :as resources] [status-im2.common.resources :as resources]
[status-im2.contexts.profile.utils :as profile.utils]
[status-im2.contexts.quo-preview.preview :as preview] [status-im2.contexts.quo-preview.preview :as preview]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -38,7 +38,7 @@
(defn view (defn view
[] []
(let [account (rf/sub [:profile/multiaccount]) (let [profile (rf/sub [:profile/profile-with-image])
state (reagent/atom state (reagent/atom
{:blur? false {:blur? false
:title "Title" :title "Title"
@ -55,7 +55,7 @@
:icon-avatar :i/placeholder :icon-avatar :i/placeholder
:on-button-press #(js/alert "on press") :on-button-press #(js/alert "on press")
:on-button-long-press #(js/alert "on long press") :on-button-long-press #(js/alert "on long press")
:profile-picture (multiaccounts/displayed-photo account)})] :profile-picture (profile.utils/photo profile)})]
(fn [] (fn []
[preview/preview-container [preview/preview-container
{:state state {:state state

View File

@ -4,19 +4,19 @@
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [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] [status-im2.contexts.shell.activity-center.notification.common.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn user-avatar-tag (defn user-avatar-tag
[user-id] [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 [quo/context-tag
{:blur? true {:blur? true
:size 24 :size 24
:full-name primary-name :full-name (profile.utils/displayed-name profile)
:profile-picture (multiaccounts/displayed-photo contact)}])) :profile-picture (profile.utils/photo profile)}]))
(defn- render-swipe-action (defn- render-swipe-action
[{:keys [active-swipeable [{:keys [active-swipeable

View File

@ -8,9 +8,9 @@
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.list-selection :as list-selection] [status-im.ui.components.list-selection :as list-selection]
[status-im2.common.qr-codes.view :as qr-codes] [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] [status-im2.contexts.shell.share.style :as style]
[utils.address :as address] [utils.address :as address]
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -46,10 +46,11 @@
(defn profile-tab (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]) :as profile} (rf/sub [:profile/profile])
profile-url (str image-server/status-profile-base-url compressed-key) 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 abbreviated-url (address/get-abbreviated-profile-url
image-server/status-profile-base-url-without-https image-server/status-profile-base-url-without-https
compressed-key) compressed-key)
@ -68,8 +69,8 @@
:on-text-long-press #(rf/dispatch [:share/copy-text-and-show-toast :on-text-long-press #(rf/dispatch [:share/copy-text-and-show-toast
{:text-to-copy profile-url {:text-to-copy profile-url
:post-copy-message (i18n/label :t/link-to-profile-copied)}]) :post-copy-message (i18n/label :t/link-to-profile-copied)}])
:profile-picture profile-photo-uri :profile-picture (:uri (profile.utils/photo profile))
:full-name display-name :full-name (profile.utils/displayed-name profile)
:customization-color customization-color}]] :customization-color customization-color}]]
[rn/view {:style style/emoji-hash-container} [rn/view {:style style/emoji-hash-container}

View File

@ -25,7 +25,7 @@
(defn view (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) valid-for-ms (reagent/atom code-valid-for-ms)
code (reagent/atom nil) code (reagent/atom nil)
delay-ms (reagent/atom nil) delay-ms (reagent/atom nil)

View File

@ -51,7 +51,7 @@
derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts)) derivation-path (reagent/atom (utils/get-derivation-path number-of-accounts))
{:keys [public-key]} (rf/sub [:profile/profile]) {:keys [public-key]} (rf/sub [:profile/profile])
on-change-text #(reset! account-name %) 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)] {window-width :width} (rn/get-window)]
(fn [{:keys [theme]}] (fn [{:keys [theme]}]
[rn/view [rn/view
@ -108,7 +108,7 @@
[quo/category [quo/category
{:list-type :settings {:list-type :settings
:label (i18n/label :t/origin) :label (i18n/label :t/origin)
:data (get-keypair-data display-name @derivation-path)}] :data (get-keypair-data primary-name @derivation-path)}]
[standard-auth/view [standard-auth/view
{:size :size-48 {:size :size-48
:track-text (i18n/label :t/slide-to-create-account) :track-text (i18n/label :t/slide-to-create-account)

View File

@ -16,6 +16,7 @@
status-im2.contexts.onboarding.common.overlay.events status-im2.contexts.onboarding.common.overlay.events
status-im2.contexts.onboarding.events status-im2.contexts.onboarding.events
status-im2.contexts.profile.events status-im2.contexts.profile.events
status-im2.contexts.profile.settings.events
status-im2.contexts.shell.share.events status-im2.contexts.shell.share.events
status-im2.contexts.syncing.events status-im2.contexts.syncing.events
status-im2.contexts.wallet.events status-im2.contexts.wallet.events

View File

@ -78,7 +78,7 @@
(fn [root-id] (fn [root-id]
(let [root (get (roots/roots) root-id)] (let [root (get (roots/roots) root-id)]
(dismiss-all-modals) (dismiss-all-modals)
(re-frame/dispatch [:multiaccounts.ui/switch-theme (re-frame/dispatch [:profile.settings/switch-theme
(get roots/themes root-id) (get roots/themes root-id)
root-id]) root-id])
(reset! state/root-id (or (get-in root [:root :stack :id]) root-id)) (reset! state/root-id (or (get-in root [:root :stack :id]) root-id))

View File

@ -167,7 +167,7 @@
{:set-root (if keycard-account? :multiaccounts-keycard :multiaccounts)})) {:set-root (if keycard-account? :multiaccounts-keycard :multiaccounts)}))
(rf/defn dismiss-all-overlays (rf/defn dismiss-all-overlays
{:events [:dissmiss-all-overlays]} {:events [:dismiss-all-overlays]}
[{:keys [db]}] [{:keys [db]}]
{:dispatch-n [[:hide-popover] {:dispatch-n [[:hide-popover]
[:hide-visibility-status-popover] [:hide-visibility-status-popover]

View File

@ -3,12 +3,12 @@
[clojure.string :as string] [clojure.string :as string]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.communities.core :as communities] [status-im.communities.core :as communities]
[status-im.contact.core :as contact]
[status-im.group-chats.core :as group-chat] [status-im.group-chats.core :as group-chat]
[status-im.group-chats.db :as group-chats.db] [status-im.group-chats.db :as group-chats.db]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.composer.constants :as composer.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)) (def memo-chats-stack-items (atom nil))
@ -313,10 +313,10 @@
(re-frame/reg-sub (re-frame/reg-sub
:chats/photo-path :chats/photo-path
:<- [:contacts/contacts] :<- [:contacts/contacts]
:<- [:profile/multiaccount] :<- [:profile/profile-with-image]
(fn [[contacts {:keys [public-key] :as multiaccount}] [_ id]] (fn [[contacts {:keys [public-key] :as multiaccount}] [_ id]]
(let [contact (or (when (= id public-key) multiaccount) (get contacts id))] (let [contact (or (when (= id public-key) multiaccount) (get contacts id))]
(contact/displayed-photo contact)))) (profile.utils/photo contact))))
(re-frame/reg-sub (re-frame/reg-sub
:chats/unread-messages-number :chats/unread-messages-number

View File

@ -2,7 +2,6 @@
(:require (:require
[clojure.string :as string] [clojure.string :as string]
[re-frame.core :as re-frame] [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-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
@ -52,20 +51,16 @@
(re-frame/reg-sub (re-frame/reg-sub
:communities/sorted-community-members :communities/sorted-community-members
(fn [[_ community-id]] (fn [[_ community-id]]
(let [contacts (re-frame/subscribe [:contacts/contacts]) (let [profile (re-frame/subscribe [:profile/profile])
multiaccount (re-frame/subscribe [:profile/profile]) members (re-frame/subscribe [:communities/community-members community-id])]
members (re-frame/subscribe [:communities/community-members community-id])] [profile members]))
[contacts multiaccount members])) (fn [[profile members] _]
(fn [[contacts multiaccount members] _]
(let [names (reduce (fn [acc contact-identity] (let [names (reduce (fn [acc contact-identity]
(let [me? (= (:public-key multiaccount) contact-identity) (assoc acc
contact (when-not me? contact-identity
(multiaccounts/contact-by-identity contacts contact-identity)) (when (= (:public-key profile) contact-identity)
name (first (multiaccounts/contact-two-names-by-identity (:primary-name profile)
contact contact-identity)))
multiaccount
contact-identity))]
(assoc acc contact-identity name)))
{} {}
(keys members))] (keys members))]
(->> members (->> members

View File

@ -4,10 +4,9 @@
[quo.theme :as theme] [quo.theme :as theme]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.contact.db :as contact.db] [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.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im.utils.gfycat.core :as gfycat]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.profile.utils :as profile.utils]
[utils.address :as address] [utils.address :as address]
[utils.collection] [utils.collection]
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -213,7 +212,7 @@
:contacts/contact-by-identity :contacts/contact-by-identity
:<- [:contacts/contacts] :<- [:contacts/contacts]
(fn [contacts [_ contact-identity]] (fn [contacts [_ contact-identity]]
(multiaccounts/contact-by-identity contacts contact-identity))) (get contacts contact-identity {:public-key contact-identity})))
(re-frame/reg-sub (re-frame/reg-sub
:contacts/contact-added? :contacts/contact-added?
@ -234,40 +233,17 @@
(fn [[_ contact-identity] _] (fn [[_ contact-identity] _]
[(re-frame/subscribe [:contacts/contact-by-identity contact-identity]) [(re-frame/subscribe [:contacts/contact-by-identity contact-identity])
(re-frame/subscribe [:profile/profile])]) (re-frame/subscribe [:profile/profile])])
(fn [[contact current-multiaccount] [_ contact-identity]] (fn [[{:keys [primary-name] :as contact}
(multiaccounts/contact-two-names-by-identity contact {:keys [public-key preferred-name display-name]}]
current-multiaccount [_ contact-identity]]
contact-identity))) [(if (= public-key contact-identity)
(cond
(re-frame/reg-sub (not (string/blank? preferred-name)) preferred-name
:contacts/contact-name-by-identity (not (string/blank? display-name)) display-name
(fn [[_ contact-identity] _] (not (string/blank? primary-name)) primary-name
[(re-frame/subscribe [:contacts/contact-two-names-by-identity contact-identity])]) :else public-key)
(fn [[names] _] (profile.utils/displayed-name contact))
(first names))) (:secondary-name contact)]))
(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))}))))))
(re-frame/reg-sub (re-frame/reg-sub
:contacts/all-contacts-not-in-current-chat :contacts/all-contacts-not-in-current-chat

View File

@ -278,8 +278,8 @@
(re-frame/reg-sub (re-frame/reg-sub
:messages/resolve-mention :messages/resolve-mention
(fn [[_ mention] _] (fn [[_ mention] _]
[(re-frame/subscribe [:contacts/contact-name-by-identity mention])]) [(re-frame/subscribe [:contacts/contact-two-names-by-identity mention])])
(fn [[contact-name] [_ mention]] (fn [[contact-names] [_ mention]]
(if (= mention constants/everyone-mention-id) (if (= mention constants/everyone-mention-id)
(i18n/label :t/everyone-mention) (i18n/label :t/everyone-mention)
contact-name))) (first contact-names))))

View File

@ -39,11 +39,11 @@
:<- [:profile/profiles-overview] :<- [:profile/profiles-overview]
:<- [:mediaserver/port] :<- [:mediaserver/port]
:<- [:initials-avatar-font-file] :<- [:initials-avatar-font-file]
(fn [[multiaccounts port font-file] [_ target-key-uid]] (fn [[profiles port font-file] [_ target-key-uid]]
(let [{:keys [images ens-name?] :as multiaccount} (get multiaccounts target-key-uid) (let [{:keys [images ens-name?] :as profile} (get profiles target-key-uid)
image-name (-> images first :type) image-name (-> images first :type)
override-ring? (when ens-name? false)] override-ring? (when ens-name? false)]
(when multiaccount (when profile
{:fn {:fn
(if image-name (if image-name
(image-server/get-account-image-uri-fn {:port port (image-server/get-account-image-uri-fn {:port port
@ -249,8 +249,8 @@
(pos? (count (get multiaccount :images))))) (pos? (count (get multiaccount :images)))))
(defn- replace-multiaccount-image-uri (defn- replace-multiaccount-image-uri
[multiaccount ens-names port font-file avatar-opts] [profile ens-names port font-file avatar-opts]
(let [{:keys [key-uid ens-name? images]} multiaccount (let [{:keys [key-uid ens-name? images]} profile
ens-name? (or ens-name? (seq ens-names)) ens-name? (or ens-name? (seq ens-names))
theme (theme/get-theme) theme (theme/get-theme)
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false)) avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
@ -271,16 +271,16 @@
:theme theme :theme theme
:font-file font-file} :font-file font-file}
avatar-opts))}])] avatar-opts))}])]
(assoc multiaccount :images new-images))) (assoc profile :images new-images)))
(re-frame/reg-sub (re-frame/reg-sub
:profile/multiaccount :profile/profile-with-image
:<- [:profile/profile] :<- [:profile/profile]
:<- [:ens/names] :<- [:ens/names]
:<- [:mediaserver/port] :<- [:mediaserver/port]
:<- [:initials-avatar-font-file] :<- [:initials-avatar-font-file]
(fn [[multiaccount ens-names port font-file] [_ avatar-opts]] (fn [[profile ens-names port font-file] [_ avatar-opts]]
(replace-multiaccount-image-uri multiaccount ens-names port font-file avatar-opts))) (replace-multiaccount-image-uri profile ens-names port font-file avatar-opts)))
(re-frame/reg-sub (re-frame/reg-sub
:profile/login-profile :profile/login-profile

View File

@ -1,7 +1,6 @@
(ns status-im2.subs.shell (ns status-im2.subs.shell
(:require (:require
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im.multiaccounts.core :as multiaccounts]
[status-im2.common.resources :as resources] [status-im2.common.resources :as resources]
[status-im2.config :as config] [status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
@ -186,15 +185,12 @@
(re-frame/subscribe [:contacts/contacts]) (re-frame/subscribe [:contacts/contacts])
(re-frame/subscribe [:profile/profile]) (re-frame/subscribe [:profile/profile])
(re-frame/subscribe [:profile/customization-color])]) (re-frame/subscribe [:profile/customization-color])])
(fn [[chat communities contacts current-multiaccount profile-customization-color] [_ id]] (fn [[chat communities contacts current-profile profile-customization-color] [_ id]]
(let [from (get-in chat [:last-message :from]) (let [from (get-in chat [:last-message :from])
contact (when from (multiaccounts/contact-by-identity contacts from)) contact (if from
primary-name (when from (get contacts from {:public-key from})
(first (multiaccounts/contact-two-names-by-identity current-profile)]
contact (private-group-chat-card chat id communities (:primary-name contact) profile-customization-color))))
current-multiaccount
from)))]
(private-group-chat-card chat id communities primary-name profile-customization-color))))
(re-frame/reg-sub (re-frame/reg-sub
:shell/community-card :shell/community-card