Skip to content

Commit

Permalink
Fixed suspended page in tab history issue #323
Browse files Browse the repository at this point in the history
  • Loading branch information
deanoemcke committed Nov 12, 2015
1 parent 0ba20dc commit e762b1e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
29 changes: 18 additions & 11 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,28 @@ var tgs = (function () {
}

function unsuspendTab(tab) {
var url = gsUtils.getSuspendedUrl(tab.url);
chrome.tabs.update(tab.id, {url: url}, function() {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
}
});
var url = gsUtils.getSuspendedUrl(tab.url),
views,
result;

//bit of a hack here as using the chrome.tabs.update method will not allow
//me to 'replace' the url - leaving a suspended tab in the history
/*tabs = chrome.extension.getViews({type: 'tab'});
for (i = 0; i < tabs.length; i++) {
if (tabs[i].location.href === tab.url) {
tabs[i].location.replace(url);
views = chrome.extension.getViews({type: 'tab', "windowId": tab.windowId});
result = views.some(function (view) {
if (view.tabId === tab.id) {
view.location.replace(url);
return true;
}
}*/
});

//if we failed to find the tab with the above method then try to update it directly
if (!result) {
chrome.tabs.update(tab.id, {url: url}, function() {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
}
});
}
}

function handleWindowFocusChanged(windowId) {
Expand Down
10 changes: 6 additions & 4 deletions src/js/suspended.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/*global window, document, chrome, console */
var tabId;

var gsUtils = chrome.extension.getBackgroundPage().gsUtils;
document.getElementById('gsTitle').innerHTML = gsUtils.getSuspendedTitle(window.location.href);
document.getElementById('gsTitle').innerHTML = chrome.extension.getBackgroundPage().gsUtils.getSuspendedTitle(window.location.href);
chrome.tabs.getCurrent(function(tab) {
tabId = tab.id;
});

(function () {
//removed strict mode for compatibility with older versions of chrome
//'use strict';

var gsUtils = chrome.extension.getBackgroundPage().gsUtils;

function generateFaviconUri(url, callback) {
Expand Down

0 comments on commit e762b1e

Please sign in to comment.