Skip to content

Commit

Permalink
[#8516] Cannot delete dapp from "Recent"
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Sep 24, 2019
1 parent e91375a commit 222c6ac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 66 deletions.
9 changes: 9 additions & 0 deletions src/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
:params [browser-id]
:on-success #()}]})

(fx/defn clear-all-browsers
{:events [:browser.ui/clear-all-browsers-pressed]}
[{:keys [db]}]
{:db (dissoc db :browser/browsers)
::json-rpc/call (for [browser-id (keys (get db :browser/browsers))]
{:method "browsers_deleteBrowser"
:params [browser-id]
:on-success #()})})

(defn update-dapp-name [{:keys [name] :as browser}]
(assoc browser :dapp? false :name (or name (i18n/label :t/browser))))

Expand Down
18 changes: 1 addition & 17 deletions src/status_im/ui/components/list/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
[status-im.ui.components.list-item.views :as list-item]
[status-im.ui.components.list.styles :as styles]
[status-im.ui.components.react :as react]
[status-im.ui.screens.home.animations.responder :as responder]
[status-im.utils.platform :as platform]
[status-im.ui.components.radio :as radio])
(:require-macros [status-im.utils.views :as views]))
Expand Down Expand Up @@ -324,19 +323,4 @@
[react/view (merge styles/list-with-label-wrapper style)
[react/text {:style styles/label}
label]
list])

;;TODO DEPRECATED, use long-press
(views/defview deletable-list-item [{:keys [type id on-delete]} body]
(views/letsubs [swiped? [:delete-swipe-position type id]]
(let [offset-x (animation/create-value (if swiped? styles/delete-button-width 0))
swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?)
swipe-pan-handler (responder/pan-handlers swipe-pan-responder)]
[react/view swipe-pan-handler
[react/animated-view {:style {:flex 1
:transform [{:translateX offset-x}]}}
body
[react/touchable-highlight {:style styles/delete-icon-highlight
:on-press on-delete}
[react/view {:style styles/delete-icon-container}
[vector-icons/icon :main-icons/delete {:color colors/red}]]]]])))
list])
39 changes: 28 additions & 11 deletions src/status_im/ui/screens/browser/open_dapp/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,35 @@
[reagent.core :as reagent])
(:require-macros [status-im.utils.views :as views]))

(defn hide-sheet-and-dispatch [event]
(re-frame/dispatch [:bottom-sheet/hide-sheet])
(re-frame/dispatch event))

(defn list-item [{:keys [browser-id name url]}]
[list/deletable-list-item {:type :browsers
:id browser-id
:on-delete #(do
(re-frame/dispatch [:set-swipe-position :browsers browser-id false])
(re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))}
[list-item/list-item
{:on-press #(re-frame/dispatch [:browser.ui/browser-item-selected browser-id])
:title name
:subtitle (or url :t/dapp)
:icon [react/view styles/browser-icon-container
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}]])
[list-item/list-item
{:on-press #(re-frame/dispatch [:browser.ui/browser-item-selected browser-id])
:on-long-press (fn []
(re-frame/dispatch
[:bottom-sheet/show-sheet
{:content (fn []
[react/view {:flex 1}
[list-item/list-item
{:theme :action
:title :t/remove
:accessibility-label :remove-dapp-from-list
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:browser.ui/remove-browser-pressed browser-id])}]
[list-item/list-item
{:theme :action-destructive
:title :t/clear-all
:accessibility-label :clear-all-dapps
:icon :main-icons/delete
:on-press #(hide-sheet-and-dispatch [:browser.ui/clear-all-browsers-pressed])}]])
:content-height 128}]))
:title name
:subtitle (or url :t/dapp)
:icon [react/view styles/browser-icon-container
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}])

(def dapp-image-data {:image (resources/get-image :dapp-store) :width 768 :height 333})
(defn dapp-image [] [components.common/image-contain nil dapp-image-data])
Expand Down
38 changes: 0 additions & 38 deletions src/status_im/ui/screens/home/animations/responder.cljs

This file was deleted.

1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"check-your-recovery-phrase": "Check your seed phrase",
"choose-authentication-method": "Choose an authentication method to protect your multiaccount",
"clear": "Clear",
"clear-all": "Clear all",
"clear-history": "Clear history",
"clear-history-action": "Clear",
"clear-history-confirmation": "Clear history?",
Expand Down

0 comments on commit 222c6ac

Please sign in to comment.