Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(mobile): make update notices unobtrusive

tianma-ifa4bd980594c8
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index d83d837a..fcbaf781 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -3,7 +3,7 @@
"name": "EdgeEver",
"slug": "edgeever",
"scheme": "edgeever",
- "version": "1.6.16",
+ "version": "1.6.17",
"runtimeVersion": {
"policy": "appVersion"
},
@@ -28,7 +28,7 @@
},
"android": {
"package": "org.edgeever.mobile",
- "versionCode": 40,
+ "versionCode": 41,
"adaptiveIcon": {
"backgroundColor": "#d1fae5",
"backgroundImage": "./assets/icon.png",
diff --git a/apps/mobile/src/lib/mobile-update.tsx b/apps/mobile/src/lib/mobile-update.tsx
index 8ed494aa..2594121b 100644
--- a/apps/mobile/src/lib/mobile-update.tsx
+++ b/apps/mobile/src/lib/mobile-update.tsx
@@ -1,23 +1,25 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import Constants from "expo-constants";
-import { AppState, Linking, Platform, type AppStateStatus } from "react-native";
+import { AppState, Platform, type AppStateStatus } from "react-native";
import * as Updates from "expo-updates";
import { Alert } from "../components/LocalizedText";
import { useMobileLocale } from "./mobile-locale";
-import { findNewerMobileRelease, GITHUB_LATEST_RELEASE_URL, GOOGLE_PLAY_URL, type MobileRelease } from "./mobile-release";
+import { findNewerMobileRelease } from "./mobile-release";
const FOREGROUND_CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000;
-type MobileUpdateStatus = "idle" | "checking" | "downloading" | "ready";
+type MobileUpdateStatus = "idle" | "checking" | "available" | "downloading" | "ready";
type MobileUpdateContextValue = {
checkForUpdate: () => Promise<void>;
+ hasUpdate: boolean;
isSupported: boolean;
status: MobileUpdateStatus;
};
const MobileUpdateContext = createContext<MobileUpdateContextValue>({
checkForUpdate: async () => undefined,
+ hasUpdate: false,
isSupported: false,
status: "idle",
});
@@ -31,54 +33,6 @@ export const MobileUpdateProvider = ({ children }: { children: ReactNode }) => {
const english = resolvedLocale === "en-US";
const installedVersion = Updates.runtimeVersion ?? Constants.expoConfig?.version ?? null;
- const openUpdateUrl = useCallback((url: string) => {
- void Linking.openURL(url).catch(() => {
- Alert.alert(
- english ? "Unable to open update page" : "无法打开更新页面",
- english ? "Open the app store or GitHub Releases and try again." : "请手动打开应用商店或 GitHub Releases 后重试。"
- );
- });
- }, [english]);
-
- const showInstallableUpdatePrompt = useCallback((release: MobileRelease) => {
- Alert.alert(
- english ? "New app version available" : "发现新版本",
- english
- ? `Version v${release.version} is available. This update includes an installable app package and cannot be applied as an in-app update.`
- : `发现可安装的新版本 v${release.version}。此类更新包含新的应用安装包,无法通过应用内热更新完成。`,
- [
- { text: english ? "Later" : "稍后", style: "cancel" },
- { text: "Google Play", onPress: () => openUpdateUrl(GOOGLE_PLAY_URL) },
- { text: "GitHub", onPress: () => openUpdateUrl(GITHUB_LATEST_RELEASE_URL) },
- ]
- );
- }, [english, openUpdateUrl]);
-
- const restart = useCallback(async () => {
- try {
- await Updates.reloadAsync();
- } catch (error) {
- const detail = error instanceof Error ? error.message : String(error);
- Alert.alert(
- english ? "Unable to restart" : "重启失败",
- english ? `Close and reopen EdgeEver to apply the update.\n\n${detail}` : `请关闭并重新打开 EdgeEver 以应用更新。\n\n${detail}`
- );
- }
- }, [english]);
-
- const showRestartPrompt = useCallback(() => {
- Alert.alert(
- english ? "Update ready" : "更新已就绪",
- english
- ? "The update has been downloaded. Restart EdgeEver now to apply it?"
- : "新版本已下载完成。现在重启 EdgeEver 以应用更新吗?",
- [
- { text: english ? "Later" : "稍后", style: "cancel" },
- { text: english ? "Restart now" : "立即重启", onPress: () => void restart() },
- ]
- );
- }, [english, restart]);
-
const runCheck = useCallback((userInitiated: boolean) => {
if (activeCheckRef.current) {
return activeCheckRef.current;
@@ -97,23 +51,21 @@ export const MobileUpdateProvider = ({ children }: { children: ReactNode }) => {
}
const check = (async () => {
- let installableReleaseCheckFailed = false;
try {
setStatus("checking");
- if (userInitiated && Platform.OS === "android") {
+ if (Platform.OS === "android") {
try {
if (!installedVersion) {
throw new Error("Installed app version is unavailable");
}
const release = await findNewerMobileRelease(installedVersion);
if (release) {
- setStatus("idle");
- showInstallableUpdatePrompt(release);
+ setStatus("available");
return;
}
} catch {
- installableReleaseCheckFailed = true;
+ // Fall back to Expo's in-app update check when the release API is unavailable.
}
}
@@ -121,37 +73,12 @@ export const MobileUpdateProvider = ({ children }: { children: ReactNode }) => {
if (!result.isAvailable) {
setStatus("idle");
- if (userInitiated) {
- if (installableReleaseCheckFailed) {
- Alert.alert(
- english ? "Unable to fully check for updates" : "无法完成更新检查",
- english
- ? "No compatible in-app update was found, but the latest installable app version could not be verified. Check your connection and try again."
- : "未发现兼容的应用内热更新,但无法确认最新安装包版本。请检查网络连接后重试。"
- );
- } else {
- Alert.alert(
- english ? "You're up to date" : "已是最新版本",
- english ? "No newer app package or compatible in-app update is available." : "当前没有更新的安装包或兼容的应用内热更新。"
- );
- }
- }
return;
}
- setStatus("downloading");
- await Updates.fetchUpdateAsync();
- setStatus("ready");
- showRestartPrompt();
- } catch (error) {
+ setStatus("available");
+ } catch {
setStatus("idle");
- if (userInitiated) {
- const detail = error instanceof Error ? error.message : String(error);
- Alert.alert(
- english ? "Unable to check for updates" : "检查更新失败",
- english ? `Check your connection and try again.\n\n${detail}` : `请检查网络连接后重试。\n\n${detail}`
- );
- }
}
})();
@@ -160,7 +87,7 @@ export const MobileUpdateProvider = ({ children }: { children: ReactNode }) => {
activeCheckRef.current = null;
});
return check;
- }, [english, installedVersion, isSupported, showInstallableUpdatePrompt, showRestartPrompt]);
+ }, [english, installedVersion, isSupported]);
useEffect(() => {
const attemptAutomaticCheck = () => {
@@ -186,16 +113,13 @@ export const MobileUpdateProvider = ({ children }: { children: ReactNode }) => {
const value = useMemo<MobileUpdateContextValue>(
() => ({
checkForUpdate: () => {
- if (status === "ready") {
- showRestartPrompt();
- return Promise.resolve();
- }
return runCheck(true);
},
+ hasUpdate: status === "available" || status === "ready",
isSupported,
status,
}),
- [isSupported, runCheck, showRestartPrompt, status]
+ [isSupported, runCheck, status]
);
return <MobileUpdateContext.Provider value={value}>{children}</MobileUpdateContext.Provider>;
diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsx
index 3c6a5454..7568f42a 100644
--- a/apps/mobile/src/screens/WorkspaceScreen.tsx
+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx
@@ -125,7 +125,7 @@ import EditorRuntimePrewarm from "../components/EditorRuntimePrewarm";
import { showEdgeEverKeyboard } from "../../modules/edgeever-keyboard";
import LocalTiptapEditor, { type LocalTiptapEditorRef } from "../components/LocalTiptapEditor";
import { resolveMobileThemeStyles, useMobileTheme, type MobileResolvedTheme } from "../lib/mobile-theme";
-import { MobileUpdateCard } from "../components/MobileUpdateCard";
+import { useMobileUpdate } from "../lib/mobile-update";
import { MobileMermaidDiagram, MobileMermaidProvider } from "../components/MobileMermaid";
import { getMobileMarkdownFenceLanguage, trimMobileMarkdownFenceContent } from "../lib/mobile-mermaid";
@@ -1913,7 +1913,6 @@ const SettingsView = ({
</View>
</View>
</View>
- <MobileUpdateCard />
<SystemInfoCard embedded />
</SettingsGroup>
</View>
@@ -3098,6 +3097,7 @@ const AdvancedPlayCard = ({ embedded = false }: { embedded?: boolean }) => {
const SystemInfoCard = ({ embedded = false }: { embedded?: boolean }) => {
const [copied, setCopied] = useState(false);
const [expanded, setExpanded] = useState(false);
+ const { checkForUpdate, hasUpdate, status } = useMobileUpdate();
const localePreference = useMobileLocalePreference();
const copy = getMobileSystemInfoText(localePreference);
const infoItems = getMobileSystemInfoItems(localePreference);
@@ -3115,6 +3115,7 @@ const SystemInfoCard = ({ embedded = false }: { embedded?: boolean }) => {
<View style={styles.settingsGroupHeader}>
<Info color="#047857" size={16} />
<Text style={styles.settingsGroupTitle}>{copy.title}</Text>
+ {hasUpdate ? <View accessibilityLabel="有新版本" style={styles.updateDot} /> : null}
</View>
<Text style={styles.settingsLinkDescription}>{copy.description}</Text>
</View>
@@ -3125,6 +3126,13 @@ const SystemInfoCard = ({ embedded = false }: { embedded?: boolean }) => {
<ActionButton label={copied ? "已复制" : "复制信息"} onPress={copySystemInfo}>
{copied ? <ShieldCheck color="#047857" size={16} /> : <Copy color="#0f172a" size={16} />}
</ActionButton>
+ <ActionButton
+ disabled={status === "checking"}
+ label={status === "checking" ? "正在检查…" : hasUpdate ? "发现新版本" : "检查更新"}
+ onPress={() => void checkForUpdate()}
+ >
+ {status === "checking" ? <ActivityIndicator color="#047857" size="small" /> : <RefreshCw color="#047857" size={16} />}
+ </ActionButton>
<View style={styles.systemInfoRows}>
{Array.from({ length: Math.ceil(infoItems.length / 3) }, (_, rowIndex) => {
const rowItems = infoItems.slice(rowIndex * 3, rowIndex * 3 + 3);
@@ -6174,6 +6182,15 @@ const baseWorkspaceStyles = StyleSheet.create({
gap: 8,
justifyContent: "flex-start",
},
+ updateDot: {
+ backgroundColor: "#10b981",
+ borderColor: "#ffffff",
+ borderRadius: 5,
+ borderWidth: 1,
+ height: 9,
+ marginLeft: 1,
+ width: 9,
+ },
settingsTitle: {
color: "#0f172a",
fontSize: 16,
diff --git a/package.json b/package.json
index 30c99cf7..f2d9e5f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "edgeever",
- "version": "1.6.18",
+ "version": "1.6.19",
"private": true,
"type": "module",
"workspaces": [