Skip to content

Commit

Permalink
Run auto save function when updating tab and Invalid it during sessio…
Browse files Browse the repository at this point in the history
…n restore
  • Loading branch information
sienori committed Nov 23, 2017
1 parent 3be0eb1 commit e201220
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Tab-Session-Manager/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,30 @@ function setAutoSaveListener() {

//ウィンドウを閉じたときに保存
if (S.get().ifAutoSaveWhenClose) {
browser.tabs.onUpdated.addListener(onUpdate);
browser.tabs.onCreated.addListener(autoSaveWhenCloseListener);
browser.tabs.onRemoved.addListener(autoSaveWhenCloseListener);
browser.windows.onCreated.addListener(autoSaveWhenCloseListener);
} else if (browser.tabs.onCreated.hasListener) {
browser.tabs.onUpdated.removeListener(onUpdate);
browser.tabs.onCreated.removeListener(autoSaveWhenCloseListener);
browser.tabs.onRemoved.removeListener(autoSaveWhenCloseListener);
browser.windows.onCreated.removeListener(autoSaveWhenCloseListener);
}
}

function onUpdate(tabId, changeInfo, tab) {
if (changeInfo.status == "complete") {
autoSaveWhenCloseListener();
}
}

function autoSaveWhenCloseListener() {
saveSession("Auto Saved - Window was closed", "auto winClose temp").then(function () {
removeOverLimit("winClose");
});
if (!IsOpeningSession) {
saveSession("Auto Saved - Window was closed", "auto winClose temp").then(function () {
removeOverLimit("winClose");
});
}
};

function removeOverLimit(tagState) {
Expand Down

0 comments on commit e201220

Please sign in to comment.