MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / onWatchFileCodeChanged

Function onWatchFileCodeChanged

src/pages/install/hooks.tsx:492–519  ·  view source on GitHub ↗
(this: FTInfo, code: string, hideInfo: boolean = false)

Source from the content-addressed store, hash-verified

490 const fileWatchMessageId = `id_${Math.random()}`;
491
492 async function onWatchFileCodeChanged(this: FTInfo, code: string, hideInfo: boolean = false) {
493 if (this.uuid !== scriptInfo?.uuid) return;
494 if (this.fileName !== localFileHandle?.name) return;
495 setScriptCode(code);
496 const uuid = (upsertScript as Script)?.uuid;
497 if (!uuid) {
498 throw new Error("uuid is undefined");
499 }
500 try {
501 const newScript = await getUpdatedNewScript(uuid, code);
502 await installOrUpdateScript(newScript, code);
503 } catch (e) {
504 Message.error({
505 id: fileWatchMessageId,
506 content: t("install_failed") + ": " + e,
507 });
508 return;
509 }
510 if (!hideInfo) {
511 Message.info({
512 id: fileWatchMessageId,
513 content: `${t("last_updated")}: ${dayFormat()}`,
514 duration: 3000,
515 closable: true,
516 showIcon: true,
517 });
518 }
519 }
520
521 async function onWatchFileError() {
522 setWatchFile(false);

Callers

nothing calls this directly

Calls 5

dayFormatFunction · 0.90
getUpdatedNewScriptFunction · 0.85
installOrUpdateScriptFunction · 0.85
errorMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected