2018-09-12 11:16:18 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2017-07-24 11:13:53 -04:00
|
|
|
|
|
|
|
export default Discourse.Route.extend({
|
2017-10-03 05:42:07 -04:00
|
|
|
beforeModel(transition) {
|
|
|
|
if (this.currentUser) {
|
|
|
|
const secret = transition.params.transcript.secret;
|
2017-07-24 11:13:53 -04:00
|
|
|
|
2018-09-12 11:16:18 -04:00
|
|
|
this.replaceWith("discovery.latest").then(e => {
|
|
|
|
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
|
2017-07-24 11:13:53 -04:00
|
|
|
Ember.run.next(() => {
|
2017-10-03 05:42:07 -04:00
|
|
|
ajax(`chat-transcript/${secret}`).then(result => {
|
2018-09-12 11:16:18 -04:00
|
|
|
e.send(
|
|
|
|
"createNewTopicViaParams",
|
|
|
|
null,
|
|
|
|
result["content"],
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null
|
|
|
|
);
|
2017-07-24 11:13:53 -04:00
|
|
|
}, popupAjaxError);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.session.set("shouldRedirectToUrl", window.location.href);
|
2018-09-12 11:16:18 -04:00
|
|
|
this.replaceWith("login");
|
2017-07-24 11:13:53 -04:00
|
|
|
}
|
|
|
|
}
|
2017-10-03 05:42:07 -04:00
|
|
|
});
|