Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

Add instant subscription sync via deep link after Stripe checkout

Gabriel Stein072762be39e3
diff --git a/main.js b/main.js
index 03aa9d3e2..52605b972 100644
--- a/main.js
+++ b/main.js
@@ -347,6 +347,11 @@ app.on("open-url", (event, url) => {
event.preventDefault();
if (!url.startsWith(`${OAUTH_PROTOCOL}://`)) return;
+ if (url.includes("upgrade-success")) {
+ handleUpgradeDeepLink();
+ return;
+ }
+
handleOAuthDeepLink(url);
if (windowManager && isLiveWindow(windowManager.controlPanelWindow)) {
@@ -396,6 +401,16 @@ function handleOAuthDeepLink(deepLinkUrl) {
}
}
+function handleUpgradeDeepLink() {
+ if (isLiveWindow(windowManager?.controlPanelWindow)) {
+ windowManager.controlPanelWindow.webContents.executeJavaScript(
+ 'window.dispatchEvent(new Event("upgrade-success"))'
+ );
+ windowManager.controlPanelWindow.show();
+ windowManager.controlPanelWindow.focus();
+ }
+}
+
function parseJsonBody(req) {
return new Promise((resolve, reject) => {
let raw = "";
@@ -985,7 +1000,11 @@ if (gotSingleInstanceLock) {
// Check for OAuth protocol URL in command line arguments (Windows/Linux)
const url = commandLine.find((arg) => arg.startsWith(`${OAUTH_PROTOCOL}://`));
if (url) {
- handleOAuthDeepLink(url);
+ if (url.includes("upgrade-success")) {
+ handleUpgradeDeepLink();
+ } else {
+ handleOAuthDeepLink(url);
+ }
}
});
diff --git a/src/hooks/useUsage.ts b/src/hooks/useUsage.ts
index 66c51b49b..29ae09d0f 100644
--- a/src/hooks/useUsage.ts
+++ b/src/hooks/useUsage.ts
@@ -134,11 +134,25 @@ export function useUsage(): UseUsageResult | null {
lastFetchRef.current = 0;
fetchUsage();
};
+ const handleUpgradeSuccess = async () => {
+ lastFetchRef.current = 0;
+ await fetchUsage();
+ // Retry if webhook hasn't updated DB yet
+ for (let i = 0; i < 3; i++) {
+ const result = await window.electronAPI.cloudUsage();
+ if (result.success && result.isSubscribed) break;
+ await new Promise((r) => setTimeout(r, 2000 * (i + 1)));
+ lastFetchRef.current = 0;
+ await fetchUsage();
+ }
+ };
window.addEventListener("focus", handleFocus);
window.addEventListener("usage-changed", handleUsageChanged);
+ window.addEventListener("upgrade-success", handleUpgradeSuccess);
return () => {
window.removeEventListener("focus", handleFocus);
window.removeEventListener("usage-changed", handleUsageChanged);
+ window.removeEventListener("upgrade-success", handleUpgradeSuccess);
};
}, [isLoaded, isSignedIn, fetchUsage]);