Files
discourse-chat-integration/assets/javascripts/discourse/routes/transcript.js.es6
T

24 lines
774 B
JavaScript
Raw Normal View History

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