Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Saving Settings #432

Merged
merged 12 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

[{*.ts,*.js,*.json}]
indent_size = 4

[package.json]
indent_size = 2
45 changes: 45 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript'
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'prettier/prettier': 'warn',
'import/no-unresolved': 'off',
'camelcase': 'warn',
'simple-import-sort/sort': 'warn',
'sort-imports': 'off',
"import/first": "warn",
"import/newline-after-import": "warn",
"import/no-duplicates": "warn",
'import/no-absolute-path': 'warn',
'import/no-unused-modules': 'warn',
'import/no-deprecated': 'warn',
'import/no-self-import': 'error'
},
plugins: [
'@typescript-eslint',
'prettier',
'import',
'simple-import-sort'
],
overrides: [{
'files': '**/*.ts',
'rules': {
'import/order': ['off', {
'newlines-between': 'always'
}],
}
}]
}
11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
endOfLine: 'lf',
jsxBracketSameLine: true,
printWidth: 120,
semi: true,
singleQuote: true,
tabWidth: 4,
trailingComma: 'all'
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- stage: lint
if: branch = master
name: "Linting Application ..."
script: ng lint
script: npm run lint
- stage: build
if: type = push AND branch != master OR type = pull_request
name: "Building Application ..."
Expand Down
97 changes: 54 additions & 43 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,102 @@
const {
app,
BrowserWindow
} = require("electron");
const url = require('url')
const path = require('path')
/* eslint-disable @typescript-eslint/no-var-requires */
const { app, BrowserWindow } = require('electron');
const url = require('url');
const path = require('path');
const Store = require('electron-store');

const store = new Store();
const exec = require('child_process').exec;
const {
ipcMain
} = require('electron')
const { ipcMain } = require('electron');

const args = process.argv.slice(1);
const dev = args.some(val => val === '--serve');
const big = args.some(val => val === '--big')
const big = args.some(val => val === '--big');

app.commandLine.appendSwitch('touch-events', 'enabled');

let window;

function createWindow() {
config = store.get("config");
store.onDidChange("config", (newValue) => {
config = newValue
})

const {
screen
} = require('electron')
config = store.get('config');
store.onDidChange('config', newValue => {
config = newValue;
});

const { screen } = require('electron');
const mainScreen = screen.getPrimaryDisplay();
window = new BrowserWindow({
width: dev ? big ? 1400 : 1080 : mainScreen.size.width,
height: dev ? big ? 502 : 342 : mainScreen.size.height,
width: dev ? (big ? 1400 : 1080) : mainScreen.size.width,
height: dev ? (big ? 502 : 342) : mainScreen.size.height,
frame: dev ? true : false,
backgroundColor: '#353b48',
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
webSecurity: false,
},
icon: path.join(__dirname, 'src/assets/icon.png')
})
icon: path.join(__dirname, 'src/assets/icon.png'),
});

if (dev) {
require('electron-reload')(__dirname, {
electron: require(`${__dirname}/node_modules/electron`)
electron: require(`${__dirname}/node_modules/electron`),
});
window.loadURL('http://localhost:4200');
window.webContents.openDevTools();
} else {
window.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}));
window.setFullScreen(true)
window.loadURL(
url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true,
}),
);
window.setFullScreen(true);
}

setTimeout(sendVersionInfo, 30 * 1000);
activateScreenSleepListener();
activateReloadListener();

window.on('closed', () => {
window = null;
});
}

function activateScreenSleepListener() {
ipcMain.on("screenSleep", () => {
exec('xset dpms force standby')
})
ipcMain.on('screenSleep', () => {
exec('xset dpms force standby');
});

ipcMain.on("screenWakeup", () => {
exec('xset -dpms')
})
ipcMain.on('screenWakeup', () => {
exec('xset -dpms');
});
}

function activateReloadListener() {
ipcMain.on('reload', () => {
window.loadURL(
url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true,
}),
);
});
}

function sendVersionInfo() {
window.webContents.send("versionInformation", {
version: app.getVersion()
})
window.webContents.send('versionInformation', {
version: app.getVersion(),
});
}

app.on('ready', createWindow)
app.on('ready', createWindow);

app.on("window-all-closed", () => {
app.quit()
app.on('window-all-closed', () => {
app.quit();
});

app.on("activate", () => {
app.on('activate', () => {
if (window === null) {
createWindow();
}
Expand Down
Loading