mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-02-22 12:21:39 +00:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user