From fb54026f421b6dba66ae731a5a26d18901d7f6d7 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 10 May 2018 09:51:30 -0400 Subject: [PATCH] Vivaldi: don't assume a tab was opened (#123) This fix permits opening the settings page on Vivaldi. --- tabfern/src/view/const.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tabfern/src/view/const.js b/tabfern/src/view/const.js index 57418b73..974e512c 100755 --- a/tabfern/src/view/const.js +++ b/tabfern/src/view/const.js @@ -110,11 +110,19 @@ }) .then(function open_tab(done, new_win){ win_id = new_win.id; - tab0_id = new_win.tabs[0].id; + // Chrome automatically creates a tab in a window, but + // Vivaldi does not. Handle either. + if(new_win.tabs && new_win.tabs.length) { + tab0_id = new_win.tabs[0].id; + } chrome.tabs.create({windowId: win_id, url: url}, ASQH.CC(done)); }) .then(function remove_old_tab(done){ - chrome.tabs.remove(tab0_id, ASQH.CC(done)); + if(tab0_id) { + chrome.tabs.remove(tab0_id, ASQH.CC(done)); + } else { + done(); + } }) .or(function(err){log_orig.error({'Load error':err, url});}) ;