mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-03-31 10:23:12 +08:00
Merge pull request 'AIAgent: remove polling every second' (#40) from bugfix/ai-agent into release/v9.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/desktop-sdk/pulls/40
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -20,9 +20,22 @@ const useServers = ({ isReady }: UseServersProps) => {
|
|||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
getTools();
|
getTools();
|
||||||
}, 1000);
|
// update tools every 5 minutes
|
||||||
|
}, 1000 * 60 * 5);
|
||||||
}, [isReady, initServers, getTools]);
|
}, [isReady, initServers, getTools]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = () => {
|
||||||
|
getTools();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("tools-changed", handler);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("tools-changed", handler);
|
||||||
|
};
|
||||||
|
}, [getTools]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tools || !currentProvider) return;
|
if (!tools || !currentProvider) return;
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ class CustomServers {
|
|||||||
correctJson.id.includes("tools-" + type)
|
correctJson.id.includes("tools-" + type)
|
||||||
) {
|
) {
|
||||||
this.tools[type] = correctJson.result.tools;
|
this.tools[type] = correctJson.result.tools;
|
||||||
|
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
@ -166,6 +167,7 @@ class CustomServers {
|
|||||||
process.start();
|
process.start();
|
||||||
|
|
||||||
this.initCustomServer(type);
|
this.initCustomServer(type);
|
||||||
|
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -186,6 +188,7 @@ class CustomServers {
|
|||||||
if (this.tools[type]) {
|
if (this.tools[type]) {
|
||||||
delete this.tools[type];
|
delete this.tools[type];
|
||||||
}
|
}
|
||||||
|
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||||
};
|
};
|
||||||
|
|
||||||
initCustomServer = (type: string) => {
|
initCustomServer = (type: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user