FIX: do not reload identical route in drawer (#27992)

This is a performance optimisation to prevent the same route to keep reloading the same endpoint.

No tests as it's not changing behavior and is also quite complex to test efficiently.
This commit is contained in:
Joffrey JAFFEUX 2024-07-19 22:27:32 +02:00 committed by GitHub
parent 346c9116b5
commit 8b18fd1556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,10 @@ export default class ChatRoute extends DiscourseRoute {
) {
transition.abort();
if (this.chatDrawerRouter.currentRouteName === transition.targetName) {
return;
}
let url = transition.intent.url;
if (transition.targetName.startsWith("chat.channel")) {
url ??= this.router.urlFor(

View File

@ -146,6 +146,7 @@ export default class ChatDrawerRouter extends Service {
this.drawerRoute = ROUTES[route.name];
this.params = this.drawerRoute?.extractParams?.(route) || route.params;
this.component = this.drawerRoute?.name || ChatDrawerRoutesChannels;
this.currentRouteName = route.name;
this.drawerRoute.activate?.(route);
}

View File

@ -26,6 +26,7 @@ export default class ChatStateManager extends Service {
@service chatHistory;
@service router;
@service site;
@service chatDrawerRouter;
@tracked isSidePanelExpanded = false;
@tracked isDrawerExpanded = false;
@ -118,6 +119,7 @@ export default class ChatStateManager extends Service {
}
});
this.chatDrawerRouter.currentRouteName = null;
this.isDrawerActive = false;
this.isDrawerExpanded = false;
this.chat.updatePresence();