Skip to content

Commit

Permalink
perf: reduce size & new feature
Browse files Browse the repository at this point in the history
 - pref: reduce size
 - fix: make sure remote options is same as local
 - feat: allow other extension send message to better onetab
  • Loading branch information
cnwangjie committed Sep 6, 2018
1 parent 270d45c commit 9c3ab75
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"stage-2"
],
"plugins": [
"syntax-dynamic-import"
"syntax-dynamic-import",
"lodash"
]
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules/**/*
yarn-error.log
dist
dist.zip
dist.zip
.sonar*
.scanner*
stats.json
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v1.3.3 9/#/2018

- pref: reduce size
- fix: make sure remote options is same as local
- feat: allow other extension send message to better onetab

### v1.3.2 9/5/2018

- pref: use vuex store options and login status
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-loader": "^7.1.4",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.1",
Expand Down
33 changes: 18 additions & 15 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ const dynamicDisableMenu = async () => {
})
}

const commandHandler = async command => {
if (command === 'store-selected-tabs') tabs.storeSelectedTabs()
else if (command === 'store-all-tabs') tabs.storeAllTabs()
else if (command === 'restore-lastest-list') {
const lists = await storage.getLists()
if (lists.length === 0) return true
const lastest = lists[0]
await tabs.restoreList(lastest)
if (lastest.pinned) return true
lists.shift()
return storage.setLists(lists)
} else if (command === 'open-lists') tabs.openTabLists()
else return true
if (PRODUCTION) ga('send', 'event', 'Command', 'used', command)
}

const init = async () => {
const opts = window.opts = await storage.getOptions() || {}
_.defaults(opts, options.getDefaultOptions())
Expand Down Expand Up @@ -156,6 +172,8 @@ const init = async () => {
boss.forceDownloadRemoteImmediate()
}
})
browser.runtime.onMessageExternal.addListener(commandHandler)
browser.commands.onCommand.addListener(commandHandler)
browser.runtime.onUpdateAvailable.addListener(detail => {
window.update = detail.version
})
Expand All @@ -170,21 +188,6 @@ const init = async () => {
window.coverBrowserAction(activeInfo)
dynamicDisableMenu(activeInfo)
}, 200))
browser.commands.onCommand.addListener(async command => {
if (command === 'store-selected-tabs') tabs.storeSelectedTabs()
else if (command === 'store-all-tabs') tabs.storeAllTabs()
else if (command === 'restore-lastest-list') {
const lists = await storage.getLists()
if (lists.length === 0) return true
const lastest = lists[0]
await tabs.restoreList(lastest)
if (lastest.pinned) return true
lists.shift()
return storage.setLists(lists)
} else if (command === 'open-lists') tabs.openTabLists()
else return true
if (PRODUCTION) ga('send', 'event', 'Command', 'used', command)
})
browser.storage.onChanged.addListener(changes => {
console.log(changes)
if (changes.boss_token) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/service/boss.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const uploadImmediate = async () => {
return (k in localOpts) && v !== localOpts[k]
})
if (_.isEmpty(diff)) {
todo.opts = opts
todo.opts = localOpts
delete conflict.opts
} else {
conflict.opts = {
Expand Down
39 changes: 39 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
dependencies:
"@babel/types" "7.0.0-beta.44"

"@babel/helper-module-imports@^7.0.0-beta.49":
version "7.0.0"
resolved "http://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d"
dependencies:
"@babel/types" "^7.0.0"

"@babel/[email protected]":
version "7.0.0-beta.44"
resolved "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz#c0b351735e0fbcb3822c8ad8db4e583b05ebd9dc"
Expand Down Expand Up @@ -78,6 +84,14 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@babel/types@^7.0.0", "@babel/types@^7.0.0-beta.49":
version "7.0.0"
resolved "http://registry.npm.taobao.org/@babel/types/download/@babel/types-7.0.0.tgz#6e191793d3c854d19c6749989e3bc55f0e962118"
dependencies:
esutils "^2.0.2"
lodash "^4.17.10"
to-fast-properties "^2.0.0"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "http://registry.npm.taobao.org/@mrmlnc/readdir-enhanced/download/@mrmlnc/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
Expand Down Expand Up @@ -668,6 +682,16 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"

babel-plugin-lodash@^3.3.4:
version "3.3.4"
resolved "http://registry.npm.taobao.org/babel-plugin-lodash/download/babel-plugin-lodash-3.3.4.tgz#4f6844358a1340baed182adbeffa8df9967bc196"
dependencies:
"@babel/helper-module-imports" "^7.0.0-beta.49"
"@babel/types" "^7.0.0-beta.49"
glob "^7.1.1"
lodash "^4.17.10"
require-package-name "^2.0.1"

babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "http://registry.npm.taobao.org/babel-plugin-syntax-async-functions/download/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
Expand Down Expand Up @@ -2824,6 +2848,17 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.1.1:
version "7.1.3"
resolved "http://registry.npm.taobao.org/glob/download/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

global-modules@^1.0.0:
version "1.0.0"
resolved "http://registry.npm.taobao.org/global-modules/download/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea"
Expand Down Expand Up @@ -5556,6 +5591,10 @@ require-main-filename@^1.0.1:
version "1.0.1"
resolved "http://registry.npm.taobao.org/require-main-filename/download/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"

require-package-name@^2.0.1:
version "2.0.1"
resolved "http://registry.npm.taobao.org/require-package-name/download/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9"

require-uncached@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3"
Expand Down

0 comments on commit 9c3ab75

Please sign in to comment.