Skip to content

Commit 450ca4a

Browse files
committed
list conversations
1 parent af2c864 commit 450ca4a

File tree

3 files changed

+25
-129
lines changed

3 files changed

+25
-129
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ qx.Class.define("osparc.support.Conversation", {
171171
setTimeout(() => {
172172
this.__messageScroll.scrollToY(this.__messageScroll.getChildControl("pane").getScrollMaxY());
173173
}, 50);
174-
175-
this.__updateMessagesNumber();
176174
},
177175

178176
deleteMessage: function(message) {
@@ -191,8 +189,6 @@ qx.Class.define("osparc.support.Conversation", {
191189
if (controlIndex > -1) {
192190
this.__messagesList.remove(children[controlIndex]);
193191
}
194-
195-
this.__updateMessagesNumber();
196192
},
197193

198194
updateMessage: function(message) {

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

Lines changed: 22 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -29,141 +29,39 @@ qx.Class.define("osparc.support.ConversationListItem", {
2929

3030
properties: {
3131
conversationId: {
32-
check: "Number",
32+
check: "String",
3333
init: null,
3434
nullable: false,
3535
event: "changeConversationId",
3636
apply: "__applyConversationId",
3737
},
38-
39-
/*
40-
thumbnail: {
41-
check: "String",
42-
init: null,
43-
nullable: false,
44-
event: "changeThumbnail",
45-
},
46-
47-
title: {
48-
check: "String",
49-
init: null,
50-
nullable: false,
51-
event: "changeTitle",
52-
},
53-
54-
author: {
55-
check: "String",
56-
init: null,
57-
nullable: false,
58-
event: "changeAuthor",
59-
},
60-
61-
lastModified: {
62-
check: "Date",
63-
init: null,
64-
nullable: false,
65-
event: "changeLastModified",
66-
},
67-
*/
68-
},
69-
70-
statics: {
71-
GRID_POS: {
72-
THUMBNAIL: {
73-
row: 0,
74-
column: 0,
75-
rowSpan: 2,
76-
},
77-
TITLE: {
78-
row: 0,
79-
column: 1,
80-
colSpan: 2,
81-
},
82-
AUTHOR: {
83-
row: 1,
84-
column: 1,
85-
},
86-
LAST_MODIFIED: {
87-
row: 1,
88-
column: 2,
89-
},
90-
BUTTON: {
91-
row: 0,
92-
column: 3,
93-
rowSpan: 2
94-
},
95-
}
9638
},
9739

9840
members: {
99-
/*
100-
_createChildControlImpl: function(id) {
101-
let control;
102-
switch (id) {
103-
case "thumbnail":
104-
control = new qx.ui.basic.Image().set({
105-
alignY: "middle",
106-
scale: true,
107-
allowGrowX: true,
108-
allowGrowY: true,
109-
allowShrinkX: true,
110-
allowShrinkY: true,
111-
maxWidth: 32,
112-
maxHeight: 32
113-
});
114-
this._add(control, this.self().GRID_POS.THUMBNAIL);
115-
break;
116-
case "title":
117-
control = new qx.ui.basic.Label().set({
118-
font: "text-14",
119-
alignY: "middle",
120-
});
121-
this._add(control, this.self().GRID_POS.TITLE);
122-
break;
123-
case "author":
124-
control = new qx.ui.basic.Label().set({
125-
font: "text-13"
126-
});
127-
this._add(control, this.self().GRID_POS.AUTHOR);
128-
break;
129-
case "author":
130-
control = new qx.ui.basic.Label().set({
131-
font: "text-13"
132-
});
133-
this._add(control, this.self().GRID_POS.LAST_MODIFIED);
134-
break;
135-
case "enter-button":
136-
control = new qx.ui.form.Button().set({
137-
icon: "@FontAwesome5Solid/info/14"
138-
});
139-
this._add(control, this.self().GRID_POS.BUTTON);
140-
break;
141-
}
142-
143-
return control || this.base(arguments, id);
144-
},
145-
*/
146-
14741
__applyConversationId: function(conversationId) {
148-
Promise.all([
149-
osparc.store.ConversationsSupport.getInstance().getConversation(conversationId),
150-
osparc.store.ConversationsSupport.getInstance().getLastMessage(conversationId)
151-
])
152-
.then(([conversation, lastMessages]) => {
153-
if (conversation) {
154-
this.set({
155-
thumbnail: conversation.thumbnail,
156-
title: conversation.title,
157-
author: conversation.author,
158-
lastModified: conversation.lastModified,
159-
});
160-
}
161-
if (lastMessages && lastMessages.length) {
42+
osparc.store.ConversationsSupport.getInstance().getLastMessage(conversationId)
43+
.then(lastMessages => {
44+
if (lastMessages && lastMessages.length) {
45+
this.getChildControl("thumbnail").set({
46+
decorator: "rounded",
47+
});
48+
const lastMessage = lastMessages[0];
49+
const date = osparc.utils.Utils.formatDateAndTime(new Date(lastMessage.created));
16250
this.set({
163-
title: lastMessages[0].title,
164-
author: lastMessages[0].author,
165-
lastModified: lastMessages[0].lastModified,
51+
title: lastMessage.content,
52+
subtitle: date,
16653
});
54+
55+
const userGroupId = lastMessage.userGroupId;
56+
osparc.store.Users.getInstance().getUser(userGroupId)
57+
.then(user => {
58+
if (user) {
59+
this.set({
60+
thumbnail: user.getThumbnail(),
61+
subtitle: user.getLabel() + " - " + date,
62+
});
63+
}
64+
});
16765
}
16866
});
16967
},

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ qx.Class.define("osparc.support.Conversations", {
165165
return null;
166166
}
167167

168-
const conversationListItem = new osparc.support.ConversationListItem(conversationData["conversationId"]);
168+
const conversationListItem = new osparc.support.ConversationListItem();
169+
conversationListItem.setConversationId(conversationData["conversationId"]);
170+
169171
const conversationsLayout = this.getChildControl("conversations-layout");
170172
conversationsLayout.add(conversationListItem);
171173

0 commit comments

Comments
 (0)