Fix missing avatar and name in members of the community channels and group chats (#20619)
This commit is contained in:
parent
54e4b597ed
commit
23c25d7715
|
@ -92,6 +92,11 @@ public class EncryptionUtils extends ReactContextBaseJavaModule {
|
||||||
return Statusgo.hexToUtf8(str);
|
return Statusgo.hexToUtf8(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||||
|
public String serializeLegacyKey(final String publicKey) {
|
||||||
|
return Statusgo.serializeLegacyKey(publicKey);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void setBlankPreviewFlag(final Boolean blankPreview) {
|
public void setBlankPreviewFlag(final Boolean blankPreview) {
|
||||||
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.reactContext);
|
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.reactContext);
|
||||||
|
|
|
@ -94,6 +94,10 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hexToUtf8:(NSString *)str) {
|
||||||
return StatusgoHexToUtf8(str);
|
return StatusgoHexToUtf8(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(serializeLegacyKey:(NSString *)str) {
|
||||||
|
return StatusgoSerializeLegacyKey(str);
|
||||||
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(setBlankPreviewFlag:(BOOL *)newValue)
|
RCT_EXPORT_METHOD(setBlankPreviewFlag:(BOOL *)newValue)
|
||||||
{
|
{
|
||||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
|
@ -672,6 +672,38 @@ void _Sha3(const FunctionCallbackInfo<Value>& args) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _SerializeLegacyKey(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 SerializeLegacyKey")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the argument types
|
||||||
|
|
||||||
|
if (!args[0]->IsString()) {
|
||||||
|
isolate->ThrowException(Exception::TypeError(
|
||||||
|
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'str'")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
|
||||||
|
char *arg0 = *arg0Obj;
|
||||||
|
|
||||||
|
// Call exported Go function, which returns a C string
|
||||||
|
char *c = SerializeLegacyKey(arg0);
|
||||||
|
|
||||||
|
Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
|
||||||
|
args.GetReturnValue().Set(ret);
|
||||||
|
delete c;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void _ToChecksumAddress(const FunctionCallbackInfo<Value>& args) {
|
void _ToChecksumAddress(const FunctionCallbackInfo<Value>& args) {
|
||||||
Isolate* isolate = args.GetIsolate();
|
Isolate* isolate = args.GetIsolate();
|
||||||
Local<Context> context = isolate->GetCurrentContext();
|
Local<Context> context = isolate->GetCurrentContext();
|
||||||
|
@ -1976,6 +2008,7 @@ void init(Local<Object> exports) {
|
||||||
NODE_SET_METHOD(exports, "checkAddressChecksum", _CheckAddressChecksum);
|
NODE_SET_METHOD(exports, "checkAddressChecksum", _CheckAddressChecksum);
|
||||||
NODE_SET_METHOD(exports, "isAddress", _IsAddress);
|
NODE_SET_METHOD(exports, "isAddress", _IsAddress);
|
||||||
NODE_SET_METHOD(exports, "sha3", _Sha3);
|
NODE_SET_METHOD(exports, "sha3", _Sha3);
|
||||||
|
NODE_SET_METHOD(exports, "serializeLegacyKey", _SerializeLegacyKey);
|
||||||
NODE_SET_METHOD(exports, "toChecksumAddress", _ToChecksumAddress);
|
NODE_SET_METHOD(exports, "toChecksumAddress", _ToChecksumAddress);
|
||||||
NODE_SET_METHOD(exports, "logout", _Logout);
|
NODE_SET_METHOD(exports, "logout", _Logout);
|
||||||
NODE_SET_METHOD(exports, "hashMessage", _HashMessage);
|
NODE_SET_METHOD(exports, "hashMessage", _HashMessage);
|
||||||
|
|
|
@ -333,6 +333,11 @@
|
||||||
:key input-key})
|
:key input-key})
|
||||||
(.deserializeAndCompressKey ^js (encryption) input-key callback))
|
(.deserializeAndCompressKey ^js (encryption) input-key callback))
|
||||||
|
|
||||||
|
(defn serialize-legacy-key
|
||||||
|
"Compresses an old format public key (0x04...) to the new one zQ..."
|
||||||
|
[public-key]
|
||||||
|
(.serializeLegacyKey ^js (encryption) public-key))
|
||||||
|
|
||||||
(defn compressed-key->public-key
|
(defn compressed-key->public-key
|
||||||
"Provides compressed key to status-go and gets back the uncompressed public key via deserialization"
|
"Provides compressed key to status-go and gets back the uncompressed public key via deserialization"
|
||||||
[public-key deserialization-key callback]
|
[public-key deserialization-key callback]
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.chat.events :as chat.events]
|
[status-im.contexts.chat.events :as chat.events]
|
||||||
[status-im.contexts.profile.utils :as profile.utils]))
|
[status-im.contexts.profile.utils :as profile.utils]
|
||||||
|
[status-im.subs.contact.utils :as contact.utils]))
|
||||||
|
|
||||||
(def memo-chats-stack-items (atom nil))
|
(def memo-chats-stack-items (atom nil))
|
||||||
|
|
||||||
|
@ -259,8 +260,19 @@
|
||||||
:chats/photo-path
|
:chats/photo-path
|
||||||
:<- [:contacts/contacts]
|
:<- [:contacts/contacts]
|
||||||
:<- [:profile/profile-with-image]
|
:<- [:profile/profile-with-image]
|
||||||
(fn [[contacts {:keys [public-key] :as multiaccount}] [_ id]]
|
:<- [:mediaserver/port]
|
||||||
(let [contact (or (when (= id public-key) multiaccount) (get contacts id))]
|
:<- [:initials-avatar-font-file]
|
||||||
|
:<- [:theme]
|
||||||
|
(fn [[contacts {:keys [public-key] :as multiaccount} port font-file theme] [_ id]]
|
||||||
|
(let [contact (or (when (= id public-key) multiaccount)
|
||||||
|
(get contacts id)
|
||||||
|
(contact.utils/replace-contact-image-uri
|
||||||
|
{:contact {:public-key id
|
||||||
|
:customization-color constants/profile-default-color}
|
||||||
|
:port port
|
||||||
|
:public-key id
|
||||||
|
:font-file font-file
|
||||||
|
:theme theme}))]
|
||||||
(profile.utils/photo contact))))
|
(profile.utils/photo contact))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||||
[quo.theme]
|
[quo.theme]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.common.pixel-ratio :as pixel-ratio]
|
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.profile.utils :as profile.utils]
|
[status-im.contexts.profile.utils :as profile.utils]
|
||||||
[status-im.subs.chat.utils :as chat.utils]
|
[status-im.subs.chat.utils :as chat.utils]
|
||||||
|
[status-im.subs.contact.utils :as contact.utils]
|
||||||
[utils.address :as address]
|
[utils.address :as address]
|
||||||
[utils.collection]
|
[utils.collection]
|
||||||
[utils.i18n :as i18n]))
|
[utils.i18n :as i18n]))
|
||||||
|
@ -37,50 +37,6 @@
|
||||||
(fn [multiaccount]
|
(fn [multiaccount]
|
||||||
(get multiaccount :profile-pictures-visibility)))
|
(get multiaccount :profile-pictures-visibility)))
|
||||||
|
|
||||||
(defn- replace-contact-image-uri
|
|
||||||
[contact port public-key font-file theme]
|
|
||||||
(let [{:keys [images ens-name customization-color]} contact
|
|
||||||
images
|
|
||||||
(reduce (fn [acc image]
|
|
||||||
(let [image-name (:type image)
|
|
||||||
clock (:clock image)
|
|
||||||
options {:port port
|
|
||||||
:ratio pixel-ratio/ratio
|
|
||||||
:public-key
|
|
||||||
public-key
|
|
||||||
:image-name
|
|
||||||
image-name
|
|
||||||
; We pass the clock so that we reload the
|
|
||||||
; image if the image is updated
|
|
||||||
:clock
|
|
||||||
clock
|
|
||||||
:theme
|
|
||||||
theme
|
|
||||||
:override-ring?
|
|
||||||
(when ens-name false)}]
|
|
||||||
(assoc-in acc
|
|
||||||
[(keyword image-name) :config]
|
|
||||||
{:type :contact
|
|
||||||
:options options})))
|
|
||||||
images
|
|
||||||
(vals images))
|
|
||||||
|
|
||||||
images (if (seq images)
|
|
||||||
images
|
|
||||||
{:thumbnail
|
|
||||||
{:config {:type :initials
|
|
||||||
:options {:port port
|
|
||||||
:ratio pixel-ratio/ratio
|
|
||||||
:public-key public-key
|
|
||||||
:override-ring? (when ens-name false)
|
|
||||||
:uppercase-ratio (:uppercase-ratio
|
|
||||||
constants/initials-avatar-font-conf)
|
|
||||||
:customization-color customization-color
|
|
||||||
:theme theme
|
|
||||||
:font-file font-file}}}})]
|
|
||||||
|
|
||||||
(assoc contact :images images)))
|
|
||||||
|
|
||||||
(defn- enrich-contact
|
(defn- enrich-contact
|
||||||
([contact] (enrich-contact contact nil nil))
|
([contact] (enrich-contact contact nil nil))
|
||||||
([{:keys [public-key] :as contact} setting own-public-key]
|
([{:keys [public-key] :as contact} setting own-public-key]
|
||||||
|
@ -103,7 +59,12 @@
|
||||||
(defn- reduce-contacts-image-uri
|
(defn- reduce-contacts-image-uri
|
||||||
[contacts port font-file theme]
|
[contacts port font-file theme]
|
||||||
(reduce-kv (fn [acc public-key contact]
|
(reduce-kv (fn [acc public-key contact]
|
||||||
(let [contact (replace-contact-image-uri contact port public-key font-file theme)]
|
(let [contact (contact.utils/replace-contact-image-uri
|
||||||
|
{:contact contact
|
||||||
|
:port port
|
||||||
|
:public-key public-key
|
||||||
|
:font-file font-file
|
||||||
|
:theme theme})]
|
||||||
(assoc acc public-key contact)))
|
(assoc acc public-key contact)))
|
||||||
{}
|
{}
|
||||||
contacts))
|
contacts))
|
||||||
|
@ -230,7 +191,12 @@
|
||||||
[_ contact-identity ens-name port font-file theme]
|
[_ contact-identity ens-name port font-file theme]
|
||||||
(let [contact (enrich-contact
|
(let [contact (enrich-contact
|
||||||
(public-key-and-ens-name->new-contact contact-identity ens-name))]
|
(public-key-and-ens-name->new-contact contact-identity ens-name))]
|
||||||
(replace-contact-image-uri contact port contact-identity font-file theme)))
|
(contact.utils/replace-contact-image-uri
|
||||||
|
{:contact contact
|
||||||
|
:port port
|
||||||
|
:public-key contact-identity
|
||||||
|
:font-file font-file
|
||||||
|
:theme theme})))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:contacts/current-contact
|
:contacts/current-contact
|
||||||
|
@ -250,7 +216,10 @@
|
||||||
:contacts/contact-by-identity
|
:contacts/contact-by-identity
|
||||||
:<- [:contacts/contacts]
|
:<- [:contacts/contacts]
|
||||||
(fn [contacts [_ contact-identity]]
|
(fn [contacts [_ contact-identity]]
|
||||||
(get contacts contact-identity {:public-key contact-identity})))
|
(get
|
||||||
|
contacts
|
||||||
|
contact-identity
|
||||||
|
(contact.utils/build-contact-from-public-key contact-identity))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:contacts/contact-two-names-by-identity
|
:contacts/contact-two-names-by-identity
|
||||||
|
@ -288,7 +257,7 @@
|
||||||
(assoc public-key current-contact))]
|
(assoc public-key current-contact))]
|
||||||
(->> members
|
(->> members
|
||||||
(map #(or (get all-contacts %)
|
(map #(or (get all-contacts %)
|
||||||
{:public-key %}))
|
(contact.utils/build-contact-from-public-key %)))
|
||||||
(sort-by (comp string/lower-case
|
(sort-by (comp string/lower-case
|
||||||
(fn [{:keys [primary-name name alias public-key]}]
|
(fn [{:keys [primary-name name alias public-key]}]
|
||||||
(or primary-name
|
(or primary-name
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
(ns status-im.subs.contact.utils
|
||||||
|
(:require
|
||||||
|
[native-module.core :as native-module]
|
||||||
|
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||||
|
[status-im.constants :as constants]
|
||||||
|
[utils.address :as address]))
|
||||||
|
|
||||||
|
(defn replace-contact-image-uri
|
||||||
|
[{:keys [contact port public-key font-file theme]}]
|
||||||
|
(let [{:keys [images ens-name customization-color]} contact
|
||||||
|
images
|
||||||
|
(reduce (fn [acc image]
|
||||||
|
(let [image-name (:type image)
|
||||||
|
clock (:clock image)
|
||||||
|
options {:port port
|
||||||
|
:ratio pixel-ratio/ratio
|
||||||
|
:public-key public-key
|
||||||
|
:image-name image-name
|
||||||
|
; We pass the clock so that we reload the
|
||||||
|
; image if the image is updated
|
||||||
|
:clock clock
|
||||||
|
:theme theme
|
||||||
|
:override-ring? (when ens-name false)}]
|
||||||
|
(assoc-in acc
|
||||||
|
[(keyword image-name) :config]
|
||||||
|
{:type :contact
|
||||||
|
:options options})))
|
||||||
|
images
|
||||||
|
(vals images))
|
||||||
|
|
||||||
|
images (if (seq images)
|
||||||
|
images
|
||||||
|
{:thumbnail
|
||||||
|
{:config {:type :initials
|
||||||
|
:options {:port port
|
||||||
|
:ratio pixel-ratio/ratio
|
||||||
|
:public-key public-key
|
||||||
|
:override-ring? (when ens-name false)
|
||||||
|
:uppercase-ratio (:uppercase-ratio
|
||||||
|
constants/initials-avatar-font-conf)
|
||||||
|
:customization-color customization-color
|
||||||
|
:theme theme
|
||||||
|
:font-file font-file}}}})]
|
||||||
|
|
||||||
|
(assoc contact :images images)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn build-contact-from-public-key
|
||||||
|
[public-key]
|
||||||
|
(when public-key
|
||||||
|
(let [compressed-key (native-module/serialize-legacy-key public-key)]
|
||||||
|
{:public-key public-key
|
||||||
|
:compressed-key compressed-key
|
||||||
|
:primary-name (address/get-shortened-compressed-key (or compressed-key public-key))})))
|
|
@ -40,6 +40,8 @@
|
||||||
(clj->js
|
(clj->js
|
||||||
{:sha3
|
{:sha3
|
||||||
(fn [s] (.sha3 native-status s))
|
(fn [s] (.sha3 native-status s))
|
||||||
|
:serializeLegacyKey
|
||||||
|
(fn [s] (.serializeLegacyKey native-status s))
|
||||||
:setBlankPreviewFlag
|
:setBlankPreviewFlag
|
||||||
identity
|
identity
|
||||||
:encodeTransfer
|
:encodeTransfer
|
||||||
|
|
Loading…
Reference in New Issue