Skip to content

🐛 fix(duplicate-event): fix event duplication - backend#1000

Merged
victor-enogwe merged 2 commits intomainfrom
fix-duplicate-events-995-backend
Sep 26, 2025
Merged

🐛 fix(duplicate-event): fix event duplication - backend#1000
victor-enogwe merged 2 commits intomainfrom
fix-duplicate-events-995-backend

Conversation

@victor-enogwe
Copy link
Contributor

What does this PR do?

Backend fix

The duplicate functionality was completely broken for both calendar and someday events. When users attempted to duplicate an event via right-click context menu or the Meta+D keyboard shortcut, no new event was created and the UI did not update. This regression was introduced in commit 2de11df during the recent refactoring of draft actions.

Root Cause

The duplicateEvent function in useDraftActions.ts was incorrectly passing the original event's _id to the submit function:

const duplicateEvent = useCallback(() => {
  const draft = MapEvent.removeProviderData({
    ...reduxDraft,
  }) as Schema_GridEvent;

  submit(draft); // ❌ This includes the original _id
  discard();
}, [reduxDraft, submit, discard]);

When an event has an existing _id, the submit function treats it as an edit operation rather than a create operation, causing the duplicate to overwrite the original event instead of creating a new one.

Copilot AI review requested due to automatic review settings September 26, 2025 09:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where event duplication was not working correctly in the backend. The issue was that the event duplication functionality was treating duplicate operations as edit operations instead of create operations, causing duplicates to overwrite the original events.

Key changes:

  • Moved the logic for handling event IDs (removing optimistic prefixes and generating new IDs) to the processEvents method
  • Simplified the payload creation in the POST endpoint to only add the user field
  • Added console logging for debugging

@victor-enogwe victor-enogwe merged commit f63e6a2 into main Sep 26, 2025
4 checks passed
@victor-enogwe victor-enogwe deleted the fix-duplicate-events-995-backend branch September 26, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants