delete thread front
This commit is contained in:
parent
ffcfc57bbe
commit
b2b0949353
@ -33,6 +33,7 @@ export interface Room {
|
||||
members: Address[];
|
||||
notSeen: number;
|
||||
threadIds: number[];
|
||||
parent_id?: number;
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
|
@ -32,6 +32,7 @@ function createRoom(options: RoomFromBack): Room {
|
||||
user: options.user,
|
||||
notSeen: options.notSeen,
|
||||
threadIds: [],
|
||||
parent_id: options.parent_id,
|
||||
};
|
||||
}
|
||||
|
||||
@ -133,9 +134,19 @@ const store = createStore<State>({
|
||||
});
|
||||
},
|
||||
removeRoom(state, payload) {
|
||||
console.log(payload);
|
||||
const roomMessageIndex = state.roomMessages.findIndex((roomM) => roomM.roomId === payload.roomId);
|
||||
state.roomMessages.splice(roomMessageIndex, 1);
|
||||
const roomIndex = state.rooms.findIndex((room) => room.id === payload.roomId);
|
||||
const roomToDelete = state.rooms[roomIndex];
|
||||
// todo debug parent_id to root_id
|
||||
// remove thread
|
||||
if (roomToDelete.roomType === RoomType.THREAD && roomToDelete.parent_id) {
|
||||
const parentRoom = roomOnId(state, roomToDelete.parent_id);
|
||||
if (parentRoom) {
|
||||
parentRoom.threadIds = parentRoom?.threadIds.filter((id) => id !== roomToDelete.id);
|
||||
}
|
||||
}
|
||||
state.rooms.splice(roomIndex, 1);
|
||||
// state.activeRoom = state.rooms[0].id;
|
||||
// router.push(`/${state.activeRoom}`);
|
||||
|
Loading…
Reference in New Issue
Block a user