Fix attachment duplication on add
This commit is contained in:
@@ -23,7 +23,7 @@ export function* createAttachmentRequest(cardId, localId, data) {
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createAttachment, cardId, data);
|
||||
const { item } = yield call(request, api.createAttachment, cardId, data, localId);
|
||||
|
||||
const action = createAttachmentSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { logoutService } from './login';
|
||||
import { closeModalService } from './modal';
|
||||
import { deleteNotificationsRequest, fetchUsersRequest } from '../requests';
|
||||
import {
|
||||
attachmentWithIdExistsSelector,
|
||||
currentModalSelector,
|
||||
currentUserIdSelector,
|
||||
currentUserSelector,
|
||||
@@ -208,8 +209,12 @@ export function* deleteTaskReceivedService(task) {
|
||||
yield put(deleteTaskReceived(task));
|
||||
}
|
||||
|
||||
export function* createAttachmentReceivedService(attachment) {
|
||||
yield put(createAttachmentReceived(attachment));
|
||||
export function* createAttachmentReceivedService(attachment, requestId) {
|
||||
const exists = yield select(attachmentWithIdExistsSelector, requestId);
|
||||
|
||||
if (!exists) {
|
||||
yield put(createAttachmentReceived(attachment));
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateAttachmentReceivedService(attachment) {
|
||||
|
||||
@@ -156,8 +156,8 @@ const createSocketEventsChannel = () =>
|
||||
emit([deleteTaskReceivedService, item]);
|
||||
};
|
||||
|
||||
const handleAttachmentCreate = api.makeHandleAttachmentCreate(({ item }) => {
|
||||
emit([createAttachmentReceivedService, item]);
|
||||
const handleAttachmentCreate = api.makeHandleAttachmentCreate(({ item, requestId }) => {
|
||||
emit([createAttachmentReceivedService, item, requestId]);
|
||||
});
|
||||
|
||||
const handleAttachmentUpdate = api.makeHandleAttachmentUpdate(({ item }) => {
|
||||
|
||||
Reference in New Issue
Block a user