mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-15 15:26:31 +00:00
Remove settings.getDefaults function
Change-type: patch
This commit is contained in:
parent
9caa42d257
commit
6fcd9e1595
@ -23,7 +23,8 @@ import * as localSettings from './local-settings';
|
|||||||
|
|
||||||
const debug = _debug('etcher:models:settings');
|
const debug = _debug('etcher:models:settings');
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: _.Dictionary<any> = {
|
// exported for tests
|
||||||
|
export const DEFAULT_SETTINGS: _.Dictionary<any> = {
|
||||||
unsafeMode: false,
|
unsafeMode: false,
|
||||||
errorReporting: true,
|
errorReporting: true,
|
||||||
unmountOnSuccess: true,
|
unmountOnSuccess: true,
|
||||||
@ -107,11 +108,3 @@ export function getAll() {
|
|||||||
debug('getAll');
|
debug('getAll');
|
||||||
return _.cloneDeep(settings);
|
return _.cloneDeep(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @summary Get the default setting values
|
|
||||||
*/
|
|
||||||
export function getDefaults() {
|
|
||||||
debug('getDefaults');
|
|
||||||
return _.cloneDeep(DEFAULT_SETTINGS);
|
|
||||||
}
|
|
||||||
|
@ -28,7 +28,6 @@ import * as settings from './app/models/settings';
|
|||||||
import * as analytics from './app/modules/analytics';
|
import * as analytics from './app/modules/analytics';
|
||||||
import { buildWindowMenu } from './menu';
|
import { buildWindowMenu } from './menu';
|
||||||
|
|
||||||
const config = settings.getDefaults();
|
|
||||||
const configUrl =
|
const configUrl =
|
||||||
settings.get('configUrl') || 'https://balena.io/etcher/static/config.json';
|
settings.get('configUrl') || 'https://balena.io/etcher/static/config.json';
|
||||||
const updatablePackageTypes = ['appimage', 'nsis', 'dmg'];
|
const updatablePackageTypes = ['appimage', 'nsis', 'dmg'];
|
||||||
@ -58,17 +57,18 @@ async function checkForUpdates(interval: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createMainWindow() {
|
function createMainWindow() {
|
||||||
|
const fullscreen = Boolean(settings.get('fullscreen'));
|
||||||
const mainWindow = new electron.BrowserWindow({
|
const mainWindow = new electron.BrowserWindow({
|
||||||
width: parseInt(config.width, 10) || 800,
|
width: parseInt(settings.get('width'), 10) || 800,
|
||||||
height: parseInt(config.height, 10) || 480,
|
height: parseInt(settings.get('height'), 10) || 480,
|
||||||
frame: !config.fullscreen,
|
frame: !fullscreen,
|
||||||
useContentSize: false,
|
useContentSize: false,
|
||||||
show: false,
|
show: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
fullscreen: Boolean(config.fullscreen),
|
fullscreen,
|
||||||
fullscreenable: Boolean(config.fullscreen),
|
fullscreenable: fullscreen,
|
||||||
kiosk: Boolean(config.fullscreen),
|
kiosk: fullscreen,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
titleBarStyle: 'hiddenInset',
|
titleBarStyle: 'hiddenInset',
|
||||||
icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'),
|
icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'),
|
||||||
@ -149,8 +149,7 @@ electron.app.on('before-quit', () => {
|
|||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const localSettings = await settings.load();
|
await settings.load();
|
||||||
Object.assign(config, localSettings);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// TODO: What do if loading the config fails?
|
// TODO: What do if loading the config fails?
|
||||||
console.error('Error loading settings:');
|
console.error('Error loading settings:');
|
||||||
|
@ -36,7 +36,7 @@ describe('Browser: settings', function() {
|
|||||||
return settings.reset();
|
return settings.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
const DEFAULT_SETTINGS = settings.getDefaults();
|
const DEFAULT_SETTINGS = _.cloneDeep(settings.DEFAULT_SETTINGS);
|
||||||
|
|
||||||
it('should be able to set and read values', function() {
|
it('should be able to set and read values', function() {
|
||||||
expect(settings.get('foo')).to.be.undefined;
|
expect(settings.get('foo')).to.be.undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user