Fix: unable to delete speaker profile pic - #1032
Conversation
📝 WalkthroughWalkthroughThe speaker save flow now detects removed profile and big photos. It updates the speaker, deletes removed photos through dedicated async actions, and dispatches ChangesSpeaker photo cleanup
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 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"; |
There was a problem hiding this comment.
🗄️ 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' srcRepository: 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\)' srcRepository: 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.
| )({})(dispatch).then(async () => { | ||
| if (removeProfilePic) { | ||
| await dispatch(deleteProfilePic(entity.id)); | ||
| } | ||
| if (removeBigPic) { | ||
| await dispatch(deleteBigPic(entity.id)); | ||
| } |
There was a problem hiding this comment.
🎯 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.
https://app.clickup.com/t/9014802374/86bb6hm53
Summary by CodeRabbit