Welcome to mirror list, hosted at ThFree Co, Russian Federation.

show_alert_from_local_storage.js « local_storage_alert « runner « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
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);
  }
};