sse für live collab eingebaut
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
import { CreateListFromTemplateDto } from '../list-templates/dto/create-list-from-template.dto';
|
||||
import { AddListItemDto, UpdateListItemDto } from './dto/list-item.dto';
|
||||
import { CreateListDto } from './dto/create-list.dto';
|
||||
import { ListRealtimeService } from './list-realtime.service';
|
||||
import { UpdateListDto } from './dto/update-list.dto';
|
||||
import { UserListEntity } from './user-list.entity';
|
||||
import { UserListItemEntity } from './user-list-item.entity';
|
||||
@@ -31,6 +32,8 @@ export class ListsService {
|
||||
private readonly listItemsRepository: Repository<UserListItemEntity>,
|
||||
@Optional()
|
||||
private readonly auditLogService?: AuditLogService,
|
||||
@Optional()
|
||||
private readonly listRealtimeService?: ListRealtimeService,
|
||||
) {}
|
||||
|
||||
async createList(ownerId: string, createDto: CreateListDto): Promise<UserList> {
|
||||
@@ -56,7 +59,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.toUserList(savedList);
|
||||
const userList = this.toUserList(savedList);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, userList);
|
||||
|
||||
return userList;
|
||||
}
|
||||
|
||||
async createListFromTemplate(
|
||||
@@ -108,7 +114,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.toUserList(savedList);
|
||||
const userList = this.toUserList(savedList);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, userList);
|
||||
|
||||
return userList;
|
||||
}
|
||||
|
||||
async listLists(ownerId: string): Promise<UserList[]> {
|
||||
@@ -160,7 +169,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.toUserList(savedList);
|
||||
const userList = this.toUserList(savedList);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, userList);
|
||||
|
||||
return userList;
|
||||
}
|
||||
|
||||
async deleteList(ownerId: string, listId: string): Promise<{ message: string }> {
|
||||
@@ -180,6 +192,8 @@ export class ListsService {
|
||||
metadata,
|
||||
});
|
||||
|
||||
this.listRealtimeService?.publishDeleted(ownerId, listId);
|
||||
|
||||
return { message: 'List deleted.' };
|
||||
}
|
||||
|
||||
@@ -209,7 +223,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.getList(ownerId, listId);
|
||||
const updatedList = await this.getList(ownerId, listId);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, updatedList);
|
||||
|
||||
return updatedList;
|
||||
}
|
||||
|
||||
async updateItem(
|
||||
@@ -279,7 +296,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.getList(ownerId, listId);
|
||||
const updatedList = await this.getList(ownerId, listId);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, updatedList);
|
||||
|
||||
return updatedList;
|
||||
}
|
||||
|
||||
async deleteItem(
|
||||
@@ -315,7 +335,10 @@ export class ListsService {
|
||||
},
|
||||
});
|
||||
|
||||
return this.getList(ownerId, listId);
|
||||
const updatedList = await this.getList(ownerId, listId);
|
||||
this.listRealtimeService?.publishSnapshot(ownerId, updatedList);
|
||||
|
||||
return updatedList;
|
||||
}
|
||||
|
||||
private async findOwnedList(
|
||||
|
||||
Reference in New Issue
Block a user