1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

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 7956503a46
commit fe91b5241e
478 changed files with 21226 additions and 19495 deletions

View file

@ -29,27 +29,44 @@ export default class extends Model {
static reducer({ type, payload }, Notification) {
switch (type) {
case ActionTypes.NOTIFICATIONS_DELETE:
payload.ids.forEach((id) => {
Notification.withId(id).delete();
});
case ActionTypes.LOCATION_CHANGE_HANDLE:
case ActionTypes.PROJECT_MANAGER_CREATE_HANDLE:
case ActionTypes.BOARD_MEMBERSHIP_CREATE_HANDLE:
if (payload.notifications) {
payload.notifications.forEach((notification) => {
Notification.withId(notification.id).deleteWithRelated();
});
}
break;
case ActionTypes.NOTIFICATIONS_FETCH_SUCCEEDED:
case ActionTypes.SOCKET_RECONNECT_HANDLE:
Notification.all().delete();
payload.notifications.forEach((notification) => {
Notification.upsert(notification);
});
break;
case ActionTypes.NOTIFICATION_CREATE_RECEIVED:
case ActionTypes.CORE_INITIALIZE:
payload.notifications.forEach((notification) => {
Notification.upsert(notification);
});
break;
case ActionTypes.NOTIFICATION_CREATE_HANDLE:
Notification.upsert(payload.notification);
break;
case ActionTypes.NOTIFICATION_DELETE_RECEIVED: {
case ActionTypes.NOTIFICATION_DELETE:
Notification.withId(payload.id).deleteWithRelated();
break;
case ActionTypes.NOTIFICATION_DELETE__SUCCESS:
case ActionTypes.NOTIFICATION_DELETE_HANDLE: {
const notificationModel = Notification.withId(payload.notification.id);
if (notificationModel) {
notificationModel.delete();
notificationModel.deleteWithRelated();
}
break;
@ -57,4 +74,15 @@ export default class extends Model {
default:
}
}
deleteRelated() {
if (this.action && !this.action.isInCard) {
this.action.delete();
}
}
deleteWithRelated() {
this.deleteRelated();
this.delete();
}
}