mirror of
https://github.com/wekan/wekan.git
synced 2026-11-05 01:20:07 -05:00
Fix addedLabel activity deleted on same-board card move (#3907)
updateActivities() runs in a Cards.before.update hook and removed all addedLabel activities for a card whenever 'boardId' appeared in the changed fields. But Card.move() always re-sets boardId (even for a move within the same board), so every card move deleted the card's label-added history. Gate the removal/remap on an actual board change by comparing the pre-update doc.boardId with modifier.$set.boardId. Cross-board moves still clean up / remap the now-invalid addedLabel activities; same-board moves leave them intact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
839183cd0f
commit
6382ad6a86
1 file changed
+12
-2
+12
-2
@@ -3046,7 +3046,17 @@ Cards.helpers({
|
||||
//FUNCTIONS FOR creation of Activities
|
||||
|
||||
async function updateActivities(doc, fieldNames, modifier) {
|
||||
if (fieldNames.includes('labelIds') && fieldNames.includes('boardId')) {
|
||||
// Only react to a real board CHANGE. This is a before.update hook, so doc is
|
||||
// the pre-update card and modifier.$set.boardId is the new value. Card.move()
|
||||
// always re-sets boardId (even for a move within the same board), so checking
|
||||
// only fieldNames.includes('boardId') wrongly deleted the card's addedLabel
|
||||
// activities on every move. See https://github.com/wekan/wekan/issues/3907
|
||||
const boardIdChanged =
|
||||
fieldNames.includes('boardId') &&
|
||||
!!modifier.$set &&
|
||||
modifier.$set.boardId !== doc.boardId;
|
||||
|
||||
if (fieldNames.includes('labelIds') && boardIdChanged) {
|
||||
const activities = await ReactiveCache.getActivities({
|
||||
activityType: 'addedLabel',
|
||||
cardId: doc._id,
|
||||
@@ -3064,7 +3074,7 @@ async function updateActivities(doc, fieldNames, modifier) {
|
||||
await Activities.removeAsync(a._id);
|
||||
}
|
||||
}
|
||||
} else if (fieldNames.includes('boardId')) {
|
||||
} else if (boardIdChanged) {
|
||||
await Activities.removeAsync({
|
||||
activityType: 'addedLabel',
|
||||
cardId: doc._id,
|
||||
|
||||
Reference in new issue
Block a user