Skip to content

Commit

Permalink
fix(frontend): reload settings when default options have been modified (
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh authored May 24, 2020
1 parent c3b7089 commit c651c7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const ScreenReader = lazy( () => import( './ScreenReader' ) )
const Presenter = lazy( () => import( './Presenter' ) )
const Settings = lazy( () => import( './Settings' ) )

const loadSettings = () => merge( { local: controller.readSettings() }, DEFAULT_OPTIONS )

class App extends PureComponent {
components = [
[ Overlay, OVERLAY_URL ],
Expand Down Expand Up @@ -61,7 +63,7 @@ class App extends PureComponent {
shabad: null,
recommendedSources: {},
writers: {},
settings: merge( { local: controller.readSettings() }, DEFAULT_OPTIONS ),
settings: loadSettings(),
}
}

Expand All @@ -87,7 +89,8 @@ class App extends PureComponent {
.then( ( { recommended: recommendedSources } ) => {
//* Update default options and settings with fetched recommended sources
DEFAULT_OPTIONS.local.sources = recommendedSources
this.setState( ( { settings } ) => ( { recommendedSources, settings } ) )
//! Re-load settings since we've modified DEFAULT_OPTIONS directly
this.setState( { recommendedSources, settings: loadSettings() } )
} )

// Get writers
Expand Down

0 comments on commit c651c7b

Please sign in to comment.