Skip to content

Commit c8206ae

Browse files
committed
refactor
1 parent 3447ebd commit c8206ae

File tree

1 file changed

+10
-6
lines changed
  • services/static-webserver/client/source/class/osparc/conversation

1 file changed

+10
-6
lines changed

services/static-webserver/client/source/class/osparc/conversation/Conversation.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,21 @@ qx.Class.define("osparc.conversation.Conversation", {
227227
.finally(() => this.__loadMoreMessages.setFetching(false));
228228
},
229229

230-
addMessage: function(message) {
231-
// it's not provided by the backend
232-
message["projectId"] = this.__studyData["uuid"];
233-
234-
this.__messages.push(message);
235-
230+
__updateMessagesNumber: function() {
236231
const nMessages = this.__messages.filter(msg => msg["type"] === "MESSAGE").length;
237232
if (nMessages === 1) {
238233
this.__messagesTitle.setValue(this.tr("1 Message"));
239234
} else if (nMessages > 1) {
240235
this.__messagesTitle.setValue(nMessages + this.tr(" Messages"));
241236
}
237+
},
238+
239+
addMessage: function(message) {
240+
// it's not provided by the backend
241+
message["projectId"] = this.__studyData["uuid"];
242+
243+
this.__messages.push(message);
244+
this.__updateMessagesNumber();
242245

243246
let control = null;
244247
switch (message["type"]) {
@@ -261,6 +264,7 @@ qx.Class.define("osparc.conversation.Conversation", {
261264
if (messageIndex !== -1) {
262265
this.__messages.splice(messageIndex, 1);
263266
}
267+
this.__updateMessagesNumber();
264268

265269
console.log(this.__messagesList.getChildren());
266270
},

0 commit comments

Comments
 (0)