MCPcopy
hub / github.com/philc/vimium / showUpgradeMessageIfNecessary

Function showUpgradeMessageIfNecessary

background_scripts/main.js:811–849  ·  view source on GitHub ↗
(onInstalledDetails)

Source from the content-addressed store, hash-verified

809
810// Show notification on upgrade.
811async function showUpgradeMessageIfNecessary(onInstalledDetails) {
812 const currentVersion = Utils.getCurrentVersion();
813 // We do not show an upgrade message for patch/silent releases. Such releases have the same
814 // major and minor version numbers.
815 if (
816 !majorVersionHasIncreased(onInstalledDetails.previousVersion) ||
817 Settings.get("hideUpdateNotifications")
818 ) {
819 return;
820 }
821
822 // NOTE(philc): These notifications use the system notification UI. So, if you don't have
823 // notifications enabled from your browser (e.g. in Notification Settings in OSX), then
824 // chrome.notification.create will succeed, but you won't see it.
825 const notificationId = "VimiumUpgradeNotification";
826 await chrome.notifications.create(
827 notificationId,
828 {
829 type: "basic",
830 iconUrl: chrome.runtime.getURL("icons/icon128.png"),
831 title: "Vimium Upgrade",
832 message:
833 `Vimium has been upgraded to version ${currentVersion}. Click here for more information.`,
834 isClickable: true,
835 },
836 );
837 if (!chrome.runtime.lastError) {
838 chrome.notifications.onClicked.addListener(async function (id) {
839 if (id != notificationId) return;
840 const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
841 const tab = tabs[0];
842 TabOperations.openUrlInNewTab({
843 tab,
844 tabId: tab.id,
845 url: "https://github.com/philc/vimium/blob/master/CHANGELOG.md",
846 });
847 });
848 }
849}
850
851async function injectContentScriptsAndCSSIntoExistingTabs() {
852 const manifest = chrome.runtime.getManifest();

Callers 1

main.jsFile · 0.85

Calls 2

majorVersionHasIncreasedFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected