Skip to content

Commit

Permalink
fix: : enhance infinite loading of chat when logged out in chat drawe…
Browse files Browse the repository at this point in the history
…r - EXO-73721

Before this fix, the fix applied in 57e7e61 is not applied in chatDrawer
This commit reuse the same modifications and applies in chatDrawer

We think about stopping requests after a certain time. But for the moment we keep as is, so that, when user go back online, the connection is restored.
It can be challenged in the future if needed.
  • Loading branch information
rdenarie committed Aug 9, 2024
1 parent 2eac39d commit 763cb95
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export default {
chatLink: `/portal/${eXo.env.portal.portalName}/chat`,
titleActionComponents: miniChatTitleActionComponents,
isExternal: false,
unresolvedRequests: 0
unresolvedRequests: 0,
failingRequests: 1,
refreshContactsInterval: 0
};
},
computed: {
Expand Down Expand Up @@ -349,9 +351,7 @@ export default {
});
},
userLoggedout() {
if (!chatWebSocket.isConnected()) {
this.changeUserStatusToOffline();
}
this.changeUserStatusToOffline();
},
totalUnreadMessagesUpdated(e) {
const totalUnreadMsg = e.detail ? e.detail.data.totalUnreadMsg : e.totalUnreadMsg;
Expand Down Expand Up @@ -413,9 +413,10 @@ export default {
});
const thiss = this;
if (this.userSettings.offlineDelay) {
setInterval(
clearInterval(this.refreshContactsInterval);
this.refreshContactsInterval = setInterval(
function() {thiss.refreshContacts(true);},
this.userSettings.offlineDelay);
this.userSettings.offlineDelay * this.failingRequests);
}
},
initChatRooms(chatRoomsData) {
Expand Down Expand Up @@ -474,6 +475,7 @@ export default {
this.unresolvedRequests++;
chatServices.getOnlineUsers().then(users => {
chatServices.getUserChatRooms(this.userSettings, users).then(chatRoomsData => {
this.failingRequests = 1;
this.addRooms(chatRoomsData.rooms);
if (!keepSelectedContact && this.selectedContact) {
const contactToChange = this.contactList.find(contact => contact.room === this.selectedContact.room || contact.user === this.selectedContact.user || contact.room === this.selectedContact);
Expand All @@ -482,6 +484,13 @@ export default {
}
}
});
}).catch(() => {
this.failingRequests++;
clearInterval(this.refreshContactsInterval);
const cloneOfThis = this;
this.refreshContactsInterval = setInterval(
function () { cloneOfThis.refreshContacts(true); },
cloneOfThis.userSettings.offlineDelay * cloneOfThis.failingRequests);
}).finally(() => {
this.unresolvedRequests--;
});
Expand All @@ -497,7 +506,7 @@ export default {
});
},
changeUserStatusToOffline() {
if (this.userSettings && this.userSettings.status && !this.userSettings.originalStatus) {
if (this?.userSettings?.status && !this.userSettings.originalStatus) {
this.userSettings.originalStatus = this.userSettings.status;
}
eXo.chat.isOnline = false;
Expand Down

0 comments on commit 763cb95

Please sign in to comment.