[#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)) (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 (fx/defn load-link-preview-data
{:events [::load-link-preview-data]} {:events [::load-link-preview-data]}
[cofx link] [cofx link]

View File

@ -24,28 +24,30 @@
(views/defview link-previews-settings [] (views/defview link-previews-settings []
(views/letsubs [link-previews-whitelist [:link-preview/whitelist] (views/letsubs [link-previews-whitelist [:link-preview/whitelist]
link-previews-enabled-sites [:link-preview/enabled-sites]] link-previews-enabled-sites [:link-preview/enabled-sites]]
[react/view {:flex 1} (let [all-enabled (= (count link-previews-whitelist) (count link-previews-enabled-sites))]
[topbar/topbar {:title (i18n/label :t/chat-link-previews)}] [react/view {:flex 1}
[react/image {:source (resources/get-theme-image :unfurl) [topbar/topbar {:title (i18n/label :t/chat-link-previews)}]
:style styles/link-preview-settings-image}] [react/image {:source (resources/get-theme-image :unfurl)
[quo/text {:style {:margin 16}} :style styles/link-preview-settings-image}]
(i18n/label :t/you-can-choose-preview-websites)] [quo/text {:style {:margin 16}}
[quo/separator {:style {:margin-vertical 8}}] (i18n/label :t/you-can-choose-preview-websites)]
[quo/separator {:style {:margin-vertical 8}}]
[react/view styles/whitelist-container [react/view styles/whitelist-container
[quo/list-header (i18n/label :t/websites)] [quo/list-header (i18n/label :t/websites)]
(when (> (count link-previews-whitelist) 1) (when (> (count link-previews-whitelist) 1)
[quo/button {:on-press #(doseq [site (map :title link-previews-whitelist)] [quo/button {:on-press #(re-frame/dispatch [::link-preview/enable-all
(re-frame/dispatch link-previews-whitelist
[::link-preview/enable site true])) (not all-enabled)])
:type :secondary :type :secondary
:style styles/enable-all} :style styles/enable-all}
(i18n/label :t/enable-all)])] (if all-enabled
(i18n/label :t/disable-all)
[list/flat-list (i18n/label :t/enable-all))])]
{:data (vec (map (prepare-urls-items-data link-previews-enabled-sites) link-previews-whitelist)) [list/flat-list
:key-fn (fn [_ i] (str i)) {:data (vec (map (prepare-urls-items-data link-previews-enabled-sites) link-previews-whitelist))
:render-fn quo/list-item :key-fn (fn [_ i] (str i))
:footer [quo/text {:color :secondary :render-fn quo/list-item
:style {:margin 16}} (i18n/label :t/previewing-may-share-metadata)]}]])) :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", "previewing-may-share-metadata" : "Previewing links from these websites may share your metadata with their owners",
"websites" : "Websites", "websites" : "Websites",
"enable-all" : "Enable all", "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.", "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", "dont-ask": "Don't ask me again",
"enable-link-previews": "Enable link previews in chat?", "enable-link-previews": "Enable link previews in chat?",