Get username for warning chat

This commit is contained in:
Ajay Ramachandran
2021-07-29 19:29:34 -04:00
parent c84a951acc
commit 839dd4613c
2 changed files with 10 additions and 7 deletions

View File

@@ -31,8 +31,12 @@ export function openChat(config: ChatConfig): void {
}
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);
openChat({
displayName: await utils.getHash(Config.config.userID),
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]}`,
customDescription: chrome.i18n.getMessage("warningChatInfo")