diff --git a/config.js b/config.js index ac273d78..1f7c0b5b 100644 --- a/config.js +++ b/config.js @@ -457,6 +457,10 @@ export const attachBlockMapping = { // perspective. LeftHand (viewer's left) maps to mixamorig:RightHand, etc. export const AUTOSAVE_KEY = "flock_autosave.flock"; +// Feature flag for autosaving to the last explicitly-saved file. localStorage +// autosave is unaffected by this flag. +export const AUTOSAVE_TO_FILE_ENABLED = false; + export const attachMixamoMapping = { LeftHand: "mixamorig:RightHand", Hold: "mixamorig:RightHand", diff --git a/main/files.js b/main/files.js index 6e2c7f9c..871ea85f 100644 --- a/main/files.js +++ b/main/files.js @@ -2,7 +2,7 @@ import * as Blockly from "blockly"; import { workspace } from "./blocklyinit.js"; import { translate } from "./translation.js"; import { getMetadata } from "meta-png"; -import { AUTOSAVE_KEY } from "../config.js"; +import { AUTOSAVE_KEY, AUTOSAVE_TO_FILE_ENABLED } from "../config.js"; // Function to save the current workspace state export function saveWorkspace(workspace) { @@ -509,7 +509,10 @@ let currentFileHandle = null; export function updateSaveButtonState() { document .getElementById("exportCodeButton") - ?.classList.toggle("no-autosave", !currentFileHandle); + ?.classList.toggle( + "no-autosave", + AUTOSAVE_TO_FILE_ENABLED && !currentFileHandle, + ); } // Clears the stored file handle (call whenever a new project is loaded) diff --git a/main/main.js b/main/main.js index 7623a7e4..25c5495f 100644 --- a/main/main.js +++ b/main/main.js @@ -15,7 +15,7 @@ import { import { executeCode, stopCode } from "./execution.js"; import "../ui/addmeshes.js"; import "../ui/colourpicker.js"; -import { TOP_BLOCK_TYPES } from "../config.js"; +import { TOP_BLOCK_TYPES, AUTOSAVE_TO_FILE_ENABLED } from "../config.js"; import { initializeBlocks, initializeWorkspace, @@ -1085,10 +1085,13 @@ window.onload = async function () { console.log("Welcome to Flock XR 🐦🐦🐦"); console.log("Release 1"); - // Autosave every 30 seconds: to localStorage and (if a file was saved) to that file + // Autosave every 30 seconds: to localStorage and (if enabled and a file was + // saved) to that file setInterval(() => { saveWorkspace(workspace); - autoSaveToFile(workspace); + if (AUTOSAVE_TO_FILE_ENABLED) { + autoSaveToFile(workspace); + } }, 30000); (async () => {