Skip to content

Commit 529ab3c

Browse files
committed
minor
1 parent d453cbf commit 529ab3c

File tree

1 file changed

+12
-1
lines changed
  • services/static-webserver/client/source/class/osparc/conversation

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ qx.Class.define("osparc.conversation.Conversation", {
245245
// it's not provided by the backend
246246
message["projectId"] = this.__studyData["uuid"];
247247

248+
// Add the message in the messages array
248249
this.__messages.push(message);
249-
this.__updateMessagesNumber();
250250

251+
// Add the UI element to the messages list
251252
let control = null;
252253
switch (message["type"]) {
253254
case "MESSAGE":
@@ -260,6 +261,8 @@ qx.Class.define("osparc.conversation.Conversation", {
260261
if (control) {
261262
this.__messagesList.add(control);
262263
}
264+
265+
this.__updateMessagesNumber();
263266
},
264267

265268
deleteMessage: function(message) {
@@ -283,6 +286,14 @@ qx.Class.define("osparc.conversation.Conversation", {
283286
},
284287

285288
updateMessage: function(message) {
289+
// Replace the message in the messages array
290+
const messageIndex = this.__messages.findIndex(msg => msg["messageId"] === message["messageId"]);
291+
if (messageIndex === -1) {
292+
return;
293+
}
294+
this.__messages[messageIndex] = message;
295+
296+
// Update the UI element from the messages list
286297
this.__messagesList.getChildren().forEach(control => {
287298
if ("getMessage" in control && control.getMessage()["messageId"] === message["messageId"]) {
288299
control.setMessage(message);

0 commit comments

Comments
 (0)