feat: Add NotificationTray persistence by course (#772)

REV-2424
This commit is contained in:
julianajlk
2021-12-21 13:50:07 -05:00
committed by GitHub
parent de49e8b271
commit 2bf4f2a0b5
6 changed files with 137 additions and 11 deletions

View File

@@ -0,0 +1,34 @@
// This file holds some convenience methods for dealing with sessionStorage. Unlike localStorage that never expires,
// sessionStorage is cleared when the browser tab is closed since the page session ends
//
// NOTE: These storage keys are not namespaced. That means that it's shared for the current fully
// qualified domain. Namespacing could be added, but we'll cross that bridge when we need it.
function getSessionStorage(key) {
try {
if (global.sessionStorage) {
const rawItem = global.sessionStorage.getItem(key);
if (rawItem) {
return JSON.parse(rawItem);
}
}
} catch (e) {
// If this fails for some reason, just return null.
}
return null;
}
function setSessionStorage(key, value) {
try {
if (global.sessionStorage) {
global.sessionStorage.setItem(key, JSON.stringify(value));
}
} catch (e) {
// If this fails, just bail.
}
}
export {
getSessionStorage,
setSessionStorage,
};