mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-02-10 18:15:05 +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(() => {
|
||||
getTools();
|
||||
}, 1000);
|
||||
// update tools every 5 minutes
|
||||
}, 1000 * 60 * 5);
|
||||
}, [isReady, initServers, getTools]);
|
||||
|
||||
useEffect(() => {
|
||||
const handler = () => {
|
||||
getTools();
|
||||
};
|
||||
|
||||
window.addEventListener("tools-changed", handler);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("tools-changed", handler);
|
||||
};
|
||||
}, [getTools]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!tools || !currentProvider) return;
|
||||
|
||||
|
||||
@ -66,6 +66,7 @@ class CustomServers {
|
||||
correctJson.id.includes("tools-" + type)
|
||||
) {
|
||||
this.tools[type] = correctJson.result.tools;
|
||||
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
@ -166,6 +167,7 @@ class CustomServers {
|
||||
process.start();
|
||||
|
||||
this.initCustomServer(type);
|
||||
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||
});
|
||||
};
|
||||
|
||||
@ -186,6 +188,7 @@ class CustomServers {
|
||||
if (this.tools[type]) {
|
||||
delete this.tools[type];
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent("tools-changed"));
|
||||
};
|
||||
|
||||
initCustomServer = (type: string) => {
|
||||
|
||||
Reference in New Issue
Block a user