mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-19 10:36:33 +00:00
Save preferences in sequence (#856)
This commit is contained in:
parent
473cb11053
commit
bc3cb0c230
@ -1,7 +1,7 @@
|
|||||||
import { injectable, inject, postConstruct } from 'inversify';
|
import { injectable, inject, postConstruct } from 'inversify';
|
||||||
import URI from '@theia/core/lib/common/uri';
|
import URI from '@theia/core/lib/common/uri';
|
||||||
import { Emitter } from '@theia/core/lib/common/event';
|
import { Emitter } from '@theia/core/lib/common/event';
|
||||||
import { Deferred } from '@theia/core/lib/common/promise-util';
|
import { Deferred, timeout } from '@theia/core/lib/common/promise-util';
|
||||||
import { deepClone } from '@theia/core/lib/common/objects';
|
import { deepClone } from '@theia/core/lib/common/objects';
|
||||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
||||||
import { ThemeService } from '@theia/core/lib/browser/theming';
|
import { ThemeService } from '@theia/core/lib/browser/theming';
|
||||||
@ -217,6 +217,11 @@ export class SettingsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async savePreference(name: string, value: unknown): Promise<void> {
|
||||||
|
await this.preferenceService.set(name, value, PreferenceScope.User);
|
||||||
|
await timeout(5);
|
||||||
|
}
|
||||||
|
|
||||||
async save(): Promise<string | true> {
|
async save(): Promise<string | true> {
|
||||||
await this.ready.promise;
|
await this.ready.promise;
|
||||||
const {
|
const {
|
||||||
@ -245,69 +250,29 @@ export class SettingsService {
|
|||||||
(config as any).network = network;
|
(config as any).network = network;
|
||||||
(config as any).locale = currentLanguage;
|
(config as any).locale = currentLanguage;
|
||||||
|
|
||||||
await Promise.all([
|
await this.savePreference('editor.fontSize', editorFontSize);
|
||||||
this.preferenceService.set(
|
await this.savePreference('workbench.colorTheme', themeId);
|
||||||
'editor.fontSize',
|
await this.savePreference('editor.autoSave', autoSave);
|
||||||
editorFontSize,
|
await this.savePreference('editor.quickSuggestions', quickSuggestions);
|
||||||
PreferenceScope.User
|
await this.savePreference(AUTO_SCALE_SETTING, autoScaleInterface);
|
||||||
),
|
await this.savePreference(ZOOM_LEVEL_SETTING, interfaceScale);
|
||||||
this.preferenceService.set(
|
await this.savePreference(ZOOM_LEVEL_SETTING, interfaceScale);
|
||||||
'workbench.colorTheme',
|
await this.savePreference(COMPILE_VERBOSE_SETTING, verboseOnCompile);
|
||||||
themeId,
|
await this.savePreference(COMPILE_WARNINGS_SETTING, compilerWarnings);
|
||||||
PreferenceScope.User
|
await this.savePreference(UPLOAD_VERBOSE_SETTING, verboseOnUpload);
|
||||||
),
|
await this.savePreference(UPLOAD_VERIFY_SETTING, verifyAfterUpload);
|
||||||
this.preferenceService.set(
|
await this.savePreference(SHOW_ALL_FILES_SETTING, sketchbookShowAllFiles);
|
||||||
'editor.autoSave',
|
await this.configService.setConfiguration(config);
|
||||||
autoSave,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
'editor.quickSuggestions',
|
|
||||||
quickSuggestions,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
AUTO_SCALE_SETTING,
|
|
||||||
autoScaleInterface,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
ZOOM_LEVEL_SETTING,
|
|
||||||
interfaceScale,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
COMPILE_VERBOSE_SETTING,
|
|
||||||
verboseOnCompile,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
COMPILE_WARNINGS_SETTING,
|
|
||||||
compilerWarnings,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
UPLOAD_VERBOSE_SETTING,
|
|
||||||
verboseOnUpload,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
UPLOAD_VERIFY_SETTING,
|
|
||||||
verifyAfterUpload,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.preferenceService.set(
|
|
||||||
SHOW_ALL_FILES_SETTING,
|
|
||||||
sketchbookShowAllFiles,
|
|
||||||
PreferenceScope.User
|
|
||||||
),
|
|
||||||
this.configService.setConfiguration(config),
|
|
||||||
]);
|
|
||||||
this.onDidChangeEmitter.fire(this._settings);
|
this.onDidChangeEmitter.fire(this._settings);
|
||||||
|
|
||||||
// after saving all the settings, if we need to change the language we need to perform a reload
|
// after saving all the settings, if we need to change the language we need to perform a reload
|
||||||
if (currentLanguage !== nls.locale) {
|
// Only reload if the language differs from the current locale. `nls.locale === undefined` signals english as well
|
||||||
window.localStorage.setItem(nls.localeId, currentLanguage);
|
if (currentLanguage !== nls.locale && !(currentLanguage === 'en' && nls.locale === undefined)) {
|
||||||
|
if (currentLanguage === 'en') {
|
||||||
|
window.localStorage.removeItem(nls.localeId);
|
||||||
|
} else {
|
||||||
|
window.localStorage.setItem(nls.localeId, currentLanguage);
|
||||||
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user