mirror of
https://github.com/penpot/penpot.git
synced 2026-07-24 23:18:06 +00:00
🐛 Guard team-container* when team-id is not a uuid (#10645)
The dashboard route can be reached without a `:team-id` query parameter
(e.g. `/#/dashboard/recent`). When that happened, `team-container*` was
emitting `dtm/initialize-team` with a `nil` team-id, which set
`:current-team-id` to `nil` in the application state. The dashboard
and workspace initialize events then built `df/fetch-fonts` with a
`nil` team-id, producing a `:get-font-variants` RPC with empty params
`{}` that the backend rejected with HTTP 400.
Guard `team-container*` so it does not emit `initialize-team` /
`finalize-team` and does not render the children when `team-id` is
not a uuid. The `with-effect` body and the render are guarded
independently; the cleanup closure captures the same `team-id` as the
setup, so the finalize still fires correctly when transitioning between
valid teams.
AI-assisted-by: minimax-m3
This commit is contained in:
parent
2523a72c32
commit
eb1e0ad186
@ -133,18 +133,21 @@
|
||||
::mf/private true}
|
||||
[{:keys [team-id children]}]
|
||||
(mf/with-effect [team-id]
|
||||
(st/emit! (dtm/initialize-team team-id))
|
||||
(fn []
|
||||
(st/emit! (dtm/finalize-team team-id))))
|
||||
(when (uuid? team-id)
|
||||
(st/emit! (dtm/initialize-team team-id))
|
||||
(fn []
|
||||
(st/emit! (dtm/finalize-team team-id)))))
|
||||
|
||||
(let [{:keys [permissions] :as team} (mf/deref refs/team)]
|
||||
(when (= team-id (:id team))
|
||||
[:> (mf/provider ctx/current-team-id) {:value team-id}
|
||||
[:> (mf/provider ctx/permissions) {:value permissions}
|
||||
[:> (mf/provider ctx/can-edit?) {:value (:can-edit permissions)}
|
||||
;; The `:key` is mandatory here because we want to reinitialize
|
||||
;; all dom tree instead of simple rerender.
|
||||
[:* {:key (str team-id)} children]]]])))
|
||||
(if-not (uuid? team-id)
|
||||
nil
|
||||
(let [{:keys [permissions] :as team} (mf/deref refs/team)]
|
||||
(when (= team-id (:id team))
|
||||
[:> (mf/provider ctx/current-team-id) {:value team-id}
|
||||
[:> (mf/provider ctx/permissions) {:value permissions}
|
||||
[:> (mf/provider ctx/can-edit?) {:value (:can-edit permissions)}
|
||||
;; The `:key` is mandatory here because we want to reinitialize
|
||||
;; all dom tree instead of simple rerender.
|
||||
[:* {:key (str team-id)} children]]]]))))
|
||||
|
||||
(mf/defc page*
|
||||
{::mf/props :obj
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user