diff --git a/src/controllers/UserWebSocketActions.ts b/src/controllers/UserWebSocketActions.ts index 6ccb8ff..a806e7a 100644 --- a/src/controllers/UserWebSocketActions.ts +++ b/src/controllers/UserWebSocketActions.ts @@ -137,6 +137,15 @@ export class UserWebSocketActions { } + /** + * Propagate the update of a conversation message + * + * @param msgID Message ID + */ + public static async UpdatedConversationMessage(msgID: number) { + console.info("Update conversation message " + msgID); + } + /** * Propagate the creation of a new comment * @@ -195,8 +204,9 @@ EventsHelper.Listen("updated_number_notifications", async (e) => await UserWebSo // When we get a new number of unread conversations EventsHelper.Listen("updated_number_unread_conversations", async (e) => await UserWebSocketActions.SendNewUnreadConversationsCount(e.usersID)); -// When a new message is sent +// When a new message is sent / updated EventsHelper.Listen("sent_conversation_message", async (e) => await UserWebSocketActions.SentNewConversationMessage(e.msg)); +EventsHelper.Listen("conv_message_updated", async (e) => await UserWebSocketActions.UpdatedConversationMessage(e.msgId)); // When a comment is created / updated / deleted EventsHelper.Listen("comment_created", async (e) => await UserWebSocketActions.CreatedNewComment(e.comment)) diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 7c7994d..7740b47 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -522,6 +522,10 @@ export class ConversationsHelper { message: newContent } }); + + await EventsHelper.Emit("conv_message_updated", { + msgId: messageID + }); } /** diff --git a/src/helpers/EventsHelper.ts b/src/helpers/EventsHelper.ts index 9090562..e5f3beb 100644 --- a/src/helpers/EventsHelper.ts +++ b/src/helpers/EventsHelper.ts @@ -29,6 +29,11 @@ export interface SentNewConversationMessageEvent { msg: ConversationMessage } +// When a conversation message is updated +export interface UpdatedConversationMessageEvent { + msgId: number +} + // When a comment is created export interface CommentCreatedEvent { comment: Comment @@ -52,6 +57,7 @@ export interface EventsMap { "updated_number_notifications": UpdatedNotificationsNumberEvent, "updated_number_unread_conversations": UpdateNumberUnreadConversationsEvent, "sent_conversation_message": SentNewConversationMessageEvent, + "conv_message_updated": UpdatedConversationMessageEvent, "comment_created": CommentCreatedEvent, "comment_updated": CommentUpdatedEvent, "comment_deleted": CommentDeletedEvent,