Add deletion of saved addresses
This commit is contained in:
parent
ecf9806176
commit
7f08fc5e1f
|
@ -0,0 +1,20 @@
|
|||
(ns status-im.contexts.settings.wallet.saved-addresses.events
|
||||
(:require [taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/remove-account-success
|
||||
(fn [_ [toast-message _]]
|
||||
{:fx [[:dispatch [:wallet/get-saved-addresses]]
|
||||
[:dispatch-later
|
||||
{:ms 100
|
||||
:dispatch [:wallet/show-account-deleted-toast toast-message]}]]}))
|
||||
|
||||
(rf/defn delete-saved-address
|
||||
{:events [:wallet/delete-saved-address]}
|
||||
[_ {:keys [address test? toast-message]}]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_deleteSavedAddress"
|
||||
:params [address test?]
|
||||
:on-success [:wallet/remove-account-success toast-message]
|
||||
:on-error #(log/error "Failed to delete saved address" %)}]})
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
(def title-container
|
||||
{:padding-horizontal 20
|
||||
:margin-top 12})
|
||||
:margin-top 12
|
||||
:margin-bottom 16})
|
||||
|
||||
(defn page-wrapper
|
||||
[inset-top]
|
||||
|
|
|
@ -34,8 +34,44 @@
|
|||
:add-divider? add-divider?
|
||||
:accessibility-label accessibility-label}))
|
||||
|
||||
(defn- remove-account
|
||||
[address account-name customization-color]
|
||||
(rf/dispatch [:hide-bottom-sheet])
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:theme :dark
|
||||
:content (fn []
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/remove-saved-address)
|
||||
:customization-color customization-color}]
|
||||
[quo/context-tag
|
||||
{:type :default
|
||||
:customization-color customization-color
|
||||
:size 24
|
||||
:full-name account-name
|
||||
:container-style {:padding-horizontal 20
|
||||
:margin-bottom 16}}]
|
||||
[quo/text
|
||||
{:style {:padding-horizontal 20
|
||||
:margin-bottom 8}}
|
||||
(i18n/label :t/remove-saved-address-description {:name account-name})]
|
||||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
:button-one-label (i18n/label :t/remove)
|
||||
:button-one-props {:on-press (fn []
|
||||
(rf/dispatch [:wallet/delete-saved-address
|
||||
{:address address
|
||||
:toast-message
|
||||
(i18n/label :t/saved-address-removed)
|
||||
:test? false}]))
|
||||
:type :danger}
|
||||
:button-two-label (i18n/label :t/cancel)
|
||||
:button-two-props {:on-press #(rf/dispatch [:hide-bottom-sheet])
|
||||
:type :grey}}]])}]))
|
||||
|
||||
(defn- options
|
||||
[account-name address]
|
||||
[account-name address customization-color]
|
||||
[(when config/show-not-implemented-features?
|
||||
{:icon :i/arrow-up
|
||||
:label (i18n/label :t/send-to-user {:user account-name})
|
||||
|
@ -82,26 +118,27 @@
|
|||
:accessibility-label :edit-saved-address})
|
||||
(when config/show-not-implemented-features?
|
||||
{:icon :i/delete
|
||||
:label (i18n/label :t/remove-account)
|
||||
:on-press not-implemented/alert
|
||||
:label (i18n/label :t/remove-address)
|
||||
:on-press #(remove-account address account-name customization-color)
|
||||
:danger? true
|
||||
:accessibility-label :remove-saved-address
|
||||
:add-divider? true})])
|
||||
|
||||
(defn- sample-options
|
||||
[account-name address]
|
||||
(keep option (options account-name address)))
|
||||
[account-name address customization-color]
|
||||
(keep option (options account-name address customization-color)))
|
||||
|
||||
(defn- account-sheet
|
||||
[address account-name]
|
||||
[address account-name customization-color]
|
||||
[quo/action-drawer
|
||||
[(sample-options account-name address)]])
|
||||
[(sample-options account-name address customization-color)]])
|
||||
|
||||
(defn- on-press-saved-address
|
||||
[{:keys [address account-name ens-name customization-color]}]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:selected-item (fn []
|
||||
{:theme :dark
|
||||
:selected-item (fn []
|
||||
[quo/saved-address
|
||||
{:active-state? false
|
||||
:user-props {:name account-name
|
||||
|
@ -110,7 +147,7 @@
|
|||
:customization-color customization-color}}])
|
||||
:content (fn []
|
||||
[account-sheet
|
||||
address account-name])}]))
|
||||
address account-name customization-color])}]))
|
||||
|
||||
(defn- saved-address
|
||||
[{:keys [address colorId _chain-short-names _test? ens?]
|
||||
|
@ -128,8 +165,7 @@
|
|||
(defn- header
|
||||
[{:keys [title]}]
|
||||
[quo/divider-label
|
||||
{:container-style {:border-top-color colors/white-opa-5
|
||||
:margin-top 16}}
|
||||
{:container-style {:border-top-color colors/white-opa-5}}
|
||||
title])
|
||||
|
||||
(defn- footer
|
||||
|
@ -163,7 +199,6 @@
|
|||
:right :action
|
||||
:customization-color customization-color
|
||||
:icon :i/add}]]
|
||||
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
:sticky-section-headers-enabled false
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
status-im.contexts.onboarding.events
|
||||
status-im.contexts.profile.events
|
||||
status-im.contexts.profile.settings.events
|
||||
status-im.contexts.settings.wallet.saved-addresses.events
|
||||
status-im.contexts.shell.qr-reader.events
|
||||
status-im.contexts.shell.share.events
|
||||
status-im.contexts.syncing.events
|
||||
|
|
|
@ -2613,5 +2613,11 @@
|
|||
"scanning-for-activity": "Scanning for activity...",
|
||||
"send-community-link": "Send community link",
|
||||
"at-least-one-network-must-be-activated": "At least 1 network must be activated",
|
||||
"status-is-a-secure-messaging-app": "Status is a secure messaging app, crypto wallet and web3 browser built with the state of the art technology"
|
||||
"status-is-a-secure-messaging-app": "Status is a secure messaging app, crypto wallet and web3 browser built with the state of the art technology",
|
||||
"send-to-user": "Send to {{user}}",
|
||||
"view-address-on-website": "View address on {{website}}",
|
||||
"saved-address-removed": "Saved address removed",
|
||||
"remove-address": "Remove address",
|
||||
"remove-saved-address-description": "Transaction history relating to this address will no longer be labelled ‘{{name}}’.",
|
||||
"remove-saved-address": "Remove saved address"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue