1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Minor improvements

This commit is contained in:
tobspr
2020-05-27 15:45:43 +02:00
parent 52e05f14c0
commit 8c88d738cc
6 changed files with 50 additions and 51 deletions

View File

@@ -131,21 +131,21 @@ export class ReadWriteProxy {
}
const jsonString = JSON_stringify(compressObject(this.currentData));
if (!this.app.pageVisible || this.app.unloaded) {
logger.log("Saving file sync because in unload handler");
const checksum = sha1(jsonString + salt);
let compressed = compressionPrefix + compressX64(checksum + jsonString);
if (G_IS_DEV && IS_DEBUG) {
compressed = jsonString;
}
// if (!this.app.pageVisible || this.app.unloaded) {
// logger.log("Saving file sync because in unload handler");
// const checksum = sha1(jsonString + salt);
// let compressed = compressionPrefix + compressX64(checksum + jsonString);
// if (G_IS_DEV && IS_DEBUG) {
// compressed = jsonString;
// }
if (!this.app.storage.writeFileSyncIfSupported(this.filename, compressed)) {
return Promise.reject("Failed to write " + this.filename + " sync!");
} else {
logger.log("📄 Wrote (sync!)", this.filename);
return Promise.resolve(compressed);
}
}
// if (!this.app.storage.writeFileSyncIfSupported(this.filename, compressed)) {
// return Promise.reject("Failed to write " + this.filename + " sync!");
// } else {
// logger.log("📄 Wrote (sync!)", this.filename);
// return Promise.resolve(compressed);
// }
// }
return asyncCompressor
.compressFileAsync(jsonString)