File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
2
2
import { defaultConfig , getUserConfig } from '../config/index.mjs'
3
3
import Browser from 'webextension-polyfill'
4
4
5
- export function useConfig ( initFn ) {
5
+ export function useConfig ( initFn , ignoreSession = true ) {
6
6
const [ config , setConfig ] = useState ( defaultConfig )
7
7
useEffect ( ( ) => {
8
8
getUserConfig ( ) . then ( ( config ) => {
@@ -12,7 +12,7 @@ export function useConfig(initFn) {
12
12
} , [ ] )
13
13
useEffect ( ( ) => {
14
14
const listener = ( changes ) => {
15
- if ( Object . keys ( changes ) . length === 1 && 'sessions' in changes ) return
15
+ if ( ignoreSession ) if ( Object . keys ( changes ) . length === 1 && 'sessions' in changes ) return
16
16
17
17
const changedItems = Object . keys ( changes )
18
18
let newConfig = { }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import Browser from 'webextension-polyfill'
19
19
function App ( ) {
20
20
const { t } = useTranslation ( )
21
21
const [ collapsed , setCollapsed ] = useState ( true )
22
- const config = useConfig ( )
22
+ const config = useConfig ( null , false )
23
23
const [ sessions , setSessions ] = useState ( [ ] )
24
24
const [ sessionId , setSessionId ] = useState ( null )
25
25
const [ currentSession , setCurrentSession ] = useState ( null )
@@ -54,6 +54,10 @@ function App() {
54
54
} ) ( )
55
55
} , [ ] )
56
56
57
+ useEffect ( ( ) => {
58
+ if ( 'sessions' in config && config [ 'sessions' ] ) setSessions ( config [ 'sessions' ] )
59
+ } , [ config ] )
60
+
57
61
useEffect ( ( ) => {
58
62
// eslint-disable-next-line
59
63
; ( async ( ) => {
You can’t perform that action at this time.
0 commit comments