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): 连点复制验证码时只认最新一次的清理凭据

Dash9e99c89c729a
diff --git a/apps/mobile/src/plugins/PluginSetupNativeForm.tsx b/apps/mobile/src/plugins/PluginSetupNativeForm.tsx
index 1f3a83acb7..112e3093f5 100644
--- a/apps/mobile/src/plugins/PluginSetupNativeForm.tsx
+++ b/apps/mobile/src/plugins/PluginSetupNativeForm.tsx
@@ -67,7 +67,8 @@ export default function PluginSetupNativeForm({
alive = useRef(true),
lock = useRef(false),
operation = useRef(0),
- copiedCode = useRef<CopiedCode | undefined>(undefined);
+ copiedCode = useRef<CopiedCode | undefined>(undefined),
+ copyAttempt = useRef(0);
const live = useRef({ focused, epoch: link.connectionEpoch });
live.current = { focused, epoch: link.connectionEpoch };
const [selected, setSelected] = useState<MobilePluginSetupAction | undefined>(
@@ -338,8 +339,11 @@ export default function PluginSetupNativeForm({
accessibilityRole="button"
onPress={() => {
const code = browser.code!;
+ const attempt = ++copyAttempt.current;
void copyCode(code)
.then((copied) => {
+ // Only the latest copy owns the cleanup token.
+ if (attempt !== copyAttempt.current) return;
copiedCode.current = copied;
if (!alive.current) void releaseCopiedCode();
})