blob: d768a06494aef118359db5199592b89f44355d41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import AccessorUtilities from '~/lib/utils/accessor';
import { LOCAL_STORAGE_ALERT_KEY } from './constants';
export const showAlertFromLocalStorage = async () => {
if (AccessorUtilities.canUseLocalStorage()) {
const alertOptions = localStorage.getItem(LOCAL_STORAGE_ALERT_KEY);
if (alertOptions) {
try {
const { createAlert } = await import('~/flash');
createAlert(JSON.parse(alertOptions));
} catch {
// ignore when the alert data cannot be parsed
}
}
localStorage.removeItem(LOCAL_STORAGE_ALERT_KEY);
}
};
|