mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,39 +1,31 @@
|
|||
|
||||
import window from 'window';
|
||||
import Cookies from 'js-cookie';
|
||||
import {isUnd} from 'Common/Utils';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
import { isUnd } from 'Common/Utils';
|
||||
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
|
||||
|
||||
class CookieDriver
|
||||
{
|
||||
class CookieDriver {
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {*} data
|
||||
* @returns {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
|
||||
let
|
||||
result = false,
|
||||
let result = false,
|
||||
storageResult = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
storageResult = Cookies.getJSON(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
Cookies.set(CLIENT_SIDE_STORAGE_INDEX_NAME, storageResult, {
|
||||
expires: 30
|
||||
});
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -43,15 +35,12 @@ class CookieDriver
|
|||
* @returns {*}
|
||||
*/
|
||||
get(key) {
|
||||
|
||||
let result = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
const storageResult = Cookies.getJSON(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
result = storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -64,4 +53,4 @@ class CookieDriver
|
|||
}
|
||||
}
|
||||
|
||||
export {CookieDriver, CookieDriver as default};
|
||||
export { CookieDriver, CookieDriver as default };
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import window from 'window';
|
||||
import {isUnd} from 'Common/Utils';
|
||||
import {isStorageSupported} from 'Storage/RainLoop';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
import { isUnd } from 'Common/Utils';
|
||||
import { isStorageSupported } from 'Storage/RainLoop';
|
||||
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
|
||||
|
||||
class LocalStorageDriver
|
||||
{
|
||||
class LocalStorageDriver {
|
||||
s = null;
|
||||
|
||||
constructor() {
|
||||
|
|
@ -18,27 +16,22 @@ class LocalStorageDriver
|
|||
* @returns {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
if (!this.s)
|
||||
{
|
||||
if (!this.s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let storageResult = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null;
|
||||
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
this.s.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, window.JSON.stringify(storageResult));
|
||||
return true;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -48,20 +41,16 @@ class LocalStorageDriver
|
|||
* @returns {*}
|
||||
*/
|
||||
get(key) {
|
||||
if (!this.s)
|
||||
{
|
||||
if (!this.s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const
|
||||
storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
|
||||
try {
|
||||
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
|
||||
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
|
||||
|
||||
return (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
return storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -74,4 +63,4 @@ class LocalStorageDriver
|
|||
}
|
||||
}
|
||||
|
||||
export {LocalStorageDriver, LocalStorageDriver as default};
|
||||
export { LocalStorageDriver, LocalStorageDriver as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue