Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Created April 28, 2020 08:46
Show Gist options
  • Save lolmaus/ec5ccf64509a1e87b63d53190af2386f to your computer and use it in GitHub Desktop.
Save lolmaus/ec5ccf64509a1e87b63d53190af2386f to your computer and use it in GitHub Desktop.
ru ember js help
async beforeModel() {
const curUser = this.get('currentUser.user');
const curCompany = curUser.get('currentCompany');
const { current_conversation_id } = this.paramsFor('messages.index');
const queryParams = {
currentConversationId: current_conversation_id,
companyId: curCompany.get('id')
};
if (current_conversation_id) {
try {
await this.store.queryRecord('conversation', queryParams)
} catch(e) {
if (e.code == 404) {
return this.transitionTo(/* ... */)
} else {
throw e;
}
}
}
}
beforeModel() {
const curUser = this.get('currentUser.user');
const curCompany = curUser.get('currentCompany');
const { current_conversation_id } = this.paramsFor('messages.index');
const queryParams = {
currentConversationId: current_conversation_id,
companyId: curCompany.get('id')
};
if (current_conversation_id) {
return this
.store
.queryRecord('conversation', queryParams)
.catch((e) => {
if (e.code == 404) {
return this.transitionTo(/* ... */)
} else {
throw e;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment