Skip to content

Commit

Permalink
Wait for 1s before saving user input to opfs
Browse files Browse the repository at this point in the history
This wait time is not final and can change in future. I personally find
that 2s is just too slow to see UI react to my changes (save button
appearing, preview becoming stale etc) so I've decided to change it to
1s.

This value should be as small as possible but we also want to not burn
user's CPU and battery so 1s might be fine.
  • Loading branch information
siddhantk232 authored and amitu committed Sep 18, 2024
1 parent d706e05 commit a1396dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/editor/editor-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/editor/editor-bundle.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion components/editor/editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {indentationMarkers} from '@replit/codemirror-indentation-markers';
import {CommandEditor} from "./command-k/command-editor";


const SAVE_MODIFICATION_WAIT_TIME = 1000;

class CMEditor extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -109,7 +111,7 @@ class CMEditor extends HTMLElement {

const saveUnsavedFile = debounce((file_path, content) => {
window.ide_dispatch_event("save-unsaved-file", {file_path, content});
}, 600);
}, SAVE_MODIFICATION_WAIT_TIME);

customElements.define('cm-editor', CMEditor);
customElements.define('command-editor', CommandEditor);
Expand Down

0 comments on commit a1396dc

Please sign in to comment.