This repository was archived by the owner on Jan 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ You can configure a few things by editing the file `src/config/index.tsx`.
19
19
- ` DIR ` - The directory to watch.
20
20
- ` MAX_IMAGES ` - How many images to request. Default 10.
21
21
- ` POLL_INTERVAL ` - How often should the frontend look for updates. Default 5 seconds.
22
+ - ` RETRY_INTERVAL ` - How frequently should the frontend retry polling on failure.
22
23
- ` FILE_EXTENSION ` - The filetypes supported. Default ` png ` .
23
24
- ` FILE_MIME ` - The file mime type. Default ` image/png ` .
24
25
- ` SHOW_TITLE ` - If the title should be overlaid. Default ` false ` .
Original file line number Diff line number Diff line change 1
1
export const DIR = `D:\\stable-diffusion-webui\\outputs\\txt2img-images` ;
2
2
export const MAX_IMAGES = 10 ;
3
3
export const POLL_INTERVAL = 5 * 1000 ;
4
+ export const RETRY_INTERVAL = 10 * 1000 ;
4
5
export const FILE_EXTENSION = "png" ;
5
6
export const FILE_MIME = "image/png" ;
6
7
export const SHOW_TITLE = false ;
Original file line number Diff line number Diff line change 1
1
import { useCallback , useState , useEffect } from "react" ;
2
2
3
- import { POLL_INTERVAL } from "@/config" ;
3
+ import { POLL_INTERVAL , RETRY_INTERVAL } from "@/config" ;
4
4
5
5
const useImages = ( ) => {
6
6
const [ images , setImages ] = useState < string [ ] > ( [ ] ) ;
7
7
8
8
const getImages = useCallback ( async ( ) => {
9
- const data = await fetch ( "/api/images" ) ;
10
- const json = await data . json ( ) ;
11
- setImages ( json . images ) ;
12
- setTimeout ( ( ) => getImages ( ) , POLL_INTERVAL ) ;
9
+ try {
10
+ const data = await fetch ( "/api/images" ) ;
11
+ const json = await data . json ( ) ;
12
+ setImages ( json . images ) ;
13
+ setTimeout ( ( ) => getImages ( ) , POLL_INTERVAL ) ;
14
+ } catch ( error ) {
15
+ console . error ( error ) ;
16
+ setTimeout ( ( ) => {
17
+ getImages ( ) ;
18
+ } , RETRY_INTERVAL ) ;
19
+ }
13
20
} , [ ] ) ;
14
21
15
22
useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments