mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-22 00:17:32 +09:00
fuck this shit bro (add tabs.onReplaced notification)
This commit is contained in:
parent
e5a431b519
commit
5ac0d5acc3
6 changed files with 108 additions and 7 deletions
|
|
@ -103,6 +103,7 @@ let tabListener = {
|
|||
|
||||
AllWindowEvents.addListener("TabClose", this);
|
||||
AllWindowEvents.addListener("TabOpen", this);
|
||||
AllWindowEvents.addListener("TabReplaced", this);
|
||||
WindowListManager.addOpenListener(this.handleWindowOpen);
|
||||
WindowListManager.addCloseListener(this.handleWindowClose);
|
||||
|
||||
|
|
@ -138,6 +139,10 @@ let tabListener = {
|
|||
this.emitRemoved(tab, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case "TabReplaced":
|
||||
this.emitReplaced(event.detail.addedTab, event.detail.removedTab);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -220,6 +225,13 @@ let tabListener = {
|
|||
}, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
emitReplaced(addedTab, removedTab) {
|
||||
this.emit("tab-replaced", {
|
||||
addedTabId: TabManager.getId(addedTab),
|
||||
removedTabId: TabManager.getId(removedTab),
|
||||
});
|
||||
},
|
||||
|
||||
tabReadyInitialized: false,
|
||||
tabReadyPromises: new WeakMap(),
|
||||
initializingTabs: new WeakSet(),
|
||||
|
|
@ -347,7 +359,15 @@ extensions.registerSchemaAPI("tabs", "addon_parent", context => {
|
|||
};
|
||||
}).api(),
|
||||
|
||||
onReplaced: ignoreEvent(context, "tabs.onReplaced"),
|
||||
onReplaced: new EventManager(context, "tabs.onReplaced", fire => {
|
||||
let listener = (eventName, event) => {
|
||||
fire(event.addedTabId, event.removedTabId);
|
||||
};
|
||||
tabListener.on("tab-replaced", listener);
|
||||
return () => {
|
||||
tabListener.off("tab-replaced", listener);
|
||||
};
|
||||
}).api(),
|
||||
|
||||
onMoved: new EventManager(context, "tabs.onMoved", fire => {
|
||||
// There are certain circumstances where we need to ignore a move event.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue