From 248c11454716e55387df0092955e22348a88f950 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 26 Feb 2022 20:35:17 -0500 Subject: [PATCH] chat: Omit undefined `authorId`, `displayName` in JSON obj --- src/static/js/ChatMessage.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/static/js/ChatMessage.js b/src/static/js/ChatMessage.js index d7ff680d1..a627f88f9 100644 --- a/src/static/js/ChatMessage.js +++ b/src/static/js/ChatMessage.js @@ -88,13 +88,10 @@ class ChatMessage { // TODO: Delete this method once users are unlikely to roll back to a version of Etherpad that // doesn't support authorId and displayName. toJSON() { - return { - ...this, - authorId: undefined, - displayName: undefined, - userId: this.authorId, - userName: this.displayName, - }; + const {authorId, displayName, ...obj} = this; + obj.userId = authorId; + obj.userName = displayName; + return obj; } }