()
| 84 | }); |
| 85 | |
| 86 | async function showWelcomePage(): Promise<void> { |
| 87 | if (await welcomeShown.get()) { |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | const [hasStoredToken, hasPermissions] = await Promise.all([ |
| 92 | hasToken(), // We can't handle an invalid token on a "Welcome" page, so just check whether the user has ever set one |
| 93 | chrome.permissions.contains({origins: ['https://github.com/*']}), |
| 94 | ]); |
| 95 | |
| 96 | try { |
| 97 | if (hasStoredToken && hasPermissions) { |
| 98 | // Mark as welcomed |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | const url = chrome.runtime.getURL('assets/welcome.html'); |
| 103 | await chrome.tabs.create({url}); |
| 104 | } finally { |
| 105 | // Make sure it's always set to true even in case of errors |
| 106 | await welcomeShown.set(true); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | chrome.runtime.onInstalled.addListener(async () => { |
| 111 | if (isDevelopmentVersion()) { |
no test coverage detected