Work related to keyboard shortcuts for page reload

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/896

Additionally, added the keyboard shortcuts to reload the current
tab to the logger. This changes the prior behavior of reloading
the logger content itself.
This commit is contained in:
Raymond Hill 2022-12-25 10:34:53 -05:00
parent 4157171b7f
commit 3f71659aa8
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 51 additions and 9 deletions

View File

@ -1123,16 +1123,42 @@ const pageSelectorFromURLHash = (( ) => {
/******************************************************************************/
const reloadTab = function(ev) {
const reloadTab = function(bypassCache = false) {
const tabId = tabIdFromPageSelector();
if ( tabId <= 0 ) { return; }
messaging.send('loggerUI', {
what: 'reloadTab',
tabId: tabId,
bypassCache: ev && (ev.ctrlKey || ev.metaKey || ev.shiftKey),
tabId,
bypassCache,
});
};
dom.on('#refresh', 'click', ev => {
reloadTab(ev.ctrlKey || ev.metaKey || ev.shiftKey);
});
dom.on(document, 'keydown', ev => {
if ( ev.isComposing ) { return; }
let bypassCache = false;
switch ( ev.key ) {
case 'F5':
bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey;
break;
case 'r':
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
break;
case 'R':
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
bypassCache = true;
break;
default:
return;
}
reloadTab(bypassCache);
ev.preventDefault();
ev.stopPropagation();
}, { capture: true });
/******************************************************************************/
/******************************************************************************/
@ -2824,7 +2850,6 @@ dom.on(window, 'beforeunload', releaseView);
/******************************************************************************/
dom.on('#pageSelector', 'change', pageSelectorChanged);
dom.on('#refresh', 'click', reloadTab);
dom.on('#netInspector .vCompactToggler', 'click', toggleVCompactView);
dom.on('#pause', 'click', pauseNetInspector);

View File

@ -1065,13 +1065,13 @@ const setFirewallRuleHandler = function(ev) {
/******************************************************************************/
const reloadTab = function(ev) {
const reloadTab = function(bypassCache = false) {
messaging.send('popupPanel', {
what: 'reloadTab',
tabId: popupData.tabId,
url: popupData.pageURL,
select: vAPI.webextFlavor.soup.has('mobile'),
bypassCache: ev.ctrlKey || ev.metaKey || ev.shiftKey,
bypassCache,
});
// Polling will take care of refreshing the popup content
@ -1084,12 +1084,29 @@ const reloadTab = function(ev) {
hashFromPopupData(true);
};
dom.on('#refresh', 'click', reloadTab);
dom.on('#refresh', 'click', ev => {
reloadTab(ev.ctrlKey || ev.metaKey || ev.shiftKey);
});
// https://github.com/uBlockOrigin/uBlock-issues/issues/672
dom.on(document, 'keydown', ev => {
if ( ev.code !== 'F5' ) { return; }
reloadTab(ev);
if ( ev.isComposing ) { return; }
let bypassCache = false;
switch ( ev.key ) {
case 'F5':
bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey;
break;
case 'r':
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
break;
case 'R':
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
bypassCache = true;
break;
default:
return;
}
reloadTab(bypassCache);
ev.preventDefault();
ev.stopPropagation();
}, { capture: true });