Skip to content

Commit 4fa171b

Browse files
committed
feat: add folo scheme
- Introduced `LEGACY_APP_PROTOCOL` to manage legacy protocol support alongside the new `APP_PROTOCOL`. - Updated various files to utilize the new protocol constants, ensuring compatibility and consistency across the application. - Enhanced mobile app configuration to support multiple schemes for better flexibility. Signed-off-by: Innei <[email protected]>
1 parent 6b4b1f3 commit 4fa171b

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

apps/desktop/forge.config.cts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ const config: ForgeConfig = {
107107
name: "Folo",
108108
schemes: ["follow"],
109109
},
110+
{
111+
name: "Folo",
112+
schemes: ["folo"],
113+
},
110114
],
111115

112116
afterCopy: [

apps/desktop/layer/main/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "./side-effects"
22

33
import { electronApp, optimizer } from "@electron-toolkit/utils"
44
import { callWindowExpose } from "@follow/shared/bridge"
5-
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
5+
import { DEV, LEGACY_APP_PROTOCOL } from "@follow/shared/constants"
66
import { env } from "@follow/shared/env.desktop"
77
import { createBuildSafeHeaders } from "@follow/utils/headers"
88
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
@@ -101,7 +101,7 @@ function bootstrap() {
101101
})
102102

103103
// Set app user model id for windows
104-
electronApp.setAppUserModelId(`re.${APP_PROTOCOL}`)
104+
electronApp.setAppUserModelId(`re.${LEGACY_APP_PROTOCOL}`)
105105

106106
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
107107
details.requestHeaders = buildSafeHeaders({

apps/desktop/layer/main/src/init.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "node:path"
22

33
import { getRendererHandlers, registerIpcMain } from "@egoist/tipc/main"
44
import { PushReceiver } from "@eneris/push-receiver"
5-
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
5+
import { APP_PROTOCOL, DEV, LEGACY_APP_PROTOCOL } from "@follow/shared/constants"
66
import { env } from "@follow/shared/env.desktop"
77
import type { MessagingData } from "@follow/shared/hono"
88
import { app, nativeTheme, Notification, protocol, shell } from "electron"
@@ -31,14 +31,16 @@ export function initializeAppStage0() {
3131
initializeSentry()
3232
}
3333
export const initializeAppStage1 = () => {
34-
if (process.defaultApp) {
35-
if (process.argv.length >= 2) {
36-
app.setAsDefaultProtocolClient(APP_PROTOCOL, process.execPath, [
37-
path.resolve(process.argv[1]!),
38-
])
34+
const protocols = [LEGACY_APP_PROTOCOL, APP_PROTOCOL]
35+
36+
for (const protocol of protocols) {
37+
if (process.defaultApp) {
38+
if (process.argv.length >= 2) {
39+
app.setAsDefaultProtocolClient(protocol, process.execPath, [path.resolve(process.argv[1]!)])
40+
}
41+
} else {
42+
app.setAsDefaultProtocolClient(protocol)
3943
}
40-
} else {
41-
app.setAsDefaultProtocolClient(APP_PROTOCOL)
4244
}
4345

4446
registerIpcMain(router)

apps/desktop/layer/main/src/window.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import path from "node:path"
22
import { fileURLToPath } from "node:url"
33

44
import { is } from "@electron-toolkit/utils"
5-
import { APP_PROTOCOL } from "@follow/shared"
5+
import { LEGACY_APP_PROTOCOL } from "@follow/shared"
66
import { callWindowExpose, WindowState } from "@follow/shared/bridge"
7-
import { DEV } from "@follow/shared/constants"
7+
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
88
import type { BrowserWindowConstructorOptions } from "electron"
99
import { app, BrowserWindow, screen, shell } from "electron"
1010
import type { Event } from "electron/main"
@@ -112,7 +112,16 @@ export function createWindow(
112112
const handleExternalProtocol = async (e: Event, url: string, window: BrowserWindow) => {
113113
const { protocol } = new URL(url)
114114

115-
const ignoreProtocols = ["http", "https", APP_PROTOCOL, "file", "code", "cursor", "app"]
115+
const ignoreProtocols = [
116+
"http",
117+
"https",
118+
LEGACY_APP_PROTOCOL,
119+
APP_PROTOCOL,
120+
"file",
121+
"code",
122+
"cursor",
123+
"app",
124+
]
116125
if (ignoreProtocols.includes(protocol.slice(0, -1))) {
117126
return
118127
}

apps/mobile/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
3737
version: PKG.version,
3838
orientation: "portrait" as const,
3939
icon: iconPath,
40-
scheme: "follow",
40+
scheme: ["follow", "folo"],
4141
userInterfaceStyle: "automatic" as const,
4242
newArchEnabled: true,
4343
ios: {

packages/internal/shared/src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export const { PROD } = import.meta.env
2121
export const DEV =
2222
"process" in globalThis ? process.env.NODE_ENV === "development" : import.meta.env.DEV
2323

24-
export const APP_PROTOCOL = DEV ? "follow-dev" : "follow"
24+
export const LEGACY_APP_PROTOCOL = DEV ? "follow-dev" : "follow"
25+
export const APP_PROTOCOL = DEV ? "folo-dev" : "folo"
2526
export const DEEPLINK_SCHEME = `${APP_PROTOCOL}://` as const
2627

2728
export const SYSTEM_CAN_UNDER_BLUR_WINDOW = globalThis?.window?.electron

0 commit comments

Comments
 (0)