Skip to content

Commit 2a2b5d0

Browse files
committed
noConversationsLabel
1 parent fea3f4c commit 2a2b5d0

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,22 @@ qx.Class.define("osparc.support.Conversations", {
2424

2525
this._setLayout(new qx.ui.layout.VBox(10));
2626

27+
this.__noConversationsLabel = new qx.ui.basic.Label("No conversations yet — your messages will appear here.").set({
28+
padding: 5,
29+
});
2730
this.__conversationListItems = [];
2831

2932
this.__fetchConversations();
3033

3134
this.__listenToNewConversations();
3235
},
3336

34-
statics: {
35-
TYPES: {
36-
SUPPORT: "SUPPORT",
37-
},
38-
39-
CHANNELS: {
40-
CONVERSATION_CREATED: "conversation:created",
41-
CONVERSATION_UPDATED: "conversation:updated",
42-
CONVERSATION_DELETED: "conversation:deleted",
43-
CONVERSATION_MESSAGE_CREATED: "conversation:message:created",
44-
CONVERSATION_MESSAGE_UPDATED: "conversation:message:updated",
45-
CONVERSATION_MESSAGE_DELETED: "conversation:message:deleted",
46-
},
47-
},
48-
4937
events: {
5038
"openConversation": "qx.event.type.Data",
5139
},
5240

5341
members: {
42+
__noConversationsLabel: null,
5443
__conversationListItems: null,
5544

5645
_createChildControlImpl: function(id) {
@@ -83,6 +72,9 @@ qx.Class.define("osparc.support.Conversations", {
8372
.then(conversations => {
8473
if (conversations.length) {
8574
conversations.forEach(conversation => this.__addConversation(conversation));
75+
} else {
76+
// No conversations found
77+
this.getChildControl("conversations-layout").add(this.__noConversationsLabel);
8678
}
8779
})
8880
.finally(() => {
@@ -99,6 +91,12 @@ qx.Class.define("osparc.support.Conversations", {
9991
},
10092

10193
__addConversation: function(conversation) {
94+
const conversationsLayout = this.getChildControl("conversations-layout");
95+
// remove the noConversationsLabel
96+
if (conversationsLayout && conversationsLayout.getChildren().indexOf(this.__noConversationsLabel) > -1) {
97+
conversationsLayout.remove(this.__noConversationsLabel);
98+
}
99+
102100
// ignore it if it was already there
103101
const conversationId = conversation.getConversationId();
104102
const conversationItemFound = this.__getConversationItem(conversationId);
@@ -109,10 +107,7 @@ qx.Class.define("osparc.support.Conversations", {
109107
const conversationListItem = new osparc.support.ConversationListItem();
110108
conversationListItem.setConversation(conversation);
111109
conversationListItem.addListener("tap", () => this.fireDataEvent("openConversation", conversationId, this));
112-
113-
const conversationsLayout = this.getChildControl("conversations-layout");
114110
conversationsLayout.add(conversationListItem);
115-
116111
this.__conversationListItems.push(conversationListItem);
117112

118113
return conversationListItem;

0 commit comments

Comments
 (0)