discourse-chat-integration/assets/javascripts/discourse/routes/transcript.js

33 lines
958 B
JavaScript
Raw Normal View History

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import DiscourseRoute from "discourse/routes/discourse";
2022-03-06 15:18:46 -05:00
import { next } from "@ember/runloop";
2023-01-23 13:30:48 -05:00
export default class Trascript extends DiscourseRoute {
model(params) {
2017-10-03 05:42:07 -04:00
if (this.currentUser) {
const secret = params.secret;
2020-09-04 07:23:28 -04:00
this.replaceWith("discovery.latest").then((e) => {
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
2022-03-06 15:18:46 -05:00
next(() => {
2020-09-04 07:23:28 -04:00
ajax(`chat-transcript/${secret}`).then((result) => {
e.send(
"createNewTopicViaParams",
null,
result["content"],
null,
null,
null
);
}, popupAjaxError);
});
}
});
} else {
this.session.set("shouldRedirectToUrl", window.location.href);
this.replaceWith("login");
}
2023-01-23 13:30:48 -05:00
}
}