From 922ae7a274962fb449af3b2bef96c424f721c3db Mon Sep 17 00:00:00 2001 From: Dick Choi Date: Thu, 14 Jul 2016 14:37:26 +0900 Subject: [PATCH] clean old codes --- browser/lib/fetchConfig.js | 24 -------- browser/main/index.js | 17 ------ browser/main/lib/queue.js | 57 ------------------- .../main/modals/PreferencesModal/ConfigTab.js | 2 - .../main/modals/PreferencesModal/InfoTab.js | 11 +++- 5 files changed, 10 insertions(+), 101 deletions(-) delete mode 100644 browser/lib/fetchConfig.js delete mode 100644 browser/main/lib/queue.js diff --git a/browser/lib/fetchConfig.js b/browser/lib/fetchConfig.js deleted file mode 100644 index e1d40dd4..00000000 --- a/browser/lib/fetchConfig.js +++ /dev/null @@ -1,24 +0,0 @@ -const electron = require('electron') -const remote = electron.remote -const jetpack = require('fs-jetpack') - -const userDataPath = remote.app.getPath('userData') -const configFile = 'config.json' - -const defaultConfig = { - 'editor-font-size': '14', - 'editor-font-family': 'Monaco, Consolas', - 'editor-indent-type': 'space', - 'editor-indent-size': '4', - 'preview-font-size': '14', - 'preview-font-family': 'Lato', - 'switch-preview': 'blur', - 'disable-direct-write': false, - 'theme-ui': 'light', - 'theme-code': 'xcode', - 'theme-syntax': 'xcode' -} - -export default function fetchConfig () { - return Object.assign({}, defaultConfig, JSON.parse(jetpack.cwd(userDataPath).read(configFile, 'utf-8'))) -} diff --git a/browser/main/index.js b/browser/main/index.js index 9e0abe3f..015dffed 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -5,7 +5,6 @@ import React from 'react' import ReactDOM from 'react-dom' require('!!style!css!stylus?sourceMap!./global.styl') import activityRecord from 'browser/lib/activityRecord' -import fetchConfig from '../lib/fetchConfig' import { Router, Route, IndexRoute, IndexRedirect, hashHistory } from 'react-router' import { syncHistoryWithStore } from 'react-router-redux' @@ -14,22 +13,6 @@ const ipc = electron.ipcRenderer const path = require('path') const remote = electron.remote -let config = fetchConfig() -applyConfig(config) - -ipc.on('config-apply', function (e, newConfig) { - config = newConfig - applyConfig(config) -}) - -function applyConfig (config) { - let body = document.body - body.setAttribute('data-theme', config['theme-ui']) - - let hljsCss = document.getElementById('hljs-css') - hljsCss.setAttribute('href', '../node_modules/highlight.js/styles/' + config['theme-code'] + '.css') -} - if (process.env.NODE_ENV !== 'production') { window.addEventListener('keydown', function (e) { if (e.keyCode === 73 && e.metaKey && e.altKey) { diff --git a/browser/main/lib/queue.js b/browser/main/lib/queue.js deleted file mode 100644 index e4adcbfb..00000000 --- a/browser/main/lib/queue.js +++ /dev/null @@ -1,57 +0,0 @@ -import Storage from 'browser/lib/Storage' -import _ from 'lodash' - -let tasks = [] - -function _save (task, storageKey, note) { - note = Object.assign({}, note) - delete note._storage - - task.status = 'process' - - Storage - .find(storageKey) - .then((storage) => { - return storage.updateNote(note.key, note) - }) - .then((note) => { - tasks.splice(tasks.indexOf(task), 1) - console.info('Note saved', note) - }) - .catch((err) => { - tasks.splice(tasks.indexOf(task), 1) - console.error('Failed to save note', note) - console.error(err) - }) -} - -const queueSaving = function (storageKey, note) { - let key = `${storageKey}-${note.key}` - - let taskIndex = _.findIndex(tasks, { - type: 'SAVE_NOTE', - key: key, - status: 'idle' - }) - let task = tasks[taskIndex] - if (taskIndex < 0) { - task = { - type: 'SAVE_NOTE', - key: key, - status: 'idle', - timer: null - } - } else { - tasks.splice(taskIndex, 1) - window.clearTimeout(task.timer) - } - - task.timer = window.setTimeout(() => { - _save(task, storageKey, note) - }, 1500) - tasks.push(task) -} - -export default { - save: queueSaving -} diff --git a/browser/main/modals/PreferencesModal/ConfigTab.js b/browser/main/modals/PreferencesModal/ConfigTab.js index 4ff94320..af789ff4 100644 --- a/browser/main/modals/PreferencesModal/ConfigTab.js +++ b/browser/main/modals/PreferencesModal/ConfigTab.js @@ -1,14 +1,12 @@ import React, { PropTypes } from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './ConfigTab.styl' -import fetchConfig from 'browser/lib/fetchConfig' import hljsTheme from 'browser/lib/hljsThemes' import ConfigManager from 'browser/main/lib/ConfigManager' import store from 'browser/main/store' const electron = require('electron') const ipc = electron.ipcRenderer -const remote = electron.remote const ace = window.ace const OSX = global.process.platform === 'darwin' diff --git a/browser/main/modals/PreferencesModal/InfoTab.js b/browser/main/modals/PreferencesModal/InfoTab.js index ee1bdef9..001773b2 100644 --- a/browser/main/modals/PreferencesModal/InfoTab.js +++ b/browser/main/modals/PreferencesModal/InfoTab.js @@ -3,6 +3,8 @@ import CSSModules from 'browser/lib/CSSModules' import styles from './InfoTab.styl' const appVersion = global.process.version +const electron = require('electron') +const { shell } = electron class InfoTab extends React.Component { constructor (props) { @@ -12,6 +14,11 @@ class InfoTab extends React.Component { } } + handleLinkClick (e) { + shell.openExternal(e.currentTarget.href) + e.preventDefault() + } + render () { return (
@@ -25,7 +32,9 @@ class InfoTab extends React.Component { - License : GPLv3
  • - - Issue Tracker : https://github.com/BoostIO/Boostnote/issues + - Issue Tracker : this.handleLinkClick(e)} + >https://github.com/BoostIO/Boostnote/issues