Skip to content

Commit

Permalink
fix(frontend/settings): call setSettings within Sources settings
Browse files Browse the repository at this point in the history
Closes #538
  • Loading branch information
Harjot1Singh committed May 24, 2020
1 parent c3b7089 commit e2e4850
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions app/frontend/src/Settings/Sources.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { shape, objectOf, string, number, func } from 'prop-types'
import { shape, objectOf, string, number } from 'prop-types'

import {
ExpansionPanel,
Expand All @@ -14,6 +14,7 @@ import { faChevronDown } from '@fortawesome/free-solid-svg-icons'

import Loader from '../shared/Loader'
import { BACKEND_URL } from '../lib/consts'
import controller from '../lib/controller'

import { ResetButton } from './DynamicOptions'
import { Dropdown as Select } from './SettingComponents'
Expand All @@ -23,7 +24,7 @@ import './Sources.css'
/**
* View to configure source content, such as translations.
*/
const Sources = ( { sources: currentSources, setSettings } ) => {
const Sources = ( { sources: currentSources, device } ) => {
const [ languages, setLanguages ] = useState()
const [ { sources, recommended }, setSources ] = useState( {} )

Expand Down Expand Up @@ -92,7 +93,7 @@ const Sources = ( { sources: currentSources, setSettings } ) => {
values={translationSources[ id ].map( (
( { nameEnglish: name, id: value } ) => ( { name, value } )
) )}
onChange={( { target: { value } } ) => setSettings( {
onChange={( { target: { value } } ) => controller.setSettings( {
sources: {
[ sourceId ]: {
translationSources: {
Expand All @@ -102,7 +103,7 @@ const Sources = ( { sources: currentSources, setSettings } ) => {
},
},
},
} )}
}, device )}
/>
) : (
<Typography variant="body2">{translationSources[ id ][ 0 ].nameEnglish}</Typography>
Expand All @@ -125,6 +126,7 @@ const Sources = ( { sources: currentSources, setSettings } ) => {
}

Sources.propTypes = {
device: string.isRequired,
sources: objectOf( shape( {
nameEnglish: string.isRequired,
nameGurmukhi: string.isRequired,
Expand All @@ -133,7 +135,6 @@ Sources.propTypes = {
nameEnglish: string.isRequired,
} ) ),
} ) ).isRequired,
setSettings: func.isRequired,
}

export default Sources
2 changes: 1 addition & 1 deletion app/frontend/src/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const Settings = () => {
path={`${SETTINGS_DEVICE_URL}/hotkeys`}
render={() => ( <Hotkeys shortcuts={SHORTCUTS} keys={hotkeys} device={device} /> )}
/>
<Route path={`${SETTINGS_DEVICE_URL}/sources`} render={() => <Sources sources={selectedDeviceSettings.sources} />} />
<Route path={`${SETTINGS_DEVICE_URL}/sources`} render={() => <Sources sources={selectedDeviceSettings.sources} device={device} />} />
<Route path={`${SETTINGS_DEVICE_URL}/*`} render={() => <DynamicOptions device={device} group={group} />} />

{/* Server setting routes */}
Expand Down

0 comments on commit e2e4850

Please sign in to comment.