1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19:22 +00:00

Create an event for deleted comments

This commit is contained in:
Pierre HUBERT 2020-04-02 18:25:23 +02:00
parent 1502906c09
commit 768b5360a3
3 changed files with 25 additions and 4 deletions

View File

@ -158,7 +158,7 @@ export class UserWebSocketActions {
/**
* Propagate comment update
*
* @param c New comment
* @param c Updated comment
*/
public static async UpdatedComment(commentID: number) {
const comment = await CommentsHelper.GetSingle(commentID);
@ -171,6 +171,15 @@ export class UserWebSocketActions {
}))
}
}
/**
* Propagage the deletion of a comment
*
* @param comment Deleted comment
*/
public static async DeletedComment(comment: Comment) {
console.log(comment);
}
}
@ -183,6 +192,7 @@ EventsHelper.Listen("updated_number_unread_conversations", async (e) => await Us
// When a new message is sent
EventsHelper.Listen("sent_conversation_message", async (e) => await UserWebSocketActions.SentNewConversationMessage(e.msg));
// When a comment is created / updated
// When a comment is created / updated / deleted
EventsHelper.Listen("comment_created", async (e) => await UserWebSocketActions.CreatedNewComment(e.comment))
EventsHelper.Listen("comment_updated", async (e) => await UserWebSocketActions.UpdatedComment(e.commentID));
EventsHelper.Listen("comment_updated", async (e) => await UserWebSocketActions.UpdatedComment(e.commentID));
EventsHelper.Listen("comment_deleted", async (e) => await UserWebSocketActions.DeletedComment(e.comment));

View File

@ -156,6 +156,11 @@ export class CommentsHelper {
await DatabaseHelper.DeleteRows(COMMENTS_TABLE, {
ID: comment.id
})
// Notify system
await EventsHelper.Emit("comment_deleted", {
comment: comment
});
}
/**

View File

@ -39,6 +39,11 @@ export interface CommentUpdatedEvent {
commentID: number
}
// When a comment is deleted
export interface CommentDeletedEvent {
comment: Comment
}
/**
* Global map of all possible events
*/
@ -48,7 +53,8 @@ export interface EventsMap {
"updated_number_unread_conversations": UpdateNumberUnreadConversationsEvent,
"sent_conversation_message": SentNewConversationMessageEvent,
"comment_created": CommentCreatedEvent,
"comment_updated": CommentUpdatedEvent
"comment_updated": CommentUpdatedEvent,
"comment_deleted": CommentDeletedEvent,
}
export class EventsHelper {