Skip to content

Commit

Permalink
fix(ui): load proper item by id (#3844)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed May 29, 2020
1 parent 0c95397 commit 78e1e1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/bot/registries/text.ts
Expand Up @@ -43,16 +43,12 @@ class Text extends Registry {
});
publicEndpoint(this.nsp, 'generic::getOne', async (opts: { id: any; parseText: boolean }, callback) => {
try {
const item = await getRepository(TextEntity).findOne({ id: opts.id });
let text = '';
if (item) {
text = item.text;
if (opts.parseText) {
text = await new Message(await customvariables.executeVariablesInText(text)).parse();
}
callback(null, {...item, text});
const item = await getRepository(TextEntity).findOneOrFail({ id: opts.id });
let text = item.text;
if (opts.parseText) {
text = await new Message(await customvariables.executeVariablesInText(text)).parse();
}
callback(null, null);
callback(null, {...item, text});
} catch(e) {
callback(e, null);
}
Expand Down
Expand Up @@ -200,8 +200,13 @@ export default class textOverlayEdit extends Vue {
// load up from db
if (this.$route.params.id) {
this.id = this.$route.params.id
this.socket.emit('generic::getOne', { id: this.urlParam('id'), parseText: false }, (err: string | null, data: TextInterface) => {
this.socket.emit('generic::getOne', { id: this.$route.params.id, parseText: false }, (err: null | Error, data: TextInterface) => {
if (err) {
this.$bvToast.toast(err.message, {
title: `Error`,
variant: 'danger',
solid: true,
});
return console.error(err);
}
this.name = data.name
Expand Down

0 comments on commit 78e1e1d

Please sign in to comment.