diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2019-07-01 22:58:47 -0500 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2019-07-01 22:58:47 -0500 |
| commit | 1ff53d9aed85aa31aafcbb72a00fc5f7eb761374 (patch) | |
| tree | efe66c3055abdef75376e0bde3aaeb55cc850bcd /webAO/client.js | |
| parent | 393142f7001269140897a8ca191884e8c29bb699 (diff) | |
Ugh! It lives!
Diffstat (limited to 'webAO/client.js')
| -rw-r--r-- | webAO/client.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/webAO/client.js b/webAO/client.js index 665dd81..50ea318 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -491,7 +491,7 @@ class Client extends EventEmitter { resetICParams(); } - viewport.say(chatmsg); + viewport.say(chatmsg); // no await } } @@ -961,7 +961,7 @@ class Viewport { * Sets a new emote. * @param {object} chatmsg the new chat message */ - say(chatmsg) { + async say(chatmsg) { this.chatmsg = chatmsg; appendICLog(chatmsg.content, chatmsg.nameplate); changeBackground(chatmsg.side); @@ -972,7 +972,9 @@ class Viewport { clearTimeout(this.updater); // If preanim existed then determine the length if (chatmsg.preanim !== "-") { - chatmsg.preanimdelay = this.getAnimLength(`${AO_HOST}characters/${escape(chatmsg.name.toLowerCase())}/${chatmsg.preanim.toLowerCase()}.gif`, this.initUpdater); + const delay = await this.getAnimLength(`${AO_HOST}characters/${escape(chatmsg.name.toLowerCase())}/${chatmsg.preanim.toLowerCase()}.gif`); + chatmsg.preanimdelay = delay; + this.initUpdater(delay); } else { this.initUpdater(0); } @@ -1013,12 +1015,17 @@ class Viewport { } /** - * Gets animation length. + * Gets animation length. If the animation cannot be found, it will + * silently fail and return 0 instead. * @param {string} filename the animation file name */ async getAnimLength(filename) { - const file = await request(filename).response; - return gify.getInfo(file).duration; + try { + const file = await request(filename); + return gify.getInfo(file).duration; + } catch (err) { + return 0; + } } /** |
