Skip to content

Commit ac04f0e

Browse files
committed
refactor
1 parent dd9d117 commit ac04f0e

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,34 @@ qx.Class.define("osparc.support.Conversation", {
263263
.finally(() => loadMoreMessages.setFetching(false));
264264
},
265265

266-
addSystemMessage: function(message) {
266+
// type can be "askAQuestion", "bookACall" or "reportOEC"
267+
addSystemMessage: function(type) {
268+
type = type || "askAQuestion";
269+
267270
const now = new Date();
268271
const systemMessage = {
269-
"content": message,
270272
"conversationId": null,
271273
"created": now.toISOString(),
272274
"messageId": `system-${now.getTime()}`,
273275
"modified": now.toISOString(),
274276
"type": "MESSAGE",
275277
"userGroupId": "system",
276278
};
279+
let msg = "Hi " + osparc.auth.Data.getInstance().getUserName() + ",";
280+
switch (type) {
281+
case "askAQuestion":
282+
msg += "\nHave a question or feedback?\nWe are happy to assist!";
283+
break;
284+
case "bookACall":
285+
msg += "\nLet us know what your availability is and we will get back to you shortly to schedule a meeting.";
286+
break;
287+
case "reportOEC":
288+
msg = "";
289+
break;
290+
}
291+
if (msg) {
292+
systemMessage["content"] = msg;
293+
}
277294
this.addMessage(systemMessage);
278295
},
279296

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,18 @@ qx.Class.define("osparc.support.ConversationPage", {
153153
const title = this.getChildControl("conversation-title");
154154
const conversationContent = this.getChildControl("conversation-content");
155155
conversationContent.clearAllMessages();
156-
let msg = "Hi " + osparc.auth.Data.getInstance().getUserName() + ",";
157156
switch (type) {
158157
case "askAQuestion":
159158
title.setValue(this.tr("Ask a Question"));
160-
msg += "\nHave a question or feedback?\nWe are happy to assist!";
161159
break;
162160
case "bookACall":
163161
title.setValue(this.tr("Book a Call"));
164-
msg += "\nLet us know what your availability is and we will get back to you shortly to schedule a meeting.";
165162
break;
166163
case "reportOEC":
167164
title.setValue(this.tr("Report an Error"));
168-
msg = null;
169165
break;
170166
}
171-
if (msg) {
172-
conversationContent.addSystemMessage(msg);
173-
}
167+
conversationContent.addSystemMessage(type);
174168
},
175169

176170
__applyConversation: function(conversation) {

0 commit comments

Comments
 (0)