Skip to content

Commit

Permalink
feat: better restart handling after updating settings
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Feb 15, 2022
1 parent 59b1857 commit 0db1dab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ISettings } from '../../server/reducers/settingsReducer'
import { Store } from 'redux'
import { ChangeEvent } from 'react'
import { SOCKET_SAVE_SETTINGS } from '../../server/constants/SOCKET_IO_DISPATCHERS'
import { storeShowSettings } from '../../server/reducers/settingsActions'
import { storeSetServerOnline, storeShowSettings } from '../../server/reducers/settingsActions'

//Set style for Select dropdown component:
const selectorColorStyles = {
Expand Down Expand Up @@ -169,7 +169,13 @@ class Settings extends React.PureComponent<IAppProps & Store, IState> {
let settingsCopy = Object.assign({}, this.state.settings)
settingsCopy.showSettings = false
window.socketIoClient.emit(SOCKET_SAVE_SETTINGS, settingsCopy)
location.reload()
this.props.dispatch(storeShowSettings())
window.alert(
'restarting Sisyfos'
)
setTimeout(()=> {
location.reload()
}, 2000)
}

handleCancel = () => {
Expand Down Expand Up @@ -553,7 +559,7 @@ class Settings extends React.PureComponent<IAppProps & Store, IState> {
this.handleSave()
}}
>
SAVE SETTINGS
SAVE & RESTART
</button>
</div>
)
Expand Down
4 changes: 4 additions & 0 deletions server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export class MainThreadHandlers {
logger.data(payload).info('Save settings:')
saveSettings(payload)
this.updateFullClientStore()
/** Delay restart to ensure the async saveSettings is done before restarting*/
setTimeout(() => {
process.exit(0)
}, 1000)
})
.on(IO.SOCKET_RESTART_SERVER, () => {
process.exit(0)
Expand Down

0 comments on commit 0db1dab

Please sign in to comment.