Skip to content

Commit ec7b163

Browse files
authored
Merge pull request #78 from CodeDead/feature/vault_password_generator_fix
feature/vault_password_generator_fix
2 parents 0e59736 + bfcad64 commit ec7b163

File tree

3 files changed

+161
-165
lines changed

3 files changed

+161
-165
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@emotion/styled": "^11.11.0",
88
"@fontsource/roboto": "^5.0.5",
99
"@mui/icons-material": "^5.14.1",
10-
"@mui/material": "^5.14.1",
10+
"@mui/material": "^5.14.2",
1111
"@mui/system": "^5.14.1",
1212
"@mui/x-data-grid": "^6.10.1",
1313
"@shopify/react-web-worker": "^5.0.13",
@@ -54,7 +54,7 @@
5454
"eslint-plugin-jsx-a11y": "^6.7.1",
5555
"eslint-plugin-react": "^7.33.0",
5656
"eslint-plugin-react-hooks": "^4.6.0",
57-
"vite": "^4.4.5",
57+
"vite": "^4.4.7",
5858
"vite-plugin-eslint": "^1.8.1",
5959
"vite-plugin-svgr": "^3.2.0"
6060
}

src/components/CreatePasswordDialog/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ import RefreshIcon from '@mui/icons-material/Refresh';
1111
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
1212
import VisibilityIcon from '@mui/icons-material/Visibility';
1313
import Tooltip from '@mui/material/Tooltip';
14+
import { createWorkerFactory, useWorker } from '@shopify/react-web-worker';
1415
import { MainContext } from '../../contexts/MainContextProvider';
1516
import PasswordStrength from '../../utils/PasswordStrength';
1617
import LinearProgressWithLabel from '../LinearProgressWithLabel';
1718
import { setError } from '../../reducers/MainReducer/Actions';
1819
import { generatePasswordArray, getFullCharacterSet } from '../../reducers/PasswordReducer/Actions';
1920
import { PasswordContext } from '../../contexts/PasswordContextProvider';
2021

22+
const createWorker = createWorkerFactory(() => import('../../utils/PasswordGenerator/index'));
23+
2124
const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
2225
const [state, d1] = useContext(MainContext);
2326
const [state2] = useContext(PasswordContext);
@@ -55,6 +58,8 @@ const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
5558
brackets,
5659
);
5760

61+
const worker = useWorker(createWorker);
62+
5863
const cannotGenerate = !simpleCharacterSet || simpleCharacterSet.length === 0
5964
|| min > max || max < min;
6065

@@ -100,7 +105,7 @@ const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
100105
return;
101106
}
102107

103-
generatePasswordArray(min, max, simpleCharacterSet, 1, allowDuplicates, null)
108+
generatePasswordArray(min, max, simpleCharacterSet, 1, allowDuplicates, worker)
104109
.then((res) => {
105110
setPassword(res[0]);
106111
})

0 commit comments

Comments
 (0)