-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: cp-12.15.0 Prevent fullscreen UI from opening every startup #31332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f047d5
4cb7863
deef539
a4f850c
1893fd8
5f88287
769b7e1
57b406b
75e4743
6c277ee
7e06ea8
18e2d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,22 +141,35 @@ const PHISHING_WARNING_PAGE_TIMEOUT = ONE_SECOND_IN_MILLISECONDS; | |
| // Event emitter for state persistence | ||
| export const statePersistenceEvents = new EventEmitter(); | ||
|
|
||
| if (isFirefox) { | ||
| browser.runtime.onInstalled.addListener(function (details) { | ||
| if (details.reason === 'install') { | ||
| browser.storage.session.set({ isFirstTimeInstall: true }); | ||
| } else if (details.reason === 'update') { | ||
| browser.storage.session.set({ isFirstTimeInstall: false }); | ||
| } | ||
| }); | ||
| } else if (!isManifestV3) { | ||
| browser.runtime.onInstalled.addListener(function (details) { | ||
| if (!isManifestV3) { | ||
| /** | ||
| * `onInstalled` event handler. | ||
| * | ||
| * On MV3 builds we must listen for this event in `app-init`, otherwise we found that the listener | ||
| * is never called. | ||
| * There is no `app-init` file on MV2 builds, so we add a listener here instead. | ||
| * | ||
| * @param {import('webextension-polyfill').Runtime.OnInstalledDetailsType} details - Event details. | ||
| */ | ||
| const onInstalledListener = (details) => { | ||
| if (details.reason === 'install') { | ||
| global.sessionStorage.setItem('isFirstTimeInstall', true); | ||
| } else if (details.reason === 'update') { | ||
| global.sessionStorage.setItem('isFirstTimeInstall', false); | ||
| onInstall(); | ||
| browser.runtime.onInstalled.removeListener(onInstalledListener); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| browser.runtime.onInstalled.addListener(onInstalledListener); | ||
|
|
||
| // This condition is for when the `onInstalled` listener in `app-init` was called before | ||
| // `background.js` was loaded. | ||
| } else if (globalThis.stateHooks.metamaskWasJustInstalled) { | ||
| onInstall(); | ||
| // Delete just to clean up global namespace | ||
| delete globalThis.stateHooks.metamaskWasJustInstalled; | ||
| // This condition is for when `background.js` was loaded before the `onInstalled` listener was | ||
| // called. | ||
| } else { | ||
| globalThis.stateHooks.metamaskTriggerOnInstall = () => onInstall(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -505,12 +518,6 @@ async function initialize() { | |
| await sendReadyMessageToTabs(); | ||
| log.info('MetaMask initialization complete.'); | ||
|
|
||
| if (isManifestV3 || isFirefox) { | ||
| browser.storage.session.set({ isFirstTimeInstall: false }); | ||
| } else { | ||
| global.sessionStorage.setItem('isFirstTimeInstall', false); | ||
| } | ||
|
|
||
| resolveInitialization(); | ||
| } catch (error) { | ||
| rejectInitialization(error); | ||
|
|
@@ -1286,24 +1293,15 @@ const addAppInstalledEvent = () => { | |
| }, 500); | ||
| }; | ||
|
|
||
| // On first install, open a new tab with MetaMask | ||
| async function onInstall() { | ||
| const sessionData = | ||
| isManifestV3 || isFirefox | ||
| ? await browser.storage.session.get(['isFirstTimeInstall']) | ||
| : await global.sessionStorage.getItem('isFirstTimeInstall'); | ||
|
|
||
| const isFirstTimeInstall = sessionData?.isFirstTimeInstall; | ||
|
|
||
| if (process.env.IN_TEST) { | ||
| addAppInstalledEvent(); | ||
| } else if (!isFirstTimeInstall && !process.env.METAMASK_DEBUG) { | ||
| // If storeAlreadyExisted is true then this is a fresh installation | ||
| // and an app installed event should be tracked. | ||
| addAppInstalledEvent(); | ||
| /** | ||
| * Trigger actions that should happen only upon initial install (e.g. open tab for onboarding). | ||
| */ | ||
| function onInstall() { | ||
| log.debug('First install detected'); | ||
| addAppInstalledEvent(); | ||
davidmurdoch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!process.env.IN_TEST && !process.env.METAMASK_DEBUG) { | ||
| platform.openExtensionInBrowser(); | ||
| } | ||
| onNavigateToTab(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why this function was here, it's not really related to the install event. This was being called irrespective of whether this session was the first after install as well, which is confusing. I've moved it down to |
||
| } | ||
|
|
||
| function onNavigateToTab() { | ||
|
|
@@ -1334,7 +1332,7 @@ function setupSentryGetStateGlobal(store) { | |
| } | ||
|
|
||
| async function initBackground() { | ||
| await onInstall(); | ||
| onNavigateToTab(); | ||
| try { | ||
| await initialize(); | ||
| if (process.env.IN_TEST) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.