UI: Warn player if they are editing and saving files on non-home servers (#1968)

This commit is contained in:
catloversg
2025-02-17 09:26:45 +07:00
committed by GitHub
parent 13990fbe4c
commit 63d7061fd8
4 changed files with 63 additions and 32 deletions
+6 -4
View File
@@ -12,11 +12,13 @@ function getServerCode(scripts: OpenScript[], index: number): string | null {
return data;
}
function dirty(scripts: OpenScript[], index: number): string {
function isUnsavedFile(scripts: OpenScript[], index: number): boolean {
const openScript = scripts[index];
const serverData = getServerCode(scripts, index);
if (serverData === null) return " *";
return serverData !== openScript.code ? " *" : "";
if (serverData === null) {
return true;
}
return serverData !== openScript.code;
}
function reorder(list: unknown[], startIndex: number, endIndex: number): void {
@@ -60,4 +62,4 @@ function makeModel(hostname: string, filename: string, code: string): editor.ITe
return editor.createModel(code, language, uri);
}
export { getServerCode, dirty, reorder, makeModel };
export { getServerCode, isUnsavedFile, reorder, makeModel };