Skip to content

Commit

Permalink
Updated Electron and improved linting/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
morkro committed Sep 16, 2020
1 parent 44ae7de commit 85d0623
Show file tree
Hide file tree
Showing 11 changed files with 3,457 additions and 134 deletions.
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const off = 0
const warn = 1
const error = 2

module.exports = {
env: {
es6: true,
node: true,
browser: true,
},
parserOptions: {
ecmaVersion: 2020,
},
plugins: ['import'],
extends: ['eslint:recommended', 'airbnb/base'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? warn : off,
'no-debugger': process.env.NODE_ENV === 'production' ? error : off,
'no-tabs': 0,
indent: 'off',
quotes: [2, 'single'],
'linebreak-style': [2, 'unix'],
semi: ['error', 'never'],
'consistent-return': 0,
'no-param-reassign': [2, { props: false }],
'object-curly-newline': off,
'valid-jsdoc': [
2,
{
requireReturn: true,
requireReturnDescription: false,
requireParamDescription: false,
},
],
},
}
36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"singleQuote": true,
"semi": false,
"vueIndentScriptAndStyle": true,
"htmlWhitespaceSensitivity": "strict",
"trailingComma": "es5",
"endOfLine": "auto"
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

## 1.0.3

- Updated Electron to latest version and improved linting/formatting

## 1.0.2 - 31.12.2017

### Fixed

- Fixed issue with presentation mode being opened in the browser [#4](https://github.com/morkro/papyrus/issues/4)
- Login into Paper wasn't working [#8](https://github.com/morkro/papyrus/issues/8)
- Minor CSS updates due to a Paper app update [8deac75](https://github.com/morkro/papyrus/commit/8deac75d1b33d79bf9d5bfd081f8a0b3dcca1636)

## 1.0.0 - 30.12.2016

Initial release.
24 changes: 10 additions & 14 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// eslint-disable-next-line
const { ipcRenderer } = require('electron')
const os = require('os')

/**
* Checks if the dynamic user menu has been loaded already.
* @return {Boolean}
*/
function checkForMenuLoaded () {
function checkForMenuLoaded() {
return !!document.querySelector('hp-dropdown-menu-wrapper')
}
/**
Expand All @@ -15,7 +14,7 @@ function checkForMenuLoaded () {
* @param {Function} cb
* @return {undefined}
*/
function forceMenuInit (cb) {
function forceMenuInit(cb) {
const $sidebar = document.querySelector('.hp-sidebar-user')
$sidebar.click()
setTimeout(() => {
Expand All @@ -29,8 +28,7 @@ ipcRenderer.on('log-out', () => {
forceMenuInit(() => {
document.querySelector('.hp-menu ul[role="menu"] li:last-child button').click()
})
}
else {
} else {
document.querySelector('.hp-menu ul[role="menu"] li:last-child button').click()
}
})
Expand All @@ -40,8 +38,7 @@ ipcRenderer.on('show-preferences', () => {
forceMenuInit(() => {
document.querySelector('.hp-button-account-settings-wrapper button').click()
})
}
else {
} else {
document.querySelector('.hp-button-account-settings-wrapper button').click()
}
})
Expand All @@ -53,11 +50,9 @@ ipcRenderer.on('new-document', () => {

if ($docsWrapper) {
$docsWrapper.querySelector('.hp-actions-menu-primary-button').click()
}
else if ($folderWrapper) {
} else if ($folderWrapper) {
$folderWrapper.querySelector('.hp-actions-menu-tertiary-button').click()
}
else if ($editorPage) {
} else if ($editorPage) {
$editorPage.querySelector('.hp-create-pad-button').click()
}
})
Expand All @@ -75,19 +70,20 @@ ipcRenderer.on('new-folder', () => {
})

ipcRenderer.on('download-document', () => {
document.querySelector('.hp-dropdown-menu-wrapper button[data-track-title="export-single"]')
document
.querySelector('.hp-dropdown-menu-wrapper button[data-track-title="export-single"]')
.click()
})

function init () {
function init() {
if (os.platform() === 'darwin') {
document.body.classList.add('papyrus-drag', 'papyrus-better-header')
}

const $homeBtn = document.querySelector('a.maestro-nav__home-button')

if ($homeBtn && $homeBtn !== null) {
$homeBtn.addEventListener('click', event => event.preventDefault())
$homeBtn.addEventListener('click', (event) => event.preventDefault())
}
}

Expand Down
8 changes: 4 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module.exports = new Config({
paperURL: 'https://paper.dropbox.com',
icons: {
osx: 'static/dropbox-osx.png',
tray: 'static/dropbox-tray.png'
tray: 'static/dropbox-tray.png',
},
window: {
width: 1024,
height: 600
}
}
height: 600,
},
},
})
34 changes: 16 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line
const { app, BrowserWindow, Menu, nativeImage, shell } = require('electron')
const { app, BrowserWindow, Menu } = require('electron')
const electronDebug = require('electron-debug')
const path = require('path')
const fs = require('fs')
Expand All @@ -13,25 +12,20 @@ electronDebug()
let quitApplication = false
let mainWindow = null
const { platform } = process
const appIsRunning = app.makeSingleInstance(() => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.show()
}
})

// Ensure only one instance is running
if (appIsRunning) {
app.quit()
app.requestSingleInstanceLock()
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.show()
}

/**
* Toggles window visibility.
* @return {undefined}
*/
function toggleWindow () {
function toggleWindow() {
if (mainWindow.isVisible()) mainWindow.hide()
else mainWindow.show()
}
Expand All @@ -40,7 +34,7 @@ function toggleWindow () {
* Creates a main `BrowserWindow` instance
* @return {BrowserWindow}
*/
function createMainWindow () {
function createMainWindow() {
const windowConfig = config.get('window')
const { paperURL } = config.store
const window = new BrowserWindow({
Expand All @@ -61,8 +55,8 @@ function createMainWindow () {
webSecurity: false,
allowDisplayingInsecureContent: true,
allowRunningInsecureContent: true,
preload: path.join(__dirname, 'browser.js')
}
preload: path.join(__dirname, 'browser.js'),
},
})

window.loadURL(paperURL)
Expand Down Expand Up @@ -96,7 +90,6 @@ app.on('ready', () => {

if (url.split('/').includes('present')) {
pageWindow.loadURL(url)
return
}
})
})
Expand All @@ -113,3 +106,8 @@ app.on('before-quit', () => {
config.set('window', mainWindow.getBounds())
}
})

// Ensure only one instance is running
app.on('second-instance', () => {
app.quit()
})
Loading

0 comments on commit 85d0623

Please sign in to comment.