File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
22import { defaultConfig , getUserConfig } from '../config/index.mjs'
33import Browser from 'webextension-polyfill'
44
5- export function useConfig ( initFn ) {
5+ export function useConfig ( initFn , ignoreSession = true ) {
66 const [ config , setConfig ] = useState ( defaultConfig )
77 useEffect ( ( ) => {
88 getUserConfig ( ) . then ( ( config ) => {
@@ -12,7 +12,7 @@ export function useConfig(initFn) {
1212 } , [ ] )
1313 useEffect ( ( ) => {
1414 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
1616
1717 const changedItems = Object . keys ( changes )
1818 let newConfig = { }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import Browser from 'webextension-polyfill'
1919function App ( ) {
2020 const { t } = useTranslation ( )
2121 const [ collapsed , setCollapsed ] = useState ( true )
22- const config = useConfig ( )
22+ const config = useConfig ( null , false )
2323 const [ sessions , setSessions ] = useState ( [ ] )
2424 const [ sessionId , setSessionId ] = useState ( null )
2525 const [ currentSession , setCurrentSession ] = useState ( null )
@@ -54,6 +54,10 @@ function App() {
5454 } ) ( )
5555 } , [ ] )
5656
57+ useEffect ( ( ) => {
58+ if ( 'sessions' in config && config [ 'sessions' ] ) setSessions ( config [ 'sessions' ] )
59+ } , [ config ] )
60+
5761 useEffect ( ( ) => {
5862 // eslint-disable-next-line
5963 ; ( async ( ) => {
You can’t perform that action at this time.
0 commit comments