mirror of
https://github.com/status-im/status-react.git
synced 2025-02-16 21:07:21 +00:00
fetch emoji hash for profile (#14987)
* add emoji-hash to app-db post login
This commit is contained in:
parent
c4264462b1
commit
d1514ec52d
@ -1139,6 +1139,11 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
executeRunnableStatusGoMethod(() -> Statusgo.generateAlias(seed), callback);
|
executeRunnableStatusGoMethod(() -> Statusgo.generateAlias(seed), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void emojiHash(final String publicKey, final Callback callback) throws JSONException {
|
||||||
|
executeRunnableStatusGoMethod(() -> Statusgo.emojiHash(publicKey), callback);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactMethod(isBlockingSynchronousMethod = true)
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||||
public String identicon(final String seed) {
|
public String identicon(final String seed) {
|
||||||
return Statusgo.identicon(seed);
|
return Statusgo.identicon(seed);
|
||||||
|
@ -865,6 +865,12 @@ RCT_EXPORT_METHOD(generateAliasAsync:(NSString *)publicKey
|
|||||||
callback(@[result]);
|
callback(@[result]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(emojiHash:(NSString *)publicKey
|
||||||
|
callback:(RCTResponseSenderBlock)callback) {
|
||||||
|
NSString *result = StatusgoEmojiHash(publicKey);
|
||||||
|
callback(@[result]);
|
||||||
|
}
|
||||||
|
|
||||||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) {
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) {
|
||||||
return StatusgoIdenticon(publicKey);
|
return StatusgoIdenticon(publicKey);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@
|
|||||||
[status-im2.navigation.events :as navigation]
|
[status-im2.navigation.events :as navigation]
|
||||||
[status-im2.common.log :as logging]
|
[status-im2.common.log :as logging]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.security.core :as security]))
|
[utils.security.core :as security]
|
||||||
|
[status-im2.contexts.emoji-hash.events :as emoji-hash]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
::initialize-communities-enabled
|
::initialize-communities-enabled
|
||||||
@ -473,6 +474,7 @@
|
|||||||
(get-group-chat-invitations)
|
(get-group-chat-invitations)
|
||||||
(multiaccounts/get-profile-picture)
|
(multiaccounts/get-profile-picture)
|
||||||
(multiaccounts/switch-preview-privacy-mode-flag)
|
(multiaccounts/switch-preview-privacy-mode-flag)
|
||||||
|
(emoji-hash/fetch-for-current-public-key)
|
||||||
(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))))
|
||||||
|
@ -481,6 +481,12 @@
|
|||||||
(when (validators/valid-public-key? public-key)
|
(when (validators/valid-public-key? public-key)
|
||||||
(.generateAliasAsync ^js (status) public-key callback)))
|
(.generateAliasAsync ^js (status) public-key callback)))
|
||||||
|
|
||||||
|
(defn public-key->emoji-hash
|
||||||
|
"Generate an emoji hash from the multiaccount public key"
|
||||||
|
[public-key callback]
|
||||||
|
(when (validators/valid-public-key? public-key)
|
||||||
|
(.emojiHash ^js (status) public-key callback)))
|
||||||
|
|
||||||
(defn identicon
|
(defn identicon
|
||||||
"Generate a icon based on a string, synchronously"
|
"Generate a icon based on a string, synchronously"
|
||||||
[seed]
|
[seed]
|
||||||
|
19
src/status_im2/contexts/emoji_hash/events.cljs
Normal file
19
src/status_im2/contexts/emoji_hash/events.cljs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
(ns status-im2.contexts.emoji-hash.events
|
||||||
|
(:require [utils.re-frame :as rf]
|
||||||
|
[status-im.native-module.core :as native-module]
|
||||||
|
[utils.transforms :as transform]))
|
||||||
|
|
||||||
|
(defn fetch-for-current-public-key
|
||||||
|
[]
|
||||||
|
(let [public-key (rf/sub [:multiaccount/public-key])]
|
||||||
|
(native-module/public-key->emoji-hash
|
||||||
|
public-key
|
||||||
|
(fn [response]
|
||||||
|
(let [response-clj (transform/json->clj response)
|
||||||
|
emoji-hash (get response-clj :result)]
|
||||||
|
(rf/dispatch [:emoji-hash/add-to-multiaccount emoji-hash]))))))
|
||||||
|
|
||||||
|
(rf/defn add-emoji-hash-to-multiaccount
|
||||||
|
{:events [:emoji-hash/add-to-multiaccount]}
|
||||||
|
[{:keys [db]} emoji-hash]
|
||||||
|
{:db (assoc db :multiaccount/emoji-hash emoji-hash)})
|
Loading…
x
Reference in New Issue
Block a user