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

33 lines
944 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";
export default DiscourseRoute.extend({
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");
}
2020-09-04 07:23:28 -04:00
},
2017-10-03 05:42:07 -04:00
});