diff options
author | Ajay Ramachandran <[email protected]> | 2021-08-03 13:10:00 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-08-05 17:02:37 -0400 |
commit | 314c793992d2f2e98776160a29faa86ccf402695 (patch) | |
tree | 5b56d2e35d82ebaa043abd4cb42ee0347e584b5e /src | |
parent | accc985e4bbf460f69597443baf30647e2623e0b (diff) | |
download | SponsorBlock-314c793992d2f2e98776160a29faa86ccf402695.tar.gz SponsorBlock-314c793992d2f2e98776160a29faa86ccf402695.zip |
Don't break chat when no warning reason
Diffstat (limited to 'src')
-rw-r--r-- | src/js-components/chat.ts | 5 |
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 |