Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 退出远程桌面时隐藏连接状态提示 (#4326)

Dash5d7f449734af
diff --git a/apps/mobile/src/i18n/locales/en/remoteDesktop.json b/apps/mobile/src/i18n/locales/en/remoteDesktop.json
index e742aec4ba..67ed78f54d 100644
--- a/apps/mobile/src/i18n/locales/en/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/en/remoteDesktop.json
@@ -56,6 +56,7 @@
"connect": "Connect",
"connecting": "Connecting…",
"reconnecting": "Reconnecting…",
+ "lockingOnExit": "Locking computer…",
"disconnected": "Disconnected",
"compatibility": "Compatibility mode · lower frame rate",
"live": "Live",
diff --git a/apps/mobile/src/i18n/locales/ja/remoteDesktop.json b/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
index 7c363c4a30..47bf15bea0 100644
--- a/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/ja/remoteDesktop.json
@@ -56,6 +56,7 @@
"connect": "接続",
"connecting": "接続中…",
"reconnecting": "再接続中…",
+ "lockingOnExit": "コンピューターをロック中…",
"disconnected": "切断済み",
"compatibility": "互換モード · 低フレームレート",
"live": "ライブ映像",
diff --git a/apps/mobile/src/i18n/locales/ko/remoteDesktop.json b/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
index fa4aaac076..0d0a482601 100644
--- a/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/ko/remoteDesktop.json
@@ -56,6 +56,7 @@
"connect": "연결",
"connecting": "연결 중…",
"reconnecting": "다시 연결 중…",
+ "lockingOnExit": "컴퓨터를 잠그는 중…",
"disconnected": "연결 끊김",
"compatibility": "호환 모드 · 낮은 프레임 속도",
"live": "실시간 화면",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json b/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
index 6acfdcdac8..1a6e1a7a54 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/remoteDesktop.json
@@ -56,6 +56,7 @@
"connect": "连接",
"connecting": "连接中…",
"reconnecting": "正在重新连接…",
+ "lockingOnExit": "正在锁定电脑…",
"disconnected": "已断开",
"compatibility": "兼容模式 · 帧率较低",
"live": "实时画面",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json b/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
index c20da6b263..f74184a24c 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/remoteDesktop.json
@@ -56,6 +56,7 @@
"connect": "連線",
"connecting": "連線中…",
"reconnecting": "正在重新連線…",
+ "lockingOnExit": "正在鎖定電腦…",
"disconnected": "已中斷",
"compatibility": "相容模式 · 畫格率較低",
"live": "即時畫面",
diff --git a/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx b/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
index d1dd95989f..600803231e 100644
--- a/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
+++ b/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
@@ -183,6 +183,8 @@ export default function RemoteDesktopScreen() {
useLockOnExitPreference(deviceId);
const exitLock = useRef(false);
const leaving = useRef(false);
+ const [isLeaving, setIsLeaving] = useState(false);
+ const [exitLockPending, setExitLockPending] = useState(false);
const linkRef = useRef(link);
linkRef.current = link;
const { t } = useTranslation();
@@ -236,11 +238,14 @@ export default function RemoteDesktopScreen() {
const [controlReady, setControlReady] = useState(false);
const connectionPending = !error && (!lease || !frameReady || !controlReady);
const showConnectionStatus =
- connectionPending || (!error && status === "reconnecting");
+ !isLeaving && (connectionPending || (!error && status === "reconnecting"));
+ const showExitLockStatus = isLeaving && exitLockPending;
const connectionLabel = t(
- recovery.current.at || status === "reconnecting"
- ? "remoteDesktop.reconnecting"
- : "remoteDesktop.connecting",
+ showExitLockStatus
+ ? "remoteDesktop.lockingOnExit"
+ : recovery.current.at || status === "reconnecting"
+ ? "remoteDesktop.reconnecting"
+ : "remoteDesktop.connecting",
);
const [busy, setBusy] = useState(false);
const [inputMode, setInputMode] = useInputModePreference();
@@ -401,6 +406,7 @@ export default function RemoteDesktopScreen() {
void remotePresentation?.playback(false).catch(() => {});
connecting.current = false;
const previous = active.current;
+ setExitLockPending(Boolean(previous && exiting && exitLock.current));
active.current = null;
pendingVideoSettings.current = null;
if (previous) pendingMediaOffers.current.delete(previous);
@@ -670,6 +676,7 @@ export default function RemoteDesktopScreen() {
const leave = async () => {
if (leaving.current) return;
leaving.current = true;
+ setIsLeaving(true);
recovery.current.enabled = false;
Keyboard.dismiss();
const ending = stop(false, true);
@@ -854,8 +861,16 @@ export default function RemoteDesktopScreen() {
useEffect(() => {
// Route blur means leaving this desktop (including a native back swipe).
// App background/inactive events use pause() without the exit flag.
- if (!focused && !presentation.current) pause(true);
- else if (!active.current) void connectRef.current();
+ if (!focused && !presentation.current) {
+ leaving.current = true;
+ setIsLeaving(true);
+ pause(true);
+ } else if (focused) {
+ leaving.current = false;
+ setIsLeaving(false);
+ setExitLockPending(false);
+ if (!active.current) void connectRef.current();
+ }
}, [focused, pause, videoPreferencesLoaded]);
useEffect(() => {
send({
@@ -1580,7 +1595,9 @@ export default function RemoteDesktopScreen() {
style={styles.webview}
testID="remoteDesktop.viewer"
/>
- {(showConnectionStatus || (!lease && error)) && (
+ {(showConnectionStatus ||
+ showExitLockStatus ||
+ (!lease && error)) && (
<View
pointerEvents="box-none"
style={[
@@ -1588,7 +1605,7 @@ export default function RemoteDesktopScreen() {
{ top: edgePadding.paddingTop + spacing.xs + 44 + spacing.lg },
]}
>
- {showConnectionStatus ? (
+ {showConnectionStatus || showExitLockStatus ? (
<View
style={styles.connectionBadge}
accessibilityRole="progressbar"