This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/chat/assets/javascripts/discourse/services/full-page-chat.js
Joffrey JAFFEUX 21570410ab
FIX: makes sidebar links respect drawer mode (#18918)
Clicking a link of the sidebar will now open the drawer and load the correct channel.

This solution should correctly solve these cases:

closing drawer, clicking sidebar channel, should open the drawer on correct channel
visiting /chat then visiting / and clicking sidebar channel, should open full page chat on correct channel
2022-11-08 16:23:13 +01:00

36 lines
721 B
JavaScript

import Service, { inject as service } from "@ember/service";
import { defaultHomepage } from "discourse/lib/utilities";
export default class FullPageChat extends Service {
@service router;
_previousURL = null;
_isActive = false;
enter(previousURL) {
this._previousURL = previousURL;
this._isActive = true;
}
exit() {
if (this.isDestroyed || this.isDestroying) {
return;
}
this._isActive = false;
let previousURL = this._previousURL;
if (!previousURL || previousURL === "/") {
previousURL = this.router.urlFor(`discovery.${defaultHomepage()}`);
}
this._previousURL = null;
return previousURL;
}
get isActive() {
return this._isActive;
}
}