Skip to content

Commit 7e9dd1d

Browse files
committed
working
1 parent 3c03e2d commit 7e9dd1d

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ qx.Class.define("osparc.data.model.Conversation", {
143143
return this.__fetchLastMessagePromise;
144144
}
145145

146-
let promise = osparc.store.ConversationsSupport.getInstance().getLastMessage(this.getConversationId());
146+
let promise = osparc.store.ConversationsSupport.getInstance().fetchLastMessage(this.getConversationId());
147147
promise
148148
.then(lastMessage => {
149149
this.addMessage(lastMessage);
@@ -158,13 +158,6 @@ qx.Class.define("osparc.data.model.Conversation", {
158158
return promise;
159159
},
160160

161-
getLastMessage: function() {
162-
if (this.getMessages() && this.getMessages().length) {
163-
return Promise.resolve(this.getMessages()[0]);
164-
}
165-
return this.__fetchLastMessage();
166-
},
167-
168161
getNextMessages: function() {
169162
const params = {
170163
url: {

services/static-webserver/client/source/class/osparc/store/ConversationsSupport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ qx.Class.define("osparc.store.ConversationsSupport", {
127127
return osparc.data.Resources.fetch("conversationsSupport", "renameConversation", params);
128128
},
129129

130-
getLastMessage: function(conversationId) {
130+
fetchLastMessage: function(conversationId) {
131131
if (
132132
conversationId in this.__conversationsCached &&
133133
this.__conversationsCached[conversationId].getLastMessage()

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,23 @@ qx.Class.define("osparc.support.ConversationListItem", {
5353
},
5454

5555
__populateWithLastMessage: function() {
56-
this.getConversation().getLastMessage()
57-
.then(lastMessage => {
58-
if (lastMessage) {
59-
const date = osparc.utils.Utils.formatDateAndTime(new Date(lastMessage.created));
60-
this.set({
61-
subtitle: date,
62-
});
63-
const userGroupId = lastMessage.userGroupId;
64-
osparc.store.Users.getInstance().getUser(userGroupId)
65-
.then(user => {
66-
if (user) {
67-
this.set({
68-
thumbnail: user.getThumbnail(),
69-
subtitle: user.getLabel() + " - " + date,
70-
});
71-
}
56+
const lastMessage = this.getConversation().getLastMessage();
57+
if (lastMessage) {
58+
const date = osparc.utils.Utils.formatDateAndTime(new Date(lastMessage.created));
59+
this.set({
60+
subtitle: date,
61+
});
62+
const userGroupId = lastMessage.userGroupId;
63+
osparc.store.Users.getInstance().getUser(userGroupId)
64+
.then(user => {
65+
if (user) {
66+
this.set({
67+
thumbnail: user.getThumbnail(),
68+
subtitle: user.getLabel() + " - " + date,
7269
});
73-
}
74-
});
70+
}
71+
});
72+
}
7573
},
7674
}
7775
});

0 commit comments

Comments
 (0)