Skip to content

Commit

Permalink
Fixed bug introduced in 1.13, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
ibillingsley committed May 12, 2014
1 parent 917460e commit a34a962
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This project is licensed under the **MIT License**, see [LICENSE_MIT.txt](LICENS
Changelog
---------

### Version 1.13 - May 11, 2014
### Version 1.14 - May 11, 2014

- Reduced memory usage
- Added option to set number of items for recently closed, recent bookmarks, and most visited
Expand Down
19 changes: 14 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

// store tab info in local storage
function storeTabs(tabs) {
var cached = JSON.parse(localStorage.getItem('closed.tabs')) || {};
function storeTabs(tabs, cached) {
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (tab.url && tab.url.substring(0, 15) !== 'chrome://newtab')
Expand All @@ -18,13 +17,21 @@ function notifyChange() {
}

// store initial tabs
chrome.tabs.query({}, function(result) {
storeTabs(result);
chrome.runtime.onStartup.addListener(function() {
chrome.tabs.query({}, function(result) {
storeTabs(result, {});
});
});

chrome.runtime.onInstalled.addListener(function() {
chrome.tabs.query({}, function(result) {
storeTabs(result, {});
});
});

// store tab info on change
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
storeTabs([tab]);
storeTabs([tab], JSON.parse(localStorage.getItem('closed.tabs')) || {});
});

// store removed tab info
Expand Down Expand Up @@ -68,6 +75,7 @@ chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {

delete tabs[tabId];
notifyChange();
storeTabs([], tabs);
return;
}

Expand All @@ -85,4 +93,5 @@ chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {

delete tabs[tabId];
notifyChange();
storeTabs([], tabs);
});
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "Humble New Tab Page",
"version" : "1.13",
"version" : "1.14",
"manifest_version": 2,
"description" : "Redesigned new tab page featuring your bookmarks, apps, most visited, recently closed, and weather in a custom layout.",
"icons" : {
Expand Down

0 comments on commit a34a962

Please sign in to comment.