Skip to content

Commit b70e995

Browse files
committed
newConversation
1 parent a66ceff commit b70e995

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,46 @@ qx.Class.define("osparc.study.Conversations", {
110110
},
111111

112112
__addConversations: function(conversations, studyData) {
113+
const conversationPages = [];
113114
const conversationsLayout = this.getChildControl("conversations-layout");
115+
116+
const newConversationButton = new qx.ui.form.Button().set({
117+
icon: "@FontAwesome5Solid/plus/12",
118+
toolTipText: this.tr("Add new conversation"),
119+
allowGrowX: false,
120+
backgroundColor: "transparent",
121+
});
122+
123+
const reloadConversations = () => {
124+
conversationPages.forEach(conversationPage => conversationPage.fireDataEvent("close", conversationPage));
125+
conversationsLayout.getChildControl("bar").remove(newConversationButton);
126+
this.fetchConversations(studyData);
127+
};
128+
114129
if (conversations.length === 0) {
115130
const noConversationTab = new osparc.info.Conversation(studyData);
116-
noConversationTab.setLabel(this.tr("new 1"));
117-
noConversationTab.addListener("conversationDeleted", () => {
118-
this._removeAll();
119-
this.fetchConversations(studyData);
120-
});
131+
conversationPages.push(noConversationTab);
132+
noConversationTab.setLabel(this.tr("new"));
133+
noConversationTab.addListener("conversationDeleted", () => reloadConversations());
121134
conversationsLayout.add(noConversationTab);
122135
} else {
123136
conversations.forEach(conversation => {
124137
const conversationId = conversation["conversationId"];
125138
const conversationTab = new osparc.info.Conversation(studyData, conversationId);
139+
conversationPages.push(conversationTab);
126140
conversationTab.setLabel(conversation["name"]);
127-
conversationTab.addListener("conversationDeleted", () => {
128-
this._removeAll();
129-
this.fetchConversations(studyData);
130-
});
141+
conversationTab.addListener("conversationDeleted", () => reloadConversations());
131142
conversationsLayout.add(conversationTab);
132143
});
133144
}
134145

135-
const newConversationButton = new qx.ui.form.Button().set({
136-
icon: "@FontAwesome5Solid/plus/12",
137-
toolTipText: this.tr("Add new conversation"),
138-
allowGrowX: false,
139-
backgroundColor: "transparent",
140-
});
141146
newConversationButton.addListener("execute", () => {
142147
osparc.study.Conversations.addConversation(studyData["uuid"], "new " + (conversations.length + 1))
148+
.then(() => {
149+
reloadConversations();
150+
});
143151
});
152+
144153
conversationsLayout.getChildControl("bar").add(newConversationButton);
145154
},
146155
}

0 commit comments

Comments
 (0)