MCPcopy
hub / github.com/philc/vimium / init

Method init

background_scripts/tab_recency.js:21–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19
20 // Add listeners to chrome.tabs, and load the index from session storage.
21 async init() {
22 if (this.initPromise) {
23 await this.initPromise;
24 return;
25 }
26 let resolveFn;
27 this.initPromise = new Promise((resolve, _reject) => {
28 resolveFn = resolve;
29 });
30
31 chrome.tabs.onActivated.addListener((activeInfo) => {
32 this.queueAction("register", activeInfo.tabId);
33 });
34 chrome.tabs.onRemoved.addListener((tabId) => {
35 this.queueAction("deregister", tabId);
36 });
37
38 chrome.tabs.onReplaced.addListener((addedTabId, removedTabId) => {
39 this.queueAction("deregister", removedTabId);
40 this.queueAction("register", addedTabId);
41 });
42
43 chrome.windows.onFocusChanged.addListener(async (windowId) => {
44 if (windowId == chrome.windows.WINDOW_ID_NONE) return;
45 const tabs = await chrome.tabs.query({ windowId, active: true });
46 if (tabs[0]) {
47 this.queueAction("register", tabs[0].id);
48 }
49 });
50
51 await this.loadFromStorage();
52 while (this.queuedActions.length > 0) {
53 const [action, tabId] = this.queuedActions.shift();
54 this.handleAction(action, tabId);
55 }
56 this.loaded = true;
57 resolveFn();
58 }
59
60 // Loads the index from session storage.
61 async loadFromStorage() {

Callers 5

visitPreviousTabFunction · 0.45
initializeExtensionFunction · 0.45
bg_utils.jsFile · 0.45
getFunction · 0.45
filterMethod · 0.45

Calls 3

queueActionMethod · 0.95
loadFromStorageMethod · 0.95
handleActionMethod · 0.95

Tested by

no test coverage detected