[#11843] "Enable all" is disabled after relogin for 3 or 4 chat link previews after relogin

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-03-08 10:50:42 +01:00
parent a9124d0fd2
commit 51178ab1b2
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
3 changed files with 37 additions and 23 deletions

View File

@ -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]

View File

@ -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)]}]])))

View File

@ -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?",