Skip to content

Commit 8da400a

Browse files
committed
refactor
1 parent c549b29 commit 8da400a

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,17 @@ qx.Class.define("osparc.data.model.ConversationSupport", {
161161
});
162162
},
163163

164+
setReadBy: function(isRead) {
165+
osparc.store.Groups.getInstance().amIASupportUser() ? this.setReadBySupport(isRead) : this.setReadByUser(isRead);
166+
},
167+
168+
getReadBy: function() {
169+
return osparc.store.Groups.getInstance().amIASupportUser() ? this.getReadBySupport() : this.getReadByUser();
170+
},
171+
164172
markAsRead: function() {
165173
osparc.store.ConversationsSupport.getInstance().markAsRead(this.getConversationId())
166-
.then(() => {
167-
if (osparc.store.Groups.getInstance().amIASupportUser()) {
168-
this.setReadBySupport(true);
169-
} else {
170-
this.setReadByUser(true);
171-
}
172-
});
174+
.then(() => this.setReadBy(true));
173175
},
174176

175177
markAsResolved: function() {
@@ -190,11 +192,7 @@ qx.Class.define("osparc.data.model.ConversationSupport", {
190192
const userGroupId = message.getUserGroupId();
191193
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
192194
if (userGroupId !== myGroupId) {
193-
if (osparc.store.Groups.getInstance().amIASupportUser()) {
194-
this.setReadBySupport(false);
195-
} else {
196-
this.setReadByUser(false);
197-
}
195+
this.setReadBy(false);
198196
}
199197
return message;
200198
},

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,7 @@ qx.Class.define("osparc.support.Conversation", {
140140
// keep conversation read
141141
const conversation = this.getConversation();
142142
if (conversation) {
143-
if (osparc.store.Groups.getInstance().amIASupportUser()) {
144-
conversation.setReadBySupport(true);
145-
} else {
146-
conversation.setReadByUser(true);
147-
}
148-
console.log("marked as read:", message);
143+
conversation.setReadBy(true);
149144
}
150145
},
151146

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,7 @@ qx.Class.define("osparc.support.Conversations", {
158158
conversationItem.show();
159159
break;
160160
case "unread":
161-
if (osparc.store.Groups.getInstance().amIASupportUser()) {
162-
if (conversation.getReadBySupport()) {
163-
conversationItem.exclude();
164-
} else {
165-
conversationItem.show();
166-
}
167-
} else {
168-
if (conversation.getReadByUser()) {
169-
conversationItem.exclude();
170-
} else {
171-
conversationItem.show();
172-
}
173-
}
161+
conversation.getReadBy() ? conversationItem.exclude() : conversationItem.show();
174162
break;
175163
case "open":
176164
if (conversation.getResolved() === false) {

0 commit comments

Comments
 (0)