[UI/UX] Improve image upload experience — add preview & drag-to-reord… (#2095)

* [UI/UX] Improve image upload experience — add preview & drag-to-reorder in chat section

* chore(chat): remove image previews, keep drag-to-reorder

* chore(chat): prevent attachment drag from triggering upload dropzone

* Revert "chore(chat): prevent attachment drag from triggering upload dropzone"

This reverts commit dd4b96256c.

* (feat:conv) rmv drag-drop on sources

* (feat:msg-input) drop attachments

---------

Co-authored-by: ManishMadan2882 <manishmadan321@gmail.com>
This commit is contained in:
Nikunj Kohli
2025-10-28 01:23:18 +05:30
committed by GitHub
parent d8ec3c008c
commit 9f7945fcf5
9 changed files with 285 additions and 219 deletions

View File

@@ -66,6 +66,23 @@ export const uploadSlice = createSlice({
(att) => att.id !== action.payload,
);
},
// Reorder attachments array by moving item from sourceIndex to destinationIndex
reorderAttachments: (
state,
action: PayloadAction<{ sourceIndex: number; destinationIndex: number }>,
) => {
const { sourceIndex, destinationIndex } = action.payload;
if (
sourceIndex < 0 ||
destinationIndex < 0 ||
sourceIndex >= state.attachments.length ||
destinationIndex >= state.attachments.length
)
return;
const [moved] = state.attachments.splice(sourceIndex, 1);
state.attachments.splice(destinationIndex, 0, moved);
},
clearAttachments: (state) => {
state.attachments = state.attachments.filter(
(att) => att.status === 'uploading' || att.status === 'processing',
@@ -121,6 +138,7 @@ export const {
addAttachment,
updateAttachment,
removeAttachment,
reorderAttachments,
clearAttachments,
addUploadTask,
updateUploadTask,