mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Cleanup AuthAccountHash handling
This commit is contained in:
parent
8e5d56e15f
commit
146b2c1001
8 changed files with 32 additions and 130 deletions
|
|
@ -1,9 +1,9 @@
|
|||
const storage = localStorage,
|
||||
const
|
||||
CLIENT_SIDE_STORAGE_INDEX_NAME = 'rlcsc',
|
||||
getStorage = () => {
|
||||
try {
|
||||
const value = storage.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null;
|
||||
return null == value ? null : JSON.parse(value);
|
||||
const value = localStorage.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
return value ? JSON.parse(value) : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ export function set(key, data) {
|
|||
storageResult['p' + key] = data;
|
||||
|
||||
try {
|
||||
storage.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult));
|
||||
localStorage.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
|
|
@ -32,10 +32,7 @@ export function set(key, data) {
|
|||
*/
|
||||
export function get(key) {
|
||||
try {
|
||||
key = 'p' + key;
|
||||
const storageResult = getStorage();
|
||||
|
||||
return storageResult && null != storageResult[key] ? storageResult[key] : null;
|
||||
return (getStorage() || {})['p' + key];
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue