From 33e58dbca94ec8a5ee11bdfa0021ff7a3dc93265 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Thu, 24 Dec 2020 15:33:30 +0100 Subject: [PATCH] Whitelist link previews client side Signed-off-by: Andrea Maria Piana --- src/status_im/subs.cljs | 4 +++- src/status_im/ui/screens/link_previews_settings/views.cljs | 3 ++- src/status_im/utils/config.cljs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index c03b356950..f9261e9ab1 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -2474,7 +2474,9 @@ :link-preview/whitelist :<- [:multiaccount] (fn [multiaccount] - (get multiaccount :link-previews-whitelist))) + (filter (fn [{:keys [address]}] + (config/link-preview-enabled-site? address)) + (get multiaccount :link-previews-whitelist)))) (re-frame/reg-sub :link-preview/cache diff --git a/src/status_im/ui/screens/link_previews_settings/views.cljs b/src/status_im/ui/screens/link_previews_settings/views.cljs index 4e2677ef9a..cfd3b69a2b 100644 --- a/src/status_im/ui/screens/link_previews_settings/views.cljs +++ b/src/status_im/ui/screens/link_previews_settings/views.cljs @@ -22,7 +22,8 @@ [::link-preview/enable title ((complement boolean) enabled?)])}))) (views/defview link-previews-settings [] - (views/letsubs [{:keys [link-previews-whitelist link-previews-enabled-sites]} [:multiaccount]] + (views/letsubs [link-previews-whitelist [:link-preview/whitelist] + link-previews-enabled-sites [:link-preview/enabled-sites]] [react/view {:flex 1} [topbar/topbar {:title (i18n/label :t/chat-link-previews)}] [react/image {:source (resources/get-theme-image :unfurl) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index d1934048ce..642b874b31 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -141,3 +141,5 @@ [id network]) default-networks))) +(def link-preview-enabled-site? + #{"youtube.com" "youtu.be"})