16 lines
663 B
JavaScript
16 lines
663 B
JavaScript
const normalize = (value) => value == null || value === 'null' || value === 'undefined' ? '' : String(value);
|
|
|
|
export const getSheetVisitId = (sheet, direction, year) => JSON.stringify([sheet, normalize(direction), normalize(year)]);
|
|
|
|
export const rememberSheetVisit = (kind, parentId, sheet, direction, year) => {
|
|
try {
|
|
sessionStorage.setItem(`last-sheet:${kind}:${parentId}`, getSheetVisitId(sheet, direction, year));
|
|
} catch { /* The sheet remains available when browser storage is disabled. */ }
|
|
};
|
|
|
|
export const readSheetVisit = (kind, parentId) => {
|
|
try {
|
|
return sessionStorage.getItem(`last-sheet:${kind}:${parentId}`);
|
|
} catch { return null; }
|
|
};
|