Make team leave & reassing as atomic operation.

This commit is contained in:
Andrey Antukh 2021-11-25 11:27:35 +01:00 committed by Andrés Moya
parent b68d721b39
commit 54f8487b46
2 changed files with 42 additions and 18 deletions

View file

@ -397,16 +397,13 @@
(let [{:keys [on-success on-error]
:or {on-success identity
on-error rx/throw}} (meta params)
team-id (:current-team-id state)]
(rx/concat
(when (uuid? reassign-to)
(->> (rp/mutation! :update-team-member-role {:team-id team-id
:role :owner
:member-id reassign-to})
(rx/ignore)))
(->> (rp/mutation! :leave-team {:id team-id})
(rx/tap on-success)
(rx/catch on-error)))))))
team-id (:current-team-id state)
params (cond-> {:id team-id}
(uuid? reassign-to)
(assoc :reassign-to reassign-to))]
(->> (rp/mutation! :leave-team params)
(rx/tap on-success)
(rx/catch on-error))))))
(defn invite-team-member
[{:keys [email role] :as params}]