feat: add hotkey to close all tabs (#2800)

This commit is contained in:
Daniel Roberto 2024-08-14 07:13:32 -03:00 committed by GitHub
parent 1bedfc2046
commit 3b8909e301
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,6 +154,31 @@ export const HotkeysProvider = (props) => {
};
}, [activeTabUid]);
// close all tabs
useEffect(() => {
Mousetrap.bind(['command+shift+w', 'ctrl+shift+w'], (e) => {
const activeTab = find(tabs, (t) => t.uid === activeTabUid);
if (activeTab) {
const collection = findCollectionByUid(collections, activeTab.collectionUid);
if (collection) {
const tabUids = tabs.filter((tab) => tab.collectionUid === collection.uid).map((tab) => tab.uid);
dispatch(
closeTabs({
tabUids: tabUids
})
);
}
}
return false; // this stops the event bubbling
});
return () => {
Mousetrap.unbind(['command+shift+w', 'ctrl+shift+w']);
};
}, [activeTabUid, tabs, collections, dispatch]);
return (
<HotkeysContext.Provider {...props} value="hotkey">
{showSaveRequestModal && (