Page MenuHomePhabricator

D14478.id42176.diff
No OneTemporary

D14478.id42176.diff

diff --git a/cashtab/src/components/App.js b/cashtab/src/components/App.js
--- a/cashtab/src/components/App.js
+++ b/cashtab/src/components/App.js
@@ -41,6 +41,7 @@
import { checkForTokenById } from 'utils/tokenMethods.js';
import ServiceWorkerWrapper from './Common/ServiceWorkerWrapper';
import aliasSettings from 'config/alias';
+import appConfig from 'config/app';
const GlobalStyle = createGlobalStyle`
*::placeholder {
@@ -488,6 +489,16 @@
}
};
+ const getExtensionInstallationStatus = async () => {
+ // Wait 2s to check
+ // window.bitcoinAbc is set by the extension, and is undefined on page load
+ // We will also want to wait for some configurable interval anyway, so that the page
+ // does not load with a popup
+ const popupWaitInterval = 2000;
+ await new Promise(resolve => setTimeout(resolve, popupWaitInterval));
+ return window && window.bitcoinAbc && window.bitcoinAbc === 'cashtab';
+ };
+
// Easter egg boolean not used in extension/src/components/App.js
const hasTab = validWallet
? checkForTokenById(
@@ -496,8 +507,17 @@
)
: false;
- useEffect(() => {
+ useEffect(async () => {
checkForPersistentStorage();
+ if (appConfig.monitorExtension) {
+ const extensionInstalled = await getExtensionInstallationStatus();
+ // TODO if false and other conditions are met, show popup advertising browser extension
+ console.log(
+ `Cashtab browser extension: ${
+ extensionInstalled ? 'Installed' : 'Not installed'
+ }`,
+ );
+ }
}, []);
return (
diff --git a/cashtab/src/config/app.js b/cashtab/src/config/app.js
--- a/cashtab/src/config/app.js
+++ b/cashtab/src/config/app.js
@@ -21,6 +21,7 @@
notificationDurationShort: 3,
notificationDurationLong: 5,
localStorageMaxCharacters: 24,
+ monitorExtension: false,
};
export default appConfig;

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 22:25 (21 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866057
Default Alt Text
D14478.id42176.diff (1 KB)

Event Timeline