Project managers, board members, auto-update after reconnection, refactoring

This commit is contained in:
Maksim Eltyshev
2021-06-24 01:05:22 +05:00
parent d6cb1f6683
commit b39119ace4
478 changed files with 21226 additions and 19495 deletions

View File

@@ -1,12 +1,16 @@
import { call, put, select } from 'redux-saga/effects';
import request from '../request';
import { isAttachmentWithIdExistsSelector, pathSelector } from '../../../selectors';
import {
createAttachmentRequest,
deleteAttachmentRequest,
updateAttachmentRequest,
} from '../requests';
import { pathSelector } from '../../../selectors';
import { createAttachment, deleteAttachment, updateAttachment } from '../../../actions';
createAttachment,
deleteAttachment,
handleAttachmentCreate,
handleAttachmentDelete,
handleAttachmentUpdate,
updateAttachment,
} from '../../../actions';
import api from '../../../api';
import { createLocalId } from '../../../utils/local-id';
export function* createAttachmentService(cardId, data) {
@@ -20,7 +24,15 @@ export function* createAttachmentService(cardId, data) {
}),
);
yield call(createAttachmentRequest, cardId, localId, data);
let attachment;
try {
({ item: attachment } = yield call(request, api.createAttachment, cardId, data, localId));
} catch (error) {
yield put(createAttachment.failure(localId, error));
return;
}
yield put(createAttachment.success(localId, attachment));
}
export function* createAttachmentInCurrentCardService(data) {
@@ -29,12 +41,46 @@ export function* createAttachmentInCurrentCardService(data) {
yield call(createAttachmentService, cardId, data);
}
export function* handleAttachmentCreateService(attachment, requestId) {
const isExists = yield select(isAttachmentWithIdExistsSelector, requestId);
if (!isExists) {
yield put(handleAttachmentCreate(attachment));
}
}
export function* updateAttachmentService(id, data) {
yield put(updateAttachment(id, data));
yield call(updateAttachmentRequest, id, data);
let attachment;
try {
({ item: attachment } = yield call(request, api.updateAttachment, id, data));
} catch (error) {
yield put(updateAttachment.failure(id, error));
return;
}
yield put(updateAttachment.success(attachment));
}
export function* handleAttachmentUpdateService(attachment) {
yield put(handleAttachmentUpdate(attachment));
}
export function* deleteAttachmentService(id) {
yield put(deleteAttachment(id));
yield call(deleteAttachmentRequest, id);
let attachment;
try {
({ item: attachment } = yield call(request, api.deleteAttachment, id));
} catch (error) {
yield put(deleteAttachment.failure(id, error));
return;
}
yield put(deleteAttachment.success(attachment));
}
export function* handleAttachmentDeleteService(attachment) {
yield put(handleAttachmentDelete(attachment));
}