Skip to content

Commit

Permalink
Add informative tooltip re. unprocessed requests at launch
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 9, 2023
1 parent c5d62d9 commit 3530b9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 8 additions & 10 deletions platform/common/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,8 @@ if ( webext.browserAction instanceof Object ) {

{
const browserAction = vAPI.browserAction;
const titleTemplate =
browser.runtime.getManifest().browser_action.default_title +
' ({badge})';
const titleTemplate = `${browser.runtime.getManifest().browser_action.default_title} ({badge})`;
const browserLaunchIssue = browser.i18n.getMessage('unprocessedRequestTooltip');
const icons = [
{ path: {
'16': 'img/icon_16-off.png',
Expand Down Expand Up @@ -840,8 +839,9 @@ if ( webext.browserAction instanceof Object ) {
const tab = await vAPI.tabs.get(tabId);
if ( tab === null ) { return; }

const hasUnprocessedRequest = vAPI.net && vAPI.net.hasUnprocessedRequest(tabId);
const { parts, state } = details;
const { badge, color } = vAPI.net && vAPI.net.hasUnprocessedRequest(tabId)
const { badge, color } = hasUnprocessedRequest
? { badge: '!', color: '#FC0' }
: details;

Expand All @@ -866,13 +866,11 @@ if ( webext.browserAction instanceof Object ) {
// - the platform does not support browserAction.setIcon(); OR
// - the rendering of the badge is disabled
if ( browserAction.setTitle !== undefined ) {
browserAction.setTitle({
tabId: tab.id,
title: titleTemplate.replace(
'{badge}',
const title = hasUnprocessedRequest && browserLaunchIssue ||
titleTemplate.replace('{badge}',
state === 1 ? (badge !== '' ? badge : '0') : 'off'
)
});
);
browserAction.setTitle({ tabId: tab.id, title });
}

if ( vAPI.contextMenu instanceof Object ) {
Expand Down
4 changes: 4 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,10 @@
"message": "Errors: {{count}}",
"description": "Summary of number of errors as reported by the linter "
},
"unprocessedRequestTooltip": {
"message": "Could not filter properly at browser launch.\nReload the page to ensure proper filtering",
"description": "Tooltip for the toolbar icon. Use newline character(s) where appropriate to prevent tooltip from being too long horizontally"
},
"dummy": {
"message": "This entry must be the last one",
"description": "so we dont need to deal with comma for last entry"
Expand Down

0 comments on commit 3530b9d

Please sign in to comment.