@@ -56,8 +56,7 @@ export enum WorkspacesActions {
5656 MoveTab = 'compass-workspaces/MoveTab' ,
5757 OpenTabFromCurrentActive = 'compass-workspaces/OpenTabFromCurrentActive' ,
5858 DuplicateTab = 'compass-workspaces/DuplicateTab' ,
59- CloseTab = 'compass-workspaces/CloseTab' ,
60- CloseAllOtherTabs = 'compass-workspaces/CloseAllOtherTabs' ,
59+ CloseTabs = 'compass-workspaces/CloseTabs' ,
6160 CollectionRenamed = 'compass-workspaces/CollectionRenamed' ,
6261 CollectionRemoved = 'compass-workspaces/CollectionRemoved' ,
6362 DatabaseRemoved = 'compass-workspaces/DatabaseRemoved' ,
@@ -472,25 +471,11 @@ const reducer: Reducer<WorkspacesState, Action> = (
472471 } ;
473472 }
474473
475- if ( isAction < CloseTabAction > ( action , WorkspacesActions . CloseTab ) ) {
474+ if ( isAction < CloseTabsAction > ( action , WorkspacesActions . CloseTabs ) ) {
476475 return _bulkTabsClose ( {
477476 state,
478- isToBeClosed : ( _tab , index ) => {
479- return index === action . atIndex ;
480- } ,
481- } ) ;
482- }
483-
484- if (
485- isAction < CloseAllOtherTabsAction > (
486- action ,
487- WorkspacesActions . CloseAllOtherTabs
488- )
489- ) {
490- return _bulkTabsClose ( {
491- state,
492- isToBeClosed : ( _tab , index ) => {
493- return index !== action . atIndex ;
477+ isToBeClosed : ( tab ) => {
478+ return action . tabIds . includes ( tab . id ) ;
494479 } ,
495480 } ) ;
496481 }
@@ -885,7 +870,7 @@ export const duplicateTab = (atIndex: number): DuplicateTabAction => {
885870 } ;
886871} ;
887872
888- async function confirmClosingTabs ( ) {
873+ async function confirmClosingTab ( ) {
889874 return await showConfirmation ( {
890875 title : 'Are you sure you want to close the tab?' ,
891876 description :
@@ -896,15 +881,15 @@ async function confirmClosingTabs() {
896881 } ) ;
897882}
898883
899- type CloseTabAction = { type : WorkspacesActions . CloseTab ; atIndex : number } ;
884+ type CloseTabsAction = { type : WorkspacesActions . CloseTabs ; tabIds : string [ ] } ;
900885
901886export const closeTab = (
902887 atIndex : number
903- ) : WorkspacesThunkAction < Promise < void > , CloseTabAction > => {
888+ ) : WorkspacesThunkAction < Promise < void > , CloseTabsAction > => {
904889 return async ( dispatch , getState ) => {
905890 const tab = getState ( ) . tabs [ atIndex ] ;
906- if ( canCloseTab ( tab ) || ( await confirmClosingTabs ( ) ) ) {
907- dispatch ( { type : WorkspacesActions . CloseTab , atIndex } ) ;
891+ if ( canCloseTab ( tab ) || ( await confirmClosingTab ( ) ) ) {
892+ dispatch ( { type : WorkspacesActions . CloseTabs , tabIds : [ tab . id ] } ) ;
908893 cleanupLocalAppRegistryForTab ( tab ?. id ) ;
909894 }
910895 } ;
0 commit comments