Skip to content

Commit

Permalink
Prompt before closing tabs playing audio
Browse files Browse the repository at this point in the history
Fixes #306
  • Loading branch information
cxw42 committed Oct 8, 2023
1 parent 0ca60e0 commit c9e9bb9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/settings/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ setting_definitions.push(
"type": "description",
"text": (
`<ul>
<li>The prompt for confirmation when closing audible tabs now applies to
individual tabs ${issue(306)}.</li>
<li>Bugfixes ${issue(322)}</li>
</ul>
`
Expand Down
50 changes: 37 additions & 13 deletions app/win/main_tl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1123,22 +1123,46 @@ function actionCloseTabAndSave(tab_node_id, tab_node, unused_action_id, unused_a
let tab_val = D.tabs.by_node_id(tab_node_id);
if(!tab_val || tab_val.tab_id === K.NONE) return; //already closed => nop
let window_node_id = tab_node.parent;
M.remember(window_node_id);

let tab_id = tab_val.tab_id; // since markTabAsClosed clears it
M.markTabAsClosed(tab_val);
function doCloseAndSave() {
M.remember(window_node_id);

let seq = ASQH.NowCC((cc)=>{
chrome.tabs.remove(tab_id, cc);
// Because the tab is already marked as closed, onTabRemoved()
// won't delete its node.
});
let tab_id = tab_val.tab_id; // since markTabAsClosed clears it
M.markTabAsClosed(tab_val);

seq.val(()=>{
// Refresh the tab.index values for the remaining tabs
M.updateTabIndexValues(window_node_id);
saveTree();
});
let seq = ASQH.NowCC((cc)=>{
chrome.tabs.remove(tab_id, cc);
// Because the tab is already marked as closed, onTabRemoved()
// won't delete its node.
});

seq.val(()=>{
// Refresh the tab.index values for the remaining tabs
M.updateTabIndexValues(window_node_id);
saveTree();
});
}

let need_confirmation_audible = (
(tab_val.isAudible && S.isCONFIRM_DEL_OF_AUDIBLE_TABS())
);

if(!need_confirmation_audible) {
doCloseAndSave();
} else {
showConfirmationModalDialog(
_T('dlgpCloseAudibleTab', M.get_html_label(tab_val)),
!need_confirmation_audible,
// "Don't show again" is hidden if it was just about audio
)

// Processing after the dialog closes
.val((result)=>{
if(result && result.reason === 'yes') {
doCloseAndSave();
}
})
}

} //actionCloseTabAndSave()

Expand Down
10 changes: 10 additions & 0 deletions static/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
}
}
}
, "dlgpCloseAudibleTab": {
"message": "Registerkarte \"$TITLE$\" schließen? Sie spielt jetzt Musik."
,"description":"Prompt for whether the user wants to delete a tab that is playing music (audible)."
,"placeholders":{
"title": {
"content": "$1"
,"example": "(this is the title of the tab that will be closed)"
}
}
}
, "dlgpCloseAudibleWindow": {
"message": "Fenster \"$TITLE$\" schließen? Es spielt jetzt Musik."
,"description":"Prompt for whether the user wants to delete a window that is playing music (audible)."
Expand Down
10 changes: 10 additions & 0 deletions static/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
}
}
}
, "dlgpCloseAudibleTab": {
"message": "Close tab \"$TITLE$\"? It is currently playing music."
,"description":"Prompt for whether the user wants to delete a tab that is playing music (audible)."
,"placeholders":{
"title": {
"content": "$1"
,"example": "(this is the title of the tab that will be closed)"
}
}
}
, "dlgpCloseAudibleWindow": {
"message": "Close window \"$TITLE$\"? It is currently playing music."
,"description":"Prompt for whether the user wants to delete a window that is playing music (audible)."
Expand Down
10 changes: 10 additions & 0 deletions static/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
}
}
}
, "dlgpCloseAudibleTab": {
"message": "Fermer \"$TITLE$\"? It is currently playing music."
,"description":"Prompt for whether the user wants to delete a tab that is playing music (audible). TODO TRANSLATE"
,"placeholders":{
"title": {
"content": "$1"
,"example": "(this is the title of the tab that will be closed)"
}
}
}
, "dlgpCloseAudibleWindow": {
"message": "Fermer \"$TITLE$\"? It is currently playing music."
,"description":"Prompt for whether the user wants to delete a window that is playing music (audible). TODO TRANSLATE"
Expand Down
10 changes: 10 additions & 0 deletions static/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
}
}
}
, "dlgpCloseAudibleTab": {
"message": "Закрыть вкладку \"$TITLE$\"? В текущем окне воспроизводится музыка."
,"description":"Prompt for whether the user wants to delete a tab that is playing music (audible). (TODO check/fix translation)"
,"placeholders":{
"title": {
"content": "$1"
,"example": "(this is the title of the tab that will be closed)"
}
}
}
, "dlgpCloseAudibleWindow": {
"message": "Закрыть окно \"$TITLE$\"? В текущем окне воспроизводится музыка."
,"description":"Prompt for whether the user wants to delete a window that is playing music (audible). TODO TRANSLATE"
Expand Down

0 comments on commit c9e9bb9

Please sign in to comment.