From 1bba4670adf021f3c6bfb59ca731a9d9a3d9300a Mon Sep 17 00:00:00 2001 From: Vladyslav Sitalo Date: Tue, 18 Jan 2022 21:46:15 -0800 Subject: [PATCH] Remove explicit state management as it's maintained as a part of the sidebar --- src/background/index.js | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/background/index.js b/src/background/index.js index 40c8b2e..19cefc2 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -6,14 +6,6 @@ import {setupCommandListener} from "./command-listener" import browser from 'webextension-polyfill' import {Browser} from "../core/browser" -let tabStates = {}; - -function initTabState(tab) { - if (!tabStates[tab.id]) { - tabStates[tab.id] = {} - } -} - window.sidebarLocked = false; function pushProposalToSidebar(proposals, tid) { @@ -29,8 +21,6 @@ const toggleInlineSidebar = async () => Browser.sendMessageToActiveTab({type: "toggle-sidebar"}) async function toggleSidebar(tab) { - initTabState(tab) - if (browser.sidebarAction) { // if a user input handler waits on a promise, then its status as a user input handler is lost // and this call won't work @@ -39,14 +29,9 @@ async function toggleSidebar(tab) { await browser.sidebarAction.toggle() } else { // todo I actually want this one in FF too, need a setting + // also rn the shortcut only works with the iframe sidebar, so there need to call this function instead await toggleInlineSidebar() } - - if (tabStates[tab.id].mode === 'show_entity') { - await pushEnitiyToSidebar(tabStates[tab.id].entity, tab.id) - } else if (tabStates[tab.id].mode === 'propose_match') { - await pushProposalToSidebar(tabStates[tab.id].proposals, tab.id) - } } browser.browserAction.onClicked.addListener(toggleSidebar) @@ -62,8 +47,6 @@ async function addToUrlCache(id, url) { async function handleMatchEvent(event, sender) { if (!sidebarLocked) { - tabStates[sender.tab.id].mode = 'show_entity' - tabStates[sender.tab.id].entity = event.wdEntityId await browser.browserAction.setIcon({ path: activeIcon, tabId: sender.tab.id, @@ -124,9 +107,6 @@ function clearPageLinks() { } async function handleMatchProposal(event, sender) { - tabStates[sender.tab.id].mode = 'propose_match' - tabStates[sender.tab.id].proposals = event.proposals - await browser.browserAction.setIcon({ path: "icons/halfactive.svg", tabId: sender.tab.id, @@ -141,8 +121,6 @@ async function handleMatchProposal(event, sender) { } async function resetState(sender) { - tabStates[sender.tab.id].mode = false - await browser.browserAction.setIcon({ path: "icons/inactive.svg", tabId: sender.tab.id, @@ -170,8 +148,6 @@ browser.runtime.onMessage.addListener(async (data, sender) => { // todo is this different in the inline-sidebar world? if (sender.tab) { - initTabState(sender.tab) - if (data.type === 'match_event') { await handleMatchEvent(data, sender) } else if (data.type === 'match_proposal') {