Files
forum/plugins/chat/assets/javascripts/discourse/services/chat-channel-info-route-origin-manager.js
David Taylor b3015f51ca DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00

35 lines
799 B
JavaScript

import Service from "@ember/service";
import { isEmpty } from "@ember/utils";
import KeyValueStore from "discourse/lib/key-value-store";
export const BACK_KEY = "back";
export const INFO_ROUTE_NAMESPACE = "discourse_chat_info_route";
export const ORIGINS = {
channel: "channel",
browse: "browse",
};
export default class ChatChannelInfoRouteOriginManager extends Service {
store = new KeyValueStore(INFO_ROUTE_NAMESPACE);
get origin() {
const origin = this.store.getObject(BACK_KEY);
if (origin) {
return ORIGINS[origin];
}
}
set origin(value) {
this.store.setObject({ key: BACK_KEY, value });
}
get isBrowse() {
return this.origin === ORIGINS.browse;
}
get isChannel() {
return this.origin === ORIGINS.channel || isEmpty(this.origin);
}
}