Skip to content

Commit b83fc0b

Browse files
committed
refactor
1 parent 285c718 commit b83fc0b

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ qx.Class.define("osparc.study.Conversation", {
2929
this.__studyData = studyData;
3030
this.__messages = [];
3131

32-
if (conversationData) {
33-
const conversation = new osparc.data.model.Conversation(conversationData, this.__studyData);
34-
this.setConversation(conversation);
35-
this.setLabel(conversationData["name"]);
36-
} else {
37-
this.setLabel(this.tr("new"));
38-
}
39-
4032
this._setLayout(new qx.ui.layout.VBox(5));
4133

4234
this.set({
@@ -51,7 +43,13 @@ qx.Class.define("osparc.study.Conversation", {
5143

5244
this.__buildLayout();
5345

54-
this.__reloadMessages();
46+
if (conversationData) {
47+
const conversation = new osparc.data.model.Conversation(conversationData, this.__studyData);
48+
this.setConversation(conversation);
49+
this.setLabel(conversationData["name"]);
50+
} else {
51+
this.setLabel(this.tr("new"));
52+
}
5553
},
5654

5755
properties: {
@@ -74,6 +72,8 @@ qx.Class.define("osparc.study.Conversation", {
7472
__loadMoreMessages: null,
7573

7674
__applyConversation: function(conversation) {
75+
this.__reloadMessages(true);
76+
7777
conversation.addListener("messageAdded", e => {
7878
const message = e.getData();
7979
this.addMessage(message);
@@ -196,10 +196,12 @@ qx.Class.define("osparc.study.Conversation", {
196196

197197
const addMessage = new osparc.conversation.AddMessage().set({
198198
studyData: this.__studyData,
199-
conversationId: this.getConversationId(),
200199
enabled: osparc.data.model.Study.canIWrite(this.__studyData["accessRights"]),
201200
paddingLeft: 10,
202201
});
202+
this.bind("conversation", addMessage, "conversationId", {
203+
converter: conversation => conversation ? conversation.getConversationId() : null
204+
});
203205
addMessage.addListener("addMessage", e => {
204206
const content = e.getData();
205207
const conversation = this.getConversation();

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ qx.Class.define("osparc.support.Conversation", {
4444
event: "changeConversation",
4545
apply: "__applyConversation",
4646
},
47-
48-
studyId: {
49-
check: "String",
50-
init: null,
51-
nullable: true,
52-
event: "changeStudyId",
53-
apply: "__applyStudyId",
54-
},
5547
},
5648

5749
statics: {

0 commit comments

Comments
 (0)