Skip to content

Commit 5cf11bd

Browse files
Implements state persistence in localStorage
1 parent 9c666a9 commit 5cf11bd

File tree

13 files changed

+594
-549
lines changed

13 files changed

+594
-549
lines changed

frontend/dist/assets/index.235e49ab.js

Lines changed: 0 additions & 518 deletions
This file was deleted.

frontend/dist/assets/index.f988921c.js

Lines changed: 518 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Stable Diffusion Dream Server</title>
7-
<script type="module" crossorigin src="/assets/index.235e49ab.js"></script>
7+
<script type="module" crossorigin src="/assets/index.f988921c.js"></script>
88
</head>
99
<body>
1010
<div id="root"></div>

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-dropzone": "^14.2.2",
2222
"react-icons": "^4.4.0",
2323
"react-redux": "^8.0.2",
24+
"redux-persist": "^6.0.0",
2425
"socket.io-client": "^4.5.2",
2526
"uuid": "^9.0.0"
2627
},

frontend/src/app/store.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import { configureStore } from '@reduxjs/toolkit';
1+
import { combineReducers, configureStore } from '@reduxjs/toolkit';
2+
import { persistReducer } from 'redux-persist';
3+
import storage from 'redux-persist/lib/storage'; // defaults to localStorage for web
4+
25
import sdReducer from '../features/sd/sdSlice';
36
import galleryReducer from '../features/gallery/gallerySlice';
47
import systemReducer from '../features/system/systemSlice';
58

6-
/*
7-
Store Slices
8-
- sd: image generation parameters
9-
- gallery: image gallery
10-
- system: logs, site settings, etc
11-
*/
9+
const reducers = combineReducers({
10+
sd: sdReducer,
11+
gallery: galleryReducer,
12+
system: systemReducer,
13+
});
14+
15+
const persistConfig = {
16+
key: 'root',
17+
storage,
18+
};
19+
20+
const persistedReducer = persistReducer(persistConfig, reducers);
1221

1322
export const store = configureStore({
14-
reducer: {
15-
sd: sdReducer,
16-
gallery: galleryReducer,
17-
system: systemReducer,
18-
},
23+
reducer: persistedReducer,
1924
// devTools: {
2025
// trace: true,
2126
// },

frontend/src/app/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extendTheme, type ThemeConfig } from '@chakra-ui/react';
1+
import { extendTheme } from '@chakra-ui/react';
22
import type { StyleFunctionProps } from '@chakra-ui/styled-system';
33

44
export const theme = extendTheme({
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Flex, Spinner } from '@chakra-ui/react';
2+
3+
const Loading = () => {
4+
return (
5+
<Flex
6+
width={'100vw'}
7+
height={'100vh'}
8+
alignItems='center'
9+
justifyContent='center'
10+
>
11+
<Spinner
12+
thickness='2px'
13+
speed='1s'
14+
emptyColor='gray.200'
15+
color='gray.400'
16+
size='xl'
17+
/>
18+
</Flex>
19+
);
20+
};
21+
22+
export default Loading;

frontend/src/components/SDFileUpload.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { useAppDispatch, useAppSelector } from '../app/hooks';
1515
import { FaUpload } from 'react-icons/fa';
1616
import { RootState } from '../app/store';
1717
import { useSocketIOEmitters } from '../context/socket';
18-
import { MdDeleteForever } from 'react-icons/md';
1918
import { resetInitialImagePath } from '../features/sd/sdSlice';
2019
import { RiCloseFill } from 'react-icons/ri';
2120

frontend/src/components/SDSwitch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FormControl, FormLabel, HStack, Switch } from '@chakra-ui/react';
2-
import React, { ChangeEvent } from 'react';
2+
import { ChangeEvent } from 'react';
33

44
type Props = {
55
label: string;

frontend/src/features/gallery/CurrentImage.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import {
33
Flex,
44
IconButton,
55
Image,
6-
Menu,
7-
MenuButton,
8-
MenuItem,
9-
MenuList,
106
Tooltip,
117
VStack,
128
} from '@chakra-ui/react';
13-
import { BsThreeDots } from 'react-icons/bs';
14-
import { FaCopy, FaPaintBrush, FaRecycle, FaSeedling, FaUpload } from 'react-icons/fa';
9+
import {
10+
FaCopy,
11+
FaPaintBrush,
12+
FaRecycle,
13+
FaSeedling,
14+
} from 'react-icons/fa';
1515
import { RiBracesFill } from 'react-icons/ri';
1616
import { GiResize } from 'react-icons/gi';
1717
import { MdDeleteForever, MdFaceRetouchingNatural } from 'react-icons/md';

0 commit comments

Comments
 (0)