23 lines
604 B
JavaScript
23 lines
604 B
JavaScript
import Route from '@ember/routing/route';
|
|
import { service } from '@ember/service';
|
|
|
|
export default class ConversationRoute extends Route {
|
|
@service session;
|
|
@service store;
|
|
|
|
beforeModel(transition) {
|
|
this.session.requireAuthentication(transition, 'login');
|
|
}
|
|
|
|
async model({ id }) {
|
|
const [conversation, agents] = await Promise.all([
|
|
this.store.findRecord('chat-conversation', id, {
|
|
include: 'messages.attachments',
|
|
reload: true,
|
|
}),
|
|
this.store.query('chat-agent', { 'page[size]': 1 }),
|
|
]);
|
|
return { conversation, assistant: agents[0] };
|
|
}
|
|
}
|