From 5cea66647e9cf9305938db02e3ece8195dc49c39 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Wed, 15 Feb 2023 23:27:34 +0530 Subject: [PATCH] fix deep links to user profiles don't do anything on tap (#15089) --- src/status_im/router/core.cljs | 22 +++++++++++++++---- src/status_im/utils/universal_links/core.cljs | 6 +---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/status_im/router/core.cljs b/src/status_im/router/core.cljs index 4f134b190a..b60b847abb 100644 --- a/src/status_im/router/core.cljs +++ b/src/status_im/router/core.cljs @@ -8,6 +8,8 @@ [status-im.ethereum.core :as ethereum] [status-im.ethereum.eip681 :as eip681] [status-im.ethereum.ens :as ens] + [status-im.utils.types :as types] + [status-im.native-module.core :as status] [status-im.ethereum.stateofus :as stateofus] [status-im2.utils.validators :as validators] [status-im.utils.http :as http] @@ -71,15 +73,27 @@ (defn match-contact-async [chain {:keys [user-id ens-name]} callback] - (let [valid-key (and (validators/valid-public-key? user-id) - (not= user-id ens/default-key))] + (let [valid-public-key? (and (validators/valid-public-key? user-id) + (not= user-id ens/default-key)) + valid-compressed-key? (validators/valid-compressed-key? user-id)] (cond - valid-key + valid-public-key? (callback {:type :contact :public-key user-id :ens-name ens-name}) - (and (not valid-key) + valid-compressed-key? + (status/compressed-key->public-key + user-id + (fn [response] + (let [{:keys [error]} (types/json->clj response)] + (when-not error + (match-contact-async + chain + {:user-id (str "0x" (subs response 5)) :ens-name ens-name} + callback))))) + + (and (not valid-public-key?) (string? user-id) (not (string/blank? user-id)) (not= user-id "0x")) diff --git a/src/status_im/utils/universal_links/core.cljs b/src/status_im/utils/universal_links/core.cljs index 9e82086cd1..44e2b4b38c 100644 --- a/src/status_im/utils/universal_links/core.cljs +++ b/src/status_im/utils/universal_links/core.cljs @@ -113,11 +113,7 @@ :pop-to-root-tab-fx :profile-stack} public-key - (navigation/navigate-to-cofx (-> cofx - (assoc-in [:db :contacts/identity] public-key) - (assoc-in [:db :contacts/ens-name] ens-name)) - :profile - {}))) + {:dispatch [:chat.ui/show-profile public-key ens-name]})) (rf/defn handle-eip681 [cofx data]