-
Notifications
You must be signed in to change notification settings - Fork 4
Fix: unable to delete speaker profile pic #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ export const UPDATE_SPEAKER = "UPDATE_SPEAKER"; | |
| export const SPEAKER_UPDATED = "SPEAKER_UPDATED"; | ||
| export const SPEAKER_ADDED = "SPEAKER_ADDED"; | ||
| export const PIC_ATTACHED = "PIC_ATTACHED"; | ||
| export const PIC_DELETED = "PIC_DELETED"; | ||
| export const BIG_PIC_ATTACHED = "BIG_PIC_ATTACHED"; | ||
| export const MERGE_SPEAKERS = "MERGE_SPEAKERS"; | ||
| export const SPEAKER_MERGED = "SPEAKER_MERGED"; | ||
|
|
@@ -141,6 +142,18 @@ const uploadProfilePic = (entity, file) => async (dispatch) => { | |
| }); | ||
| }; | ||
|
|
||
| const deleteProfilePic = (speakerId) => async (dispatch) => { | ||
| const accessToken = await getAccessTokenSafely(); | ||
|
|
||
| return deleteRequest( | ||
| null, | ||
| createAction(PIC_DELETED), | ||
| `${window.API_BASE_URL}/api/v1/speakers/${speakerId}/photo?access_token=${accessToken}`, | ||
| null, | ||
| authErrorHandler | ||
| )({})(dispatch); | ||
| }; | ||
|
|
||
| const uploadBigPic = (entity, file) => async (dispatch) => { | ||
| const accessToken = await getAccessTokenSafely(); | ||
|
|
||
|
|
@@ -157,6 +170,18 @@ const uploadBigPic = (entity, file) => async (dispatch) => { | |
| }); | ||
| }; | ||
|
|
||
| const deleteBigPic = (speakerId) => async (dispatch) => { | ||
| const accessToken = await getAccessTokenSafely(); | ||
|
|
||
| return deleteRequest( | ||
| null, | ||
| createAction(PIC_DELETED), | ||
| `${window.API_BASE_URL}/api/v1/speakers/${speakerId}/big-photo?access_token=${accessToken}`, | ||
| null, | ||
| authErrorHandler | ||
| )({})(dispatch); | ||
| }; | ||
|
|
||
| export const initSpeakersList = () => async (dispatch) => { | ||
| dispatch(createAction(INIT_SPEAKERS_LIST_PARAMS)()); | ||
| }; | ||
|
|
@@ -343,7 +368,12 @@ export const resetSpeakerForm = () => (dispatch) => { | |
| dispatch(createAction(RESET_SPEAKER_FORM)({})); | ||
| }; | ||
|
|
||
| export const saveSpeaker = (entity) => async (dispatch) => { | ||
| export const saveSpeaker = (entity) => async (dispatch, getState) => { | ||
| const { currentSpeakerState } = getState(); | ||
| const { entity: prevSpeaker } = currentSpeakerState; | ||
| const removeProfilePic = prevSpeaker?.pic && !entity.pic; | ||
| const removeBigPic = prevSpeaker?.big_pic && !entity.big_pic; | ||
|
|
||
| const accessToken = await getAccessTokenSafely(); | ||
|
|
||
| dispatch(startLoading()); | ||
|
|
@@ -358,7 +388,13 @@ export const saveSpeaker = (entity) => async (dispatch) => { | |
| normalizedEntity, | ||
| authErrorHandler, | ||
| entity | ||
| )({})(dispatch).then(() => { | ||
| )({})(dispatch).then(async () => { | ||
| if (removeProfilePic) { | ||
| await dispatch(deleteProfilePic(entity.id)); | ||
| } | ||
| if (removeBigPic) { | ||
| await dispatch(deleteBigPic(entity.id)); | ||
| } | ||
|
Comment on lines
+391
to
+397
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Return the update and deletion promise chain.
Proposed fix- putRequest(
+ return putRequest(🤖 Prompt for AI Agents |
||
| dispatch(showSuccessMessage(T.translate("edit_speaker.speaker_saved"))); | ||
| }); | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
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:
Repository: fntechgit/summit-admin
Length of output: 21131
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 42974
🏁 Script executed:
Repository: fntechgit/summit-admin
Length of output: 12288
Handle
PIC_DELETEDinspeakerReducer.The reducer ignores
PIC_DELETED, so it cannot clear eitherpicorbig_pic. Add photo-type metadata and clear the matching field, or refresh the speaker after deletion.🤖 Prompt for AI Agents