-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.jsx
More file actions
68 lines (61 loc) · 2.13 KB
/
Copy pathindex.jsx
File metadata and controls
68 lines (61 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { createContext, useReducer } from 'react';
import MainReducer from '../../reducers/MainReducer';
import enUs from '../../languages/en_us.json';
import esEs from '../../languages/es_es.json';
import nlNl from '../../languages/nl_nl.json';
import frFr from '../../languages/fr_fr.json';
import zhCn from '../../languages/zh_cn.json';
import itIt from '../../languages/it_it.json';
const languageIndex = localStorage.languageIndex ? parseFloat(localStorage.languageIndex) : 0;
const themeIndex = localStorage.themeIndex ? parseFloat(localStorage.themeIndex) : 0;
const themeType = localStorage.themeType ? localStorage.themeType : 'light';
const autoUpdate = localStorage.autoUpdate ? (localStorage.autoUpdate === 'true') : true;
const colorOnDark = localStorage.colorOnDark ? (localStorage.colorOnDark === 'true') : false;
const threads = localStorage.threads ? parseFloat(localStorage.threads) : 1;
const timeout = localStorage.timeout ? parseFloat(localStorage.timeout) : 250;
const noClosed = localStorage.noClosed ? (localStorage.noClosed === 'true') : false;
const exportNoClosed = localStorage.exportNoClosed ? (localStorage.exportNoClosed === 'true') : true;
const sort = localStorage.sort ? (localStorage.sort === 'true') : true;
const themeToggle = localStorage.themeToggle ? (localStorage.themeToggle === 'true') : true;
const initState = {
autoUpdate,
languageIndex,
languages: [
enUs,
esEs,
frFr,
itIt,
nlNl,
zhCn,
],
themeIndex,
themeType,
pageIndex: 0,
update: null,
checkedForUpdates: false,
loading: false,
colorOnDark,
error: null,
address: '',
startPort: 0,
endPort: 65535,
isScanning: false,
threads,
timeout,
noClosed,
exportNoClosed,
sort,
scanResults: null,
themeToggle,
};
export const MainContext = createContext(initState);
const MainContextProvider = ({ children }) => {
const [state, dispatch] = useReducer(MainReducer, initState);
return (
// eslint-disable-next-line react/jsx-no-constructed-context-values
<MainContext.Provider value={[state, dispatch]}>
{children}
</MainContext.Provider>
);
};
export default MainContextProvider;