mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
This commit is expanding on previous work making everything chat working through an URL. Improves drawer templates to be all URLs Implements some kind of router for the drawer Removes few remaining actions for opening channels
32 lines
825 B
JavaScript
32 lines
825 B
JavaScript
import DiscourseRoute from "discourse/routes/discourse";
|
|
import { inject as service } from "@ember/service";
|
|
|
|
export default class ChatIndexRoute extends DiscourseRoute {
|
|
@service chat;
|
|
@service chatChannelsManager;
|
|
@service router;
|
|
|
|
redirect() {
|
|
// Always want the channel index on mobile.
|
|
if (this.site.mobileView) {
|
|
return;
|
|
}
|
|
|
|
// We are on desktop. Check for a channel to enter and transition if so
|
|
const id = this.chat.getIdealFirstChannelId();
|
|
if (id) {
|
|
return this.chatChannelsManager.find(id).then((c) => {
|
|
return this.router.transitionTo("chat.channel", ...c.routeModels);
|
|
});
|
|
} else {
|
|
return this.router.transitionTo("chat.browse");
|
|
}
|
|
}
|
|
|
|
model() {
|
|
if (this.site.mobileView) {
|
|
return this.chatChannelsManager.channels;
|
|
}
|
|
}
|
|
}
|