修复策划事件订阅就绪时序
分离业务读取与订阅代次创建 避免清理窗口悬挂或提前请求
This commit is contained in:
@@ -866,6 +866,12 @@ export function App({
|
||||
}
|
||||
|
||||
function designAgentEventSubscriptionReady() {
|
||||
// 业务动作只读取当前订阅代次;清理与下一次 effect 建立之间不能创建
|
||||
// 一个没有订阅 effect 接管的悬挂 promise。
|
||||
return designAgentEventSubscriptionReadyRef.current ?? Promise.resolve();
|
||||
}
|
||||
|
||||
function createDesignAgentEventSubscriptionReady() {
|
||||
if (!designAgentEventSubscriptionReadyRef.current) {
|
||||
designAgentEventSubscriptionReadyRef.current = new Promise<void>(
|
||||
(resolve) => {
|
||||
@@ -2106,12 +2112,13 @@ export function App({
|
||||
}, [planningV2Active]);
|
||||
|
||||
useEffect(() => {
|
||||
const ready = designAgentEventSubscriptionReady();
|
||||
const ready = createDesignAgentEventSubscriptionReady();
|
||||
if (!canSubscribeTauriEvents() || !planningV2Active) {
|
||||
resolveDesignAgentEventSubscriptionReady();
|
||||
return () => {
|
||||
if (designAgentEventSubscriptionReadyRef.current === ready) {
|
||||
designAgentEventSubscriptionReadyRef.current = null;
|
||||
createDesignAgentEventSubscriptionReady();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -2168,6 +2175,7 @@ export function App({
|
||||
resolveDesignAgentEventSubscriptionReady();
|
||||
if (designAgentEventSubscriptionReadyRef.current === ready) {
|
||||
designAgentEventSubscriptionReadyRef.current = null;
|
||||
createDesignAgentEventSubscriptionReady();
|
||||
}
|
||||
};
|
||||
// applyDesignView 读的是 refs 和当前项目路径,
|
||||
|
||||
Reference in New Issue
Block a user