mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Cleanup boot.js and fix rllayout cookie
This commit is contained in:
parent
827421e116
commit
f3717815e1
3 changed files with 37 additions and 41 deletions
|
|
@ -1,13 +1,37 @@
|
|||
const
|
||||
CLIENT_SIDE_STORAGE_INDEX_NAME = 'rlcsc',
|
||||
getStorage = () => {
|
||||
try {
|
||||
const value = localStorage.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
return value ? JSON.parse(value) : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
win = window,
|
||||
CLIENT_SIDE_STORAGE_INDEX_NAME = 'rlcsc',
|
||||
sName = 'localStorage',
|
||||
getStorage = () => {
|
||||
try {
|
||||
const value = localStorage.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
return value ? JSON.parse(value) : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Storage
|
||||
try {
|
||||
win[sName].setItem(sName, '');
|
||||
win[sName].getItem(sName);
|
||||
win[sName].removeItem(sName);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// initialise if there's already data
|
||||
let data = document.cookie.match(/(^|;) ?localStorage=([^;]+)/);
|
||||
data = data ? decodeURIComponent(data[2]) : null;
|
||||
data = data ? JSON.parse(data) : {};
|
||||
win[sName] = {
|
||||
getItem: key => data[key] == null ? null : data[key],
|
||||
setItem: (key, value) => {
|
||||
data[key] = ''+value; // forces the value to a string
|
||||
document.cookie = sName+'='+encodeURIComponent(JSON.stringify(data))
|
||||
+"; expires="+((new Date(Date.now()+(365*24*60*60*1000))).toGMTString())
|
||||
+"; path=/; samesite=strict";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue