Reopen a tab on only current tab

This commit is contained in:
Shin'ya Ueoka 2018-06-16 10:47:37 +09:00
parent 9a4dfcbb9f
commit f43345a3a5

View file

@ -59,13 +59,17 @@ const closeTabsByKeywordsForce = (keyword) => {
};
const reopenTab = () => {
return browser.sessions.getRecentlyClosed({
maxResults: 1
let window = null;
return browser.windows.getCurrent().then().then((w) => {
window = w;
return browser.sessions.getRecentlyClosed();
}).then((sessions) => {
if (sessions.length === 0) {
let session = sessions.find((s) => {
return s.tab && s.tab.windowId === window.id;
});
if (!session) {
return;
}
let session = sessions[0];
if (session.tab) {
return browser.sessions.restore(session.tab.sessionId);
}