From aae898fc5753a688348eb9bea0a0062561a8e5cb Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 17 Mar 2020 17:32:04 +0100 Subject: catch the error if the browser doesn't support promises --- webAO/client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 5999bfe..291802e 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1363,19 +1363,25 @@ async changeBackground(position) { this.changeBackground(chatmsg.side); + try { const { url: speakUrl } = await this.oneSuccess([ this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/" + this.chatmsg.sprite + ".png")), this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/(b)" + this.chatmsg.sprite + ".gif")) ]); - this.speakingSprite = speakUrl ? speakUrl : transparentPNG; + } catch (error) { + this.speakingSprite = AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/(b)" + this.chatmsg.sprite + ".gif"; + } + try { const { url: silentUrl } = await this.oneSuccess([ this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/" + this.chatmsg.sprite + ".png")), this.rejectOnError(fetch(AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif")) ]); - this.silentSprite = silentUrl ? silentUrl : transparentPNG; + } catch (error) { + this.silentSprite = AO_HOST + "characters/" + encodeURI(this.chatmsg.name.toLowerCase()) + "/(a)" + this.chatmsg.sprite + ".gif"; + } // gets which shout shall played const shout = this.shouts[this.chatmsg.objection]; -- cgit