mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-07-24 07:31:55 +08:00
Removed using and added check on local storage
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { f7, ListItem, List, Icon } from 'framework7-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { LocalStorage } from '../../utils/LocalStorage.mjs';
|
||||
|
||||
const ThemeColors = ({ themeColors, onColorClick, curColor, isTypeColors, isTypeCustomColors }) => {
|
||||
return (
|
||||
@ -110,7 +111,7 @@ const ThemeColorPalette = props => {
|
||||
let customColors = props.customColors;
|
||||
|
||||
if (customColors.length < 1) {
|
||||
customColors = localStorage.getItem('mobile-custom-colors');
|
||||
customColors = LocalStorage.getItem('mobile-custom-colors');
|
||||
customColors = customColors ? customColors.toLowerCase().split(',') : [];
|
||||
}
|
||||
|
||||
@ -177,11 +178,11 @@ const CustomColorPicker = props => {
|
||||
});
|
||||
|
||||
const addNewColor = (color) => {
|
||||
let colors = localStorage.getItem('mobile-custom-colors');
|
||||
let colors = LocalStorage.getItem('mobile-custom-colors');
|
||||
colors = colors ? colors.split(',') : [];
|
||||
const newColor = color.slice(1);
|
||||
if (colors.push(newColor) > countDynamicColors) colors.shift(); // 10 - dynamiccolors
|
||||
localStorage.setItem('mobile-custom-colors', colors.join().toLowerCase());
|
||||
LocalStorage.setItem('mobile-custom-colors', colors.join().toLowerCase());
|
||||
props.onAddNewColor && props.onAddNewColor(colors, newColor);
|
||||
};
|
||||
|
||||
|
||||
@ -8,18 +8,35 @@ const load_stylesheet = reflink => {
|
||||
document.getElementsByTagName("head")[0].appendChild(link);
|
||||
};
|
||||
|
||||
if ( !!window.Android && window.Android.editorConfig ) {
|
||||
if(!!window.Android && window.Android.editorConfig) {
|
||||
window.native = {editorConfig: window.Android.editorConfig()}
|
||||
}
|
||||
|
||||
if ( localStorage && localStorage.getItem('mobile-mode-direction') === 'rtl' ) {
|
||||
load_stylesheet('./css/framework7-rtl.css')
|
||||
document.body.classList.add('rtl');
|
||||
function isLocalStorageAvailable() {
|
||||
try {
|
||||
const testKey = 'test';
|
||||
localStorage.setItem(testKey, '1');
|
||||
localStorage.removeItem(testKey);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isLocalStorageAvailable()) {
|
||||
if(localStorage.getItem('mobile-mode-direction') === 'rtl') {
|
||||
load_stylesheet('./css/framework7-rtl.css');
|
||||
document.body.classList.add('rtl');
|
||||
} else {
|
||||
load_stylesheet('./css/framework7.css')
|
||||
}
|
||||
} else {
|
||||
load_stylesheet('./css/framework7.css')
|
||||
}
|
||||
|
||||
let obj = !localStorage ? {id: 'theme-light', type: 'light'} : JSON.parse(localStorage.getItem("mobile-ui-theme"));
|
||||
let obj = !isLocalStorageAvailable() ? {id: 'theme-light', type: 'light'} : JSON.parse(localStorage.getItem("mobile-ui-theme"));
|
||||
|
||||
if ( !obj ) {
|
||||
if ( window.native && window.native.theme ) {
|
||||
if ( window.native.theme.type == 'dark' ) obj = {id: 'theme-dark', type: 'dark'};
|
||||
@ -30,7 +47,9 @@ if ( !obj ) {
|
||||
obj = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ?
|
||||
{id: 'theme-dark', type: 'dark'} : {id: 'theme-light', type: 'light'};
|
||||
|
||||
localStorage && localStorage.setItem("mobile-ui-theme", JSON.stringify(obj));
|
||||
if(isLocalStorageAvailable()) {
|
||||
localStorage.setItem("mobile-ui-theme", JSON.stringify(obj));
|
||||
}
|
||||
}
|
||||
|
||||
document.body.classList.add(`theme-type-${obj.type}`, `${window.asceditor}-editor`);
|
||||
|
||||
@ -102,7 +102,7 @@ class MainController extends Component {
|
||||
}
|
||||
this.props.storeApplicationSettings.changeMacrosSettings(value);
|
||||
|
||||
value = localStorage.getItem("de-mobile-allow-macros-request");
|
||||
value = LocalStorage.getItem("de-mobile-allow-macros-request");
|
||||
this.props.storeApplicationSettings.changeMacrosRequest((value !== null) ? parseInt(value) : 0);
|
||||
|
||||
this.props.storeAppOptions.wopi = this.editorConfig.wopi;
|
||||
|
||||
@ -94,7 +94,7 @@ class MainController extends Component {
|
||||
}
|
||||
this.props.storeApplicationSettings.changeMacrosSettings(value);
|
||||
|
||||
value = localStorage.getItem("pe-mobile-allow-macros-request");
|
||||
value = LocalStorage.getItem("pe-mobile-allow-macros-request");
|
||||
this.props.storeApplicationSettings.changeMacrosRequest((value !== null) ? parseInt(value) : 0);
|
||||
};
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ class MainController extends Component {
|
||||
}
|
||||
this.props.storeApplicationSettings.changeMacrosSettings(value);
|
||||
|
||||
value = localStorage.getItem("sse-mobile-allow-macros-request");
|
||||
value = LocalStorage.getItem("sse-mobile-allow-macros-request");
|
||||
this.props.storeApplicationSettings.changeMacrosRequest((value !== null) ? parseInt(value) : 0);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user