Skip to content

Commit

Permalink
1.1.3: fix bugs & performance improve
Browse files Browse the repository at this point in the history
 - fix: remove list item will not open the tab
 - fix: restore list from popup
 - perf: set storage at next tick
  • Loading branch information
cnwangjie committed Aug 6, 2018
1 parent 872f1c7 commit 30613f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v1.1.3 8/6/2018

- fix: remove list item will not open the tab
- fix: restore list from popup
- perf: set storage at next tick

### v1.1.2 8/5/2018

- feat: nightmode
Expand Down
16 changes: 16 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if (PRODUCTION) import(
'@/common/tracker'
).then(({tracker}) => tracker())

if (DEBUG) window.tabs = tabs

const getBrowserActionHandler = action => {
if (action === 'store-selected') return () => tabs.storeSelectedTabs()
if (action === 'show-list') return () => tabs.openTabLists()
Expand Down Expand Up @@ -72,6 +74,20 @@ const init = async () => {
await browser.runtime.sendMessage({optionsChangeHandledStatus: 'success'})
if (PRODUCTION) Object.keys(changes).map(key => ga('send', 'event', 'Options', key, changes[key]))
}
if (msg.restoreList) {
const restoreList = msg.restoreList
const listIndex = restoreList.index
const lists = await storage.getLists()
if (restoreList.newWindow) {
tabs.restoreListInNewWindow(lists[listIndex])
} else {
tabs.restoreList(lists[listIndex])
}
if (!lists[listIndex].pinned) {
lists.splice(index, 1)
storage.setLists(lists)
}
}
})
browser.runtime.onUpdateAvailable.addListener(detail => {
window.update = detail.version
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_ext_name__",
"version": "1.1.2",
"version": "1.1.3",
"default_locale": "en",
"description": "__MSG_ext_desc__",
"author": "WangJie <[email protected]>",
Expand Down
8 changes: 5 additions & 3 deletions src/page/DetailList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
class="list-item"
:key="tabIndex">
<v-list-tile-action v-if="removeItemBtnPos === 'left'">
<v-icon class="clear-btn" color="red" @click.stop="removeTab(listIndex, tabIndex)">clear</v-icon>
<v-icon class="clear-btn" color="red" @click.stop.prevent="removeTab(listIndex, tabIndex)">clear</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
Expand All @@ -79,7 +79,7 @@
</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-action v-if="removeItemBtnPos === 'right'">
<v-icon class="clear-btn" color="red" @click.stop="removeTab(listIndex, tabIndex)">clear</v-icon>
<v-icon class="clear-btn" color="red" @click.stop.prevent="removeTab(listIndex, tabIndex)">clear</v-icon>
</v-list-tile-action>
</v-list-tile>
</draggable>
Expand Down Expand Up @@ -155,7 +155,9 @@ export default {
},
storeLists: _.debounce(function() {
console.time('store')
storage.setLists(this.lists).then(() => console.timeEnd('store'))
this.$nextTick(() => {
storage.setLists(this.lists).then(() => console.timeEnd('store'))
})
}, 200),
removeList(listIndex) {
this.lists.splice(listIndex, 1)
Expand Down
14 changes: 6 additions & 8 deletions src/page/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ export default {
this.action = opts.popupItemClickAction
},
clicked(index) {
if (this.action === 'restore') {
tabs.restoreList(this.lists[index])
} else if (this.action === 'restore-new-window') {
tabs.restoreListInNewWindow(this.lists[index])
if (['restore', 'restore-new-window'].includes(this.action)) {
chrome.runtime.sendMessage({restoreList: {
index,
newWindow: this.action === 'restore-new-window',
}})
} else return
if (!this.lists[index].pinned) {
this.lists.splice(index, 1)
storage.setLists(this.lists)
}
if (!this.lists[index].pinned) this.lists.splice(index, 1)
},
}
}
Expand Down

0 comments on commit 30613f0

Please sign in to comment.