mirror of
https://github.com/penpot/penpot.git
synced 2026-05-25 09:53:44 +00:00
✨ Allow delete subscriptions on profile deletion request
This commit is contained in:
parent
c9d71f3b2d
commit
3c45a8d0b4
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
;; Watch for profile deletion events
|
;; Watch for profile deletion events
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter dp/profile-deleted?)
|
(rx/filter dp/profile-deleted-event?)
|
||||||
(rx/map da/logged-out))
|
(rx/map da/logged-out))
|
||||||
|
|
||||||
;; Once profile is fetched, initialize all penpot application
|
;; Once profile is fetched, initialize all penpot application
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.router :as rt]
|
[app.main.router :as rt]
|
||||||
[app.plugins.register :as plugins.register]
|
[app.plugins.register :as plugins.register]
|
||||||
|
[app.util.http :as http]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.storage :as storage]
|
[app.util.storage :as storage]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
@ -356,9 +357,19 @@
|
|||||||
|
|
||||||
;; --- EVENT: request-account-deletion
|
;; --- EVENT: request-account-deletion
|
||||||
|
|
||||||
(def profile-deleted?
|
(def profile-deleted-event?
|
||||||
(ptk/type? ::profile-deleted))
|
(ptk/type? ::profile-deleted))
|
||||||
|
|
||||||
|
(defn- delete-subscription
|
||||||
|
[]
|
||||||
|
(if (contains? cf/flags :subscriptions)
|
||||||
|
(->> (http/fetch {:uri "/payments/subscriptions/delete"
|
||||||
|
:credentials "include"
|
||||||
|
:method :get})
|
||||||
|
(rx/map (constantly nil))
|
||||||
|
(rx/catch #(rx/empty)))
|
||||||
|
(rx/empty)))
|
||||||
|
|
||||||
(defn request-account-deletion
|
(defn request-account-deletion
|
||||||
[params]
|
[params]
|
||||||
(ptk/reify ::request-account-deletion
|
(ptk/reify ::request-account-deletion
|
||||||
@ -366,13 +377,17 @@
|
|||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(let [{:keys [on-error on-success]
|
(let [{:keys [on-error on-success]
|
||||||
:or {on-error rx/throw
|
:or {on-error rx/throw
|
||||||
on-success identity}} (meta params)]
|
on-success identity}}
|
||||||
(->> (rp/cmd! :delete-profile {})
|
(meta params)]
|
||||||
(rx/tap on-success)
|
|
||||||
(rx/map (fn [_]
|
(rx/concat
|
||||||
(ptk/data-event ::profile-deleted params)))
|
(delete-subscription)
|
||||||
(rx/catch on-error)
|
(->> (rp/cmd! :delete-profile {})
|
||||||
(rx/delay-at-least 300))))))
|
(rx/tap on-success)
|
||||||
|
(rx/map (fn [_]
|
||||||
|
(ptk/data-event ::profile-deleted params)))
|
||||||
|
(rx/catch on-error)
|
||||||
|
(rx/delay-at-least 300)))))))
|
||||||
|
|
||||||
;; --- EVENT: request-profile-recovery
|
;; --- EVENT: request-profile-recovery
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user