aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-08-03 13:10:00 -0400
committerAjay Ramachandran <[email protected]>2021-08-03 13:10:00 -0400
commitafeba5f0771e7f784a4c46010665f42933534f25 (patch)
tree39b8c8f2f3dac131d4768bd0b9b60c5a77f11200
parent81d0c0cab1bc42038d74ae9136a6f93d4b182651 (diff)
downloadSponsorBlock-afeba5f0771e7f784a4c46010665f42933534f25.tar.gz
SponsorBlock-afeba5f0771e7f784a4c46010665f42933534f25.zip
Don't break chat when no warning reason
-rw-r--r--src/js-components/chat.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/js-components/chat.ts b/src/js-components/chat.ts
index 91dc6720..bb7028d2 100644
--- a/src/js-components/chat.ts
+++ b/src/js-components/chat.ts
@@ -34,11 +34,12 @@ export async function openWarningChat(warningMessage: string): Promise<void> {
const userNameData = await utils.asyncRequestToServer("GET", "/api/getUsername?userID=" + Config.config.userID);
const userName = userNameData.ok ? JSON.parse(userNameData.responseText).userName : "";
const publicUserID = await utils.getHash(Config.config.userID);
+ const warningReasonMatch = warningMessage.match(/Warning reason: '(.+)'/);
openChat({
displayName: `${userName ? userName : ``}${userName !== publicUserID ? ` | ${publicUserID}` : ``}`,
- composerInitialValue: `I got a warning and want to know what I need to do to improve. ` +
- `Warning reason: ${warningMessage.match(/Warning reason: '(.+)'/)[1]}`,
+ composerInitialValue: `I got a warning and want to know what I need to do to improve.` +
+ warningReasonMatch ? ` Warning reason: ${warningReasonMatch[1]}` : ``,
customDescription: chrome.i18n.getMessage("warningChatInfo")
});
} \ No newline at end of file