mirror of
https://github.com/XFox111/my-website.git
synced 2026-04-22 07:28:01 +03:00
fix: fixed possibe requrest timeout for AlertMessage
This commit is contained in:
@@ -18,24 +18,31 @@ const AlertMessage: React.FC = async () =>
|
|||||||
if (!process.env.ALERT_TEXT_URL)
|
if (!process.env.ALERT_TEXT_URL)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const response: Response = await fetch(process.env.ALERT_TEXT_URL, { cache: "no-cache" });
|
try
|
||||||
const alertText: string = await response.text();
|
{
|
||||||
|
const response: Response = await fetch(process.env.ALERT_TEXT_URL, { cache: "no-cache" });
|
||||||
|
const alertText: string = await response.text();
|
||||||
|
|
||||||
if (!response.ok || !alertText)
|
if (!response.ok || !alertText)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const title: string = alertText.split("\n", 1)[0];
|
const title: string = alertText.split("\n", 1)[0];
|
||||||
const message: string = alertText.substring(title.length);
|
const message: string = alertText.substring(title.length);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div role="alert" className={ cls.alertBox } aria-label={ alertText }>
|
<div role="alert" className={ cls.alertBox } aria-label={ alertText }>
|
||||||
<ChatWarningRegular className={ cls.icon } />
|
<ChatWarningRegular className={ cls.icon } />
|
||||||
<div>
|
<div>
|
||||||
<p className={ cls.title }>{ title }</p>
|
<p className={ cls.title }>{ title }</p>
|
||||||
<p dangerouslySetInnerHTML={ { __html: message } } />
|
<p dangerouslySetInnerHTML={ { __html: message } } />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AlertMessage;
|
export default AlertMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user