Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions main/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () => {
Expand Down
Loading