(this: FTInfo, code: string, hideInfo: boolean = false)
| 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); |
nothing calls this directly
no test coverage detected