[MM-38695] Fixed minimize to tray setting on Linux (#1767)
* [MM-38695] Fixed minimize to tray setting on Linux * Lint fix
This commit is contained in:
@@ -36,7 +36,6 @@ type ConfigType = typeof CONFIG_TYPE_SERVERS | typeof CONFIG_TYPE_APP_OPTIONS;
|
|||||||
type State = DeepPartial<CombinedConfig> & {
|
type State = DeepPartial<CombinedConfig> & {
|
||||||
ready: boolean;
|
ready: boolean;
|
||||||
maximized?: boolean;
|
maximized?: boolean;
|
||||||
trayWasVisible?: boolean;
|
|
||||||
savingState: SavingStateItems;
|
savingState: SavingStateItems;
|
||||||
userOpenedDownloadDialog: boolean;
|
userOpenedDownloadDialog: boolean;
|
||||||
allowSaveSpellCheckerURL: boolean;
|
allowSaveSpellCheckerURL: boolean;
|
||||||
@@ -122,7 +121,6 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
|
|||||||
|
|
||||||
convertConfigDataToState = (configData: Partial<LocalConfiguration>, currentState: Partial<State> = {}) => {
|
convertConfigDataToState = (configData: Partial<LocalConfiguration>, currentState: Partial<State> = {}) => {
|
||||||
const newState = Object.assign({} as State, configData);
|
const newState = Object.assign({} as State, configData);
|
||||||
newState.trayWasVisible = currentState.trayWasVisible || false;
|
|
||||||
newState.savingState = currentState.savingState || {
|
newState.savingState = currentState.savingState || {
|
||||||
appOptions: SavingState.SAVING_STATE_DONE,
|
appOptions: SavingState.SAVING_STATE_DONE,
|
||||||
servers: SavingState.SAVING_STATE_DONE,
|
servers: SavingState.SAVING_STATE_DONE,
|
||||||
@@ -207,7 +205,7 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleChangeMinimizeToTray = () => {
|
handleChangeMinimizeToTray = () => {
|
||||||
const shouldMinimizeToTray = this.state.showTrayIcon && !this.minimizeToTrayRef.current?.checked;
|
const shouldMinimizeToTray = this.state.showTrayIcon && this.minimizeToTrayRef.current?.checked;
|
||||||
|
|
||||||
window.timers.setImmediate(this.saveSetting, CONFIG_TYPE_APP_OPTIONS, {key: 'minimizeToTray', data: shouldMinimizeToTray});
|
window.timers.setImmediate(this.saveSetting, CONFIG_TYPE_APP_OPTIONS, {key: 'minimizeToTray', data: shouldMinimizeToTray});
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -642,18 +640,20 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
|
|||||||
if (window.process.platform === 'linux') {
|
if (window.process.platform === 'linux') {
|
||||||
options.push(
|
options.push(
|
||||||
<FormCheck
|
<FormCheck
|
||||||
type='radio'
|
|
||||||
key='inputMinimizeToTray'
|
key='inputMinimizeToTray'
|
||||||
id='inputMinimizeToTray'
|
|
||||||
ref={this.minimizeToTrayRef}
|
|
||||||
disabled={!this.state.showTrayIcon || !this.state.trayWasVisible}
|
|
||||||
checked={this.state.minimizeToTray}
|
|
||||||
onChange={this.handleChangeMinimizeToTray}
|
|
||||||
>
|
>
|
||||||
|
<FormCheck.Input
|
||||||
|
type='checkbox'
|
||||||
|
id='inputMinimizeToTray'
|
||||||
|
ref={this.minimizeToTrayRef}
|
||||||
|
disabled={!this.state.showTrayIcon}
|
||||||
|
checked={this.state.minimizeToTray}
|
||||||
|
onChange={this.handleChangeMinimizeToTray}
|
||||||
|
/>
|
||||||
{'Leave app running in notification area when application window is closed'}
|
{'Leave app running in notification area when application window is closed'}
|
||||||
<FormText>
|
<FormText>
|
||||||
{'If enabled, the app stays running in the notification area after app window is closed.'}
|
{'If enabled, the app stays running in the notification area after app window is closed.'}
|
||||||
{this.state.trayWasVisible || !this.state.showTrayIcon ? '' : ' Setting takes effect after restarting the app.'}
|
{this.state.showTrayIcon ? ' Setting takes effect after restarting the app.' : ''}
|
||||||
</FormText>
|
</FormText>
|
||||||
</FormCheck>);
|
</FormCheck>);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user