Skip to content

Commit cc93862

Browse files
committed
refactor
1 parent 8da400a commit cc93862

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

services/static-webserver/client/source/class/osparc/conversation/MessageUI.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ qx.Class.define("osparc.conversation.MessageUI", {
3636
});
3737
},
3838

39-
statics: {
40-
isMyMessage: function(message) {
41-
if (message.getUserGroupId() === osparc.data.model.Message.SYSTEM_MESSAGE_ID) {
42-
return false;
43-
}
44-
return message && osparc.auth.Data.getInstance().getGroupId() === message.getUserGroupId();
45-
}
46-
},
47-
4839
events: {
4940
"messageUpdated": "qx.event.type.Data",
5041
"messageDeleted": "qx.event.type.Data",
@@ -61,7 +52,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
6152

6253
members: {
6354
_createChildControlImpl: function(id) {
64-
const isMyMessage = this.self().isMyMessage(this.getMessage());
55+
const isMyMessage = osparc.data.model.Message.isMyMessage(this.getMessage());
6556
let control;
6657
switch (id) {
6758
case "avatar":
@@ -154,7 +145,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
154145

155146
const avatar = this.getChildControl("avatar");
156147
const userName = this.getChildControl("user-name");
157-
if (message.getUserGroupId() === osparc.data.model.Message.SYSTEM_MESSAGE_ID) {
148+
if (osparc.data.model.Message.isSupportMessage(message)) {
158149
userName.setValue("Support");
159150
} else {
160151
osparc.store.Users.getInstance().getUser(message.getUserGroupId())
@@ -168,7 +159,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
168159
});
169160
}
170161

171-
if (this.self().isMyMessage(message)) {
162+
if (osparc.data.model.Message.isMyMessage(message)) {
172163
const menuButton = this.getChildControl("menu-button");
173164

174165
const menu = new qx.ui.menu.Menu().set({

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ qx.Class.define("osparc.data.model.ConversationSupport", {
189189
this.__evalFirstAndLastMessage();
190190

191191
// mark conversation as unread if the message is from the other party
192-
const userGroupId = message.getUserGroupId();
193-
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
194-
if (userGroupId !== myGroupId) {
192+
if (osparc.data.model.Message.isMyMessage(message)) {
195193
this.setReadBy(false);
196194
}
197195
return message;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ qx.Class.define("osparc.data.model.Message", {
9292
// oldest first: higher in the list. Latest at the bottom
9393
messages.sort((a, b) => a.getCreated() - b.getCreated());
9494
},
95+
96+
isSupportMessage: function(message) {
97+
return message.getUserGroupId() === osparc.data.model.Message.SYSTEM_MESSAGE_ID;
98+
},
99+
100+
isMyMessage: function(message) {
101+
if (osparc.data.model.Message.isSupportMessage(message)) {
102+
return false;
103+
}
104+
return message && osparc.auth.Data.getInstance().getGroupId() === message.getUserGroupId();
105+
},
95106
},
96107

97108
members: {

0 commit comments

Comments
 (0)