diff --git a/backend/src/realtime/realtime-note/realtime-note.service.ts b/backend/src/realtime/realtime-note/realtime-note.service.ts index 19ea69b8f..1a5fb9ba6 100644 --- a/backend/src/realtime/realtime-note/realtime-note.service.ts +++ b/backend/src/realtime/realtime-note/realtime-note.service.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -49,6 +49,9 @@ export class RealtimeNoteService implements BeforeApplicationShutdown { realtimeNote.getRealtimeDoc().getCurrentContent(), realtimeNote.getRealtimeDoc().encodeStateAsUpdate(), ) + .then(() => { + realtimeNote.announceMetadataUpdate(); + }) .catch((reason) => this.logger.error(reason)); } @@ -117,7 +120,7 @@ export class RealtimeNoteService implements BeforeApplicationShutdown { const realtimeNote = this.realtimeNoteStore.find(note.id); if (!realtimeNote) return; - realtimeNote.announcePermissionChange(); + realtimeNote.announceMetadataUpdate(); const allConnections = realtimeNote.getConnections(); await this.updateOrCloseConnection(allConnections, note); } diff --git a/backend/src/realtime/realtime-note/realtime-note.spec.ts b/backend/src/realtime/realtime-note/realtime-note.spec.ts index 1635d519e..809f0687f 100644 --- a/backend/src/realtime/realtime-note/realtime-note.spec.ts +++ b/backend/src/realtime/realtime-note/realtime-note.spec.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -82,11 +82,11 @@ describe('realtime note', () => { const sendMessage2Spy = jest.spyOn(client2.getTransporter(), 'sendMessage'); const metadataMessage = { type: MessageType.METADATA_UPDATED }; - sut.announcePermissionChange(); + sut.announceMetadataUpdate(); expect(sendMessage1Spy).toHaveBeenCalledWith(metadataMessage); expect(sendMessage2Spy).toHaveBeenCalledWith(metadataMessage); sut.removeClient(client2); - sut.announcePermissionChange(); + sut.announceMetadataUpdate(); expect(sendMessage1Spy).toHaveBeenCalledTimes(2); expect(sendMessage2Spy).toHaveBeenCalledTimes(1); }); diff --git a/backend/src/realtime/realtime-note/realtime-note.ts b/backend/src/realtime/realtime-note/realtime-note.ts index c55a20415..ed8399549 100644 --- a/backend/src/realtime/realtime-note/realtime-note.ts +++ b/backend/src/realtime/realtime-note/realtime-note.ts @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) + * SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file) * * SPDX-License-Identifier: AGPL-3.0-only */ @@ -149,9 +149,10 @@ export class RealtimeNote extends EventEmitter2 { } /** - * Announce to all clients that the permissions of the note have been changed. + * Announce to all clients that the metadata of the note have been changed. + * This could for example be a permission change or a revision being saved. */ - public announcePermissionChange(): void { + public announceMetadataUpdate(): void { this.sendToAllClients({ type: MessageType.METADATA_UPDATED }); }