Skip to content
Snippets Groups Projects
Unverified Commit 263800c1 authored by John Swanson's avatar John Swanson Committed by GitHub
Browse files

Skip `:event/{card,dashboard}-update` on pin/unpin (#35066)

When a card or dashboard is pinned, the entity itself is not changing, so let's not send the `:event/card-update` or
`:event/dashboard-update` events in these cases.
parent 584eddc0
No related branches found
No related tags found
No related merge requests found
...@@ -757,7 +757,10 @@ saved later when it is ready." ...@@ -757,7 +757,10 @@ saved later when it is ready."
(let [card (t2/select-one Card :id id)] (let [card (t2/select-one Card :id id)]
(delete-alerts-if-needed! card-before-update card) (delete-alerts-if-needed! card-before-update card)
(events/publish-event! :event/card-update {:object card :user-id api/*current-user-id*}) ;; skip publishing the event if it's just a change in its collection position
(when-not (= #{:collection_position}
(set (keys card-updates)))
(events/publish-event! :event/card-update {:object card :user-id api/*current-user-id*}))
;; include same information returned by GET /api/card/:id since frontend replaces the Card it currently ;; include same information returned by GET /api/card/:id since frontend replaces the Card it currently
;; has with returned one -- See #4142 ;; has with returned one -- See #4142
(-> card (-> card
......
...@@ -607,7 +607,10 @@ ...@@ -607,7 +607,10 @@
(select-keys dashcards-changes-stats [:created-dashcards :deleted-dashcards])))))) (select-keys dashcards-changes-stats [:created-dashcards :deleted-dashcards]))))))
true)) true))
(let [dashboard (t2/select-one :model/Dashboard id)] (let [dashboard (t2/select-one :model/Dashboard id)]
(events/publish-event! :event/dashboard-update {:object dashboard :user-id api/*current-user-id*}) ;; skip publishing the event if it's just a change in its collection position
(when-not (= #{:collection_position}
(set (keys dash-updates)))
(events/publish-event! :event/dashboard-update {:object dashboard :user-id api/*current-user-id*}))
(track-dashcard-and-tab-events! dashboard @changes-stats) (track-dashcard-and-tab-events! dashboard @changes-stats)
(-> (t2/hydrate dashboard [:collection :is_personal] [:dashcards :series] :tabs) (-> (t2/hydrate dashboard [:collection :is_personal] [:dashcards :series] :tabs)
(assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*)))))) (assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment