Skip to content

Fix: unable to delete speaker profile pic - #1032

Open
santipalenque wants to merge 1 commit into
masterfrom
fix/delete-speaker-image
Open

Fix: unable to delete speaker profile pic#1032
santipalenque wants to merge 1 commit into
masterfrom
fix/delete-speaker-image

Conversation

@santipalenque

@santipalenque santipalenque commented Jul 31, 2026

Copy link
Copy Markdown

https://app.clickup.com/t/9014802374/86bb6hm53

Summary by CodeRabbit

  • Bug Fixes
    • Removed profile and large speaker images are now automatically deleted when speaker details are saved.
    • Added handling for image deletion events to keep speaker profiles up to date.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The speaker save flow now detects removed profile and big photos. It updates the speaker, deletes removed photos through dedicated async actions, and dispatches PIC_DELETED during the deletion lifecycle.

Changes

Speaker photo cleanup

Layer / File(s) Summary
Photo deletion actions
src/actions/speaker-actions.js
Adds the PIC_DELETED action type and async actions for deleting profile and big photos.
Speaker save cleanup
src/actions/speaker-actions.js
saveSpeaker reads the previous speaker, detects removed photos, and awaits their deletion after the speaker update.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant saveSpeaker
  participant State
  participant SpeakerAPI
  participant PhotoDeletionActions
  participant PhotoAPI
  saveSpeaker->>State: Read previous speaker
  saveSpeaker->>SpeakerAPI: Update speaker
  SpeakerAPI-->>saveSpeaker: Return update result
  saveSpeaker->>PhotoDeletionActions: Delete removed profile photo
  PhotoDeletionActions->>PhotoAPI: DELETE profile photo
  PhotoDeletionActions->>PhotoAPI: DELETE big photo when removed
  PhotoAPI-->>PhotoDeletionActions: Return deletion lifecycle
  PhotoDeletionActions-->>saveSpeaker: Complete deletion actions
Loading

Suggested reviewers: smarcet, tomrndom

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing speaker profile picture deletion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/delete-speaker-image

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/actions/speaker-actions.js`:
- Around line 391-397: Update saveSpeaker’s promise chain around the dispatch
callback so it returns the update request and each conditional
deleteProfilePic/deleteBigPic dispatch promise, ensuring
dispatch(saveSpeaker(entity)) remains pending until all requested operations
complete. Preserve the existing conditional deletion behavior and sequencing.
- Line 64: Update speakerReducer to handle the PIC_DELETED action by using its
photo-type metadata to clear the corresponding pic or big_pic field, or refresh
the speaker state after deletion. Preserve the existing state shape and ensure
unrelated photo fields remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39ef8867-78ea-4c1e-843b-85392600b9df

📥 Commits

Reviewing files that changed from the base of the PR and between 54e0bd4 and e11f7c7.

📒 Files selected for processing (1)
  • src/actions/speaker-actions.js

export const SPEAKER_UPDATED = "SPEAKER_UPDATED";
export const SPEAKER_ADDED = "SPEAKER_ADDED";
export const PIC_ATTACHED = "PIC_ATTACHED";
export const PIC_DELETED = "PIC_DELETED";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 8 --glob '*.js' \
  '\bPIC_DELETED\b|deleteProfilePic|deleteBigPic|currentSpeakerState|big_pic' .

Repository: fntechgit/summit-admin

Length of output: 21131


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- speaker reducer ---'
cat -n src/reducers/speakers/speaker-reducer.js | sed -n '1,210p'

echo '--- action helpers and speaker refresh flow ---'
rg -n -C 10 --glob '*.js' \
  'function deleteRequest|const deleteRequest|export const deleteRequest|deleteRequest\s*=|function getSpeaker|export const getSpeaker|RECEIVE_SPEAKER|PIC_DELETED' src

Repository: fntechgit/summit-admin

Length of output: 42974


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- request helper imports ---'
cat -n src/actions/speaker-actions.js | sed -n '1,50p'

echo '--- update request helper definition and tests ---'
rg -n -C 12 --glob '*.js' \
  'UPDATE_SPEAKER|updateRequest|createAction\(SPEAKER_UPDATED\)|createAction\(UPDATE_SPEAKER\)' src

Repository: fntechgit/summit-admin

Length of output: 12288


Handle PIC_DELETED in speakerReducer.

The reducer ignores PIC_DELETED, so it cannot clear either pic or big_pic. Add photo-type metadata and clear the matching field, or refresh the speaker after deletion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/actions/speaker-actions.js` at line 64, Update speakerReducer to handle
the PIC_DELETED action by using its photo-type metadata to clear the
corresponding pic or big_pic field, or refresh the speaker state after deletion.
Preserve the existing state shape and ensure unrelated photo fields remain
unchanged.

Comment on lines +391 to +397
)({})(dispatch).then(async () => {
if (removeProfilePic) {
await dispatch(deleteProfilePic(entity.id));
}
if (removeBigPic) {
await dispatch(deleteBigPic(entity.id));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return the update and deletion promise chain.

saveSpeaker resolves after it schedules putRequest. It does not wait for the update or either deletion. A caller that awaits dispatch(saveSpeaker(entity)) can continue before the profile photo deletion completes.

Proposed fix
-    putRequest(
+    return putRequest(
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/actions/speaker-actions.js` around lines 391 - 397, Update saveSpeaker’s
promise chain around the dispatch callback so it returns the update request and
each conditional deleteProfilePic/deleteBigPic dispatch promise, ensuring
dispatch(saveSpeaker(entity)) remains pending until all requested operations
complete. Preserve the existing conditional deletion behavior and sequencing.

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.

1 participant