|
@@ -34,6 +34,35 @@ function generateBlockError(block) {
|
|
|
return error;
|
|
|
}
|
|
|
|
|
|
+export async function closeTab(block) {
|
|
|
+ const nextBlockId = getBlockConnection(block);
|
|
|
+
|
|
|
+ try {
|
|
|
+ const { data } = block;
|
|
|
+ let tabIds;
|
|
|
+
|
|
|
+ if (data.activeTab && this.tabId) {
|
|
|
+ tabIds = this.tabId;
|
|
|
+ } else if (data.url) {
|
|
|
+ tabIds = (await browser.tabs.query({ url: data.url })).map(
|
|
|
+ (tab) => tab.id
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(tabIds);
|
|
|
+ if (tabIds) await browser.tabs.remove(tabIds);
|
|
|
+
|
|
|
+ return {
|
|
|
+ nextBlockId,
|
|
|
+ data: '',
|
|
|
+ };
|
|
|
+ } catch (error) {
|
|
|
+ const errorInstance = typeof error === 'string' ? new Error(error) : error;
|
|
|
+ errorInstance.nextBlockId = nextBlockId;
|
|
|
+
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+}
|
|
|
export async function trigger(block) {
|
|
|
const nextBlockId = getBlockConnection(block);
|
|
|
try {
|