@@ -651,23 +651,57 @@ function actionEditBullet(node_id, node, unused_action_id, unused_action_el)
651
651
/// @param evt {Event} (optional) If truthy, the event that triggered the action
652
652
/// @param is_internal {Boolean} (optional) If truthy, this is an internal
653
653
/// action, so don't prompt for confirmation.
654
+ /// ** Not yet used. **
654
655
function actionDeleteTab ( node_id , node , unused_action_id , unused_action_el ,
655
- evt , is_internal )
656
+ evt , is_internal_unimplemented )
656
657
{
657
658
let tab_val = D . tabs . by_node_id ( node_id ) ;
658
- if ( ! tab_val || ! tab_val . tab_id ) return ;
659
+ if ( ! tab_val ) return ;
660
+ if ( tab_val . tab_id !== K . NONE ) { // Remove open tabs
661
+ chrome . tabs . remove ( tab_val . tab_id , K . ignore_chrome_error ) ;
662
+ } else { // Remove closed tabs
663
+ // TODO implement this
664
+ }
665
+
666
+ // TODO? implement if necessary. At the moment, it doesn't appear
667
+ // that I need this.
668
+ // // We had a click --- hover the node that is now under the mouse.
669
+ // // That is the node that was the next-sibling node before.
670
+ // // This fixes a bug in which clicking the delete button removes the row,
671
+ // // and the row that had been below moves up, but the wholerow hover and the
672
+ // // action buttons don't appear for that row.
673
+ // //
674
+ // // TODO update this when adding full hierarchy (#34).
675
+ //
676
+ // let next_node = T.treeobj.get_next_dom(node, true);
677
+ // if(evt && evt.type === 'click' && next_node) {
678
+ // T.treeobj.hover_node(next_node);
679
+ // }
659
680
660
- // TODO RESUME HERE
661
- // ASQH.NowCCTry((cc)=>{
681
+
682
+ // If it actually disappears, let tabOnRemoved() handle it.
683
+
684
+ // let seq = ASQH.NowCCTry((cc)=>{
662
685
// chrome.tabs.remove(tab_val.tab_id, cc)
663
- // })
664
- // .then((done_or_err)=>{
686
+ // });
687
+ //
688
+ // seq.try((done, maybe_err)=>{
689
+ // if(ASQH.is_asq_try_err(maybe_err)) { return done(); }
690
+ // // If the tab-removal failed, just bail.
691
+ //
665
692
// // Check if the tab still exists. If it had a beforeunload and
666
693
// // the user hit "Stay", it will still be there.
667
694
// // Even if there is a beforeunload popup, it appears that
668
695
// // chrome.runtime.lastError does not show any error. Therefore,
669
696
// // we cannot rely on the error state to tell us whether the tab
670
697
// // is actually closed.
698
+ // chrome.tabs.get(tab_val.tab_id, ASQH.CC(done));
699
+ // // We hope this will fail; if so, the tab is gone.
700
+ //
701
+ // seq.val( (info_or_err) => {
702
+ // if(!ASQH.is_asq_try_err(maybe_err)) return;
703
+ // // If the tab is still there, don't remove it from the tree
704
+ // });
671
705
// });
672
706
673
707
} //actionDeleteTab
@@ -693,6 +727,16 @@ function addTabNodeActions(win_node_id)
693
727
callback : actionEditBullet ,
694
728
dataset : { action : 'editBullet' }
695
729
} ) ;
730
+
731
+ T . treeobj . add_action ( win_node_id , {
732
+ id : 'deleteTab' ,
733
+ class : 'fff-cross ' + K . ACTION_BUTTON_WIN_CLASS ,
734
+ text : ' ' ,
735
+ grouped : true ,
736
+ callback : actionDeleteTab ,
737
+ dataset : { action : 'deleteTab' }
738
+ } ) ;
739
+
696
740
} //addTabNodeActions
697
741
698
742
/// Create a tree node for an open tab.
@@ -1127,17 +1171,25 @@ function treeOnSelect(_evt_unused, evt_data)
1127
1171
log . info ( { 'Actually, button press' :elem , action, evt_data} ) ;
1128
1172
1129
1173
switch ( action ) {
1174
+ // Windows
1130
1175
case 'renameWindow' :
1131
1176
actionRenameWindow ( node . id , node , null , null ) ; break ;
1132
1177
case 'closeWindow' :
1133
1178
actionCloseWindowAndSave ( node . id , node , null , null ) ; break ;
1134
1179
case 'deleteWindow' :
1135
- actionDeleteWindow ( node . id , node , null , null , evt_data . event ) ;
1136
- // Pass the event so actionDeleteWindow will treat it as
1137
- // a click and refresh the hover state.
1180
+ actionDeleteWindow ( node . id , node , null , null , evt_data . event ) ;
1181
+ // Pass the event so actionDeleteWindow will treat it
1182
+ // as a click and refresh the hover state.
1138
1183
break ;
1184
+
1185
+ // Tabs
1139
1186
case 'editBullet' :
1140
1187
actionEditBullet ( node . id , node , null , null ) ; break ;
1188
+ case 'deleteTab' :
1189
+ actionDeleteTab ( node . id , node , null , null , evt_data . event ) ;
1190
+ // as deleteWindow, above.
1191
+ break ;
1192
+
1141
1193
default : break ; //no-op if unknown
1142
1194
}
1143
1195
@@ -1829,7 +1881,7 @@ function tabOnRemoved(tabid, removeinfo)
1829
1881
1830
1882
// See if it's a tab we have already marked as removed. If so,
1831
1883
// whichever code marked it is responsible, and we're off the hook.
1832
- if ( ! tab_val || ! tab_val . tab_id ) return ;
1884
+ if ( ! tab_val || tab_val . tab_id === K . NONE ) return ;
1833
1885
1834
1886
D . tabs . remove_value ( tab_val ) ;
1835
1887
// So any events that are triggered won't try to look for a
0 commit comments