From 2badb9b1c0bf6628d2a2fc177063fd0c7c7fb08b Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 18 Nov 2024 16:01:00 +0800 Subject: [PATCH] fix: ignore `file` and editor protocols Signed-off-by: Innei --- apps/main/src/window.ts | 5 +++- .../src/modules/upgrade/container.tsx | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/main/src/window.ts b/apps/main/src/window.ts index 981db4896..ce551da7e 100644 --- a/apps/main/src/window.ts +++ b/apps/main/src/window.ts @@ -2,6 +2,7 @@ import path from "node:path" import { fileURLToPath } from "node:url" import { is } from "@electron-toolkit/utils" +import { APP_PROTOCOL } from "@follow/shared" import { callWindowExpose } from "@follow/shared/bridge" import type { BrowserWindowConstructorOptions } from "electron" import { app, BrowserWindow, screen, shell } from "electron" @@ -113,7 +114,9 @@ export function createWindow( const handleExternalProtocol = async (e: Event, url: string, window: BrowserWindow) => { const { protocol } = new URL(url) - if (protocol === "http:" || protocol === "https:" || protocol === "follow:") { + + const ignoreProtocols = ["http", "https", APP_PROTOCOL, "file", "code", "cursor"] + if (ignoreProtocols.includes(protocol.slice(0, -1))) { return } e.preventDefault() diff --git a/apps/renderer/src/modules/upgrade/container.tsx b/apps/renderer/src/modules/upgrade/container.tsx index 0fa07cff6..cfba7f7b9 100644 --- a/apps/renderer/src/modules/upgrade/container.tsx +++ b/apps/renderer/src/modules/upgrade/container.tsx @@ -1,4 +1,5 @@ import { useOnce } from "@follow/hooks" +import { nextFrame } from "@follow/utils/dom" import { getStorageNS } from "@follow/utils/ns" import { repository } from "@pkg" import type { FC } from "react" @@ -72,18 +73,20 @@ const AppNotificationContainer: FC = () => { ? { label: "What's new?", onClick: () => { - present({ - clickOutsideToDismiss: true, - title: "What's new?", - autoFocus: false, - modalClassName: - "relative mx-auto mt-[10vh] scrollbar-none max-w-full overflow-auto px-2 lg:max-w-[65rem] lg:p-0", + nextFrame(() => { + present({ + clickOutsideToDismiss: true, + title: "What's new?", + autoFocus: false, + modalClassName: + "relative mx-auto mt-[10vh] scrollbar-none max-w-full overflow-auto px-2 lg:max-w-[65rem] lg:p-0", - CustomModalComponent: ({ children }) => { - return {children} - }, - content: Changelog, - overlay: true, + CustomModalComponent: ({ children }) => { + return {children} + }, + content: Changelog, + overlay: true, + }) }) }, }