diff --git a/src/status_im/chat/models/link_preview.cljs b/src/status_im/chat/models/link_preview.cljs index 6d0ec1d8e1..3142d0fbed 100644 --- a/src/status_im/chat/models/link_preview.cljs +++ b/src/status_im/chat/models/link_preview.cljs @@ -16,6 +16,17 @@ (disj (get multiaccount :link-previews-enabled-sites #{}) site)) {}))) +(fx/defn enable-all + {:events [::enable-all]} + [{{:keys [multiaccount]} :db :as cofx} link-previews-whitelist enabled?] + (fx/merge cofx + (multiaccounts.update/multiaccount-update + :link-previews-enabled-sites + (if enabled? + (into #{} (map :title link-previews-whitelist)) + #{}) + {}))) + (fx/defn load-link-preview-data {:events [::load-link-preview-data]} [cofx link] 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 07b0b9142c..ec387b9977 100644 --- a/src/status_im/ui/screens/link_previews_settings/views.cljs +++ b/src/status_im/ui/screens/link_previews_settings/views.cljs @@ -24,28 +24,30 @@ (views/defview link-previews-settings [] (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) - :style styles/link-preview-settings-image}] - [quo/text {:style {:margin 16}} - (i18n/label :t/you-can-choose-preview-websites)] - [quo/separator {:style {:margin-vertical 8}}] + (let [all-enabled (= (count link-previews-whitelist) (count link-previews-enabled-sites))] + [react/view {:flex 1} + [topbar/topbar {:title (i18n/label :t/chat-link-previews)}] + [react/image {:source (resources/get-theme-image :unfurl) + :style styles/link-preview-settings-image}] + [quo/text {:style {:margin 16}} + (i18n/label :t/you-can-choose-preview-websites)] + [quo/separator {:style {:margin-vertical 8}}] - [react/view styles/whitelist-container - [quo/list-header (i18n/label :t/websites)] + [react/view styles/whitelist-container + [quo/list-header (i18n/label :t/websites)] - (when (> (count link-previews-whitelist) 1) - [quo/button {:on-press #(doseq [site (map :title link-previews-whitelist)] - (re-frame/dispatch - [::link-preview/enable site true])) - :type :secondary - :style styles/enable-all} - (i18n/label :t/enable-all)])] - - [list/flat-list - {:data (vec (map (prepare-urls-items-data link-previews-enabled-sites) link-previews-whitelist)) - :key-fn (fn [_ i] (str i)) - :render-fn quo/list-item - :footer [quo/text {:color :secondary - :style {:margin 16}} (i18n/label :t/previewing-may-share-metadata)]}]])) + (when (> (count link-previews-whitelist) 1) + [quo/button {:on-press #(re-frame/dispatch [::link-preview/enable-all + link-previews-whitelist + (not all-enabled)]) + :type :secondary + :style styles/enable-all} + (if all-enabled + (i18n/label :t/disable-all) + (i18n/label :t/enable-all))])] + [list/flat-list + {:data (vec (map (prepare-urls-items-data link-previews-enabled-sites) link-previews-whitelist)) + :key-fn (fn [_ i] (str i)) + :render-fn quo/list-item + :footer [quo/text {:color :secondary + :style {:margin 16}} (i18n/label :t/previewing-may-share-metadata)]}]]))) diff --git a/translations/en.json b/translations/en.json index 37cb328097..8fbf5d4a0e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1414,6 +1414,7 @@ "previewing-may-share-metadata" : "Previewing links from these websites may share your metadata with their owners", "websites" : "Websites", "enable-all" : "Enable all", + "disable-all" : "Disable all", "warning-sending-to-contract-descr": "The address you entered is a smart contract, sending funds to this address may result in loss of funds. To interact with a DApp, open the DApp in the Status DApp Browser.", "dont-ask": "Don't ask me again", "enable-link-previews": "Enable link previews in chat?",