| 1 |
/** |
| 2 |
* Store the unique preload ID in order to prevent notifications from |
| 3 |
* displaying over and over when the REST endpoint is polled. |
| 4 |
*/ |
| 5 |
const preloadIdKey = 'swpsp-preload-id'; |
| 6 |
|
| 7 |
export const PreloadId = { |
| 8 |
/** |
| 9 |
* Retrieve the preload ID from sessionStorage. |
| 10 |
* |
| 11 |
* @returns {string|null} The stored preload ID, or `null` if it doesn't exist. |
| 12 |
*/ |
| 13 |
get: () => sessionStorage.getItem(preloadIdKey), |
| 14 |
|
| 15 |
/** |
| 16 |
* Set the preload ID in sessionStorage. |
| 17 |
* |
| 18 |
* @param {string} id The preload ID to store. |
| 19 |
*/ |
| 20 |
set: (id) => sessionStorage.setItem(preloadIdKey, id), |
| 21 |
|
| 22 |
/** |
| 23 |
* Check if the preload ID exists in sessionStorage. |
| 24 |
* |
| 25 |
* @returns {boolean} `true` if the preload ID exists, otherwise `false`. |
| 26 |
*/ |
| 27 |
has: () => sessionStorage.getItem(preloadIdKey) !== null, |
| 28 |
|
| 29 |
/** |
| 30 |
* Clear the preload ID. |
| 31 |
*/ |
| 32 |
clear: () => sessionStorage.removeItem(preloadIdKey), |
| 33 |
}; |
| 34 |
|