Skip to content

Commit 29db062

Browse files
committed
autosave interval
1 parent c1f41a4 commit 29db062

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

client/modules/IDE/pages/IDEView.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ const IDEView = (props) => {
115115

116116
// For autosave
117117
useEffect(() => {
118-
let autosaveTimeout;
119-
120118
const handleAutosave = () => {
121119
if (
122120
isUserOwner &&
@@ -136,16 +134,14 @@ const IDEView = (props) => {
136134
}
137135

138136
if (preferences.autosave) {
139-
autosaveTimeout = setTimeout(handleAutosave, 20000);
137+
autosaveIntervalRef.current = setTimeout(handleAutosave, 20000);
140138
}
141-
142-
autosaveIntervalRef.current = autosaveTimeout;
143139
prevFileNameRef.current = selectedFile.name;
144140
prevFileContentRef.current = selectedFile.content;
145141

146142
return () => {
147-
if (autosaveTimeout) {
148-
clearTimeout(autosaveTimeout);
143+
if (autosaveIntervalRef.current) {
144+
clearTimeout(autosaveIntervalRef.current);
149145
}
150146
};
151147
}, [

0 commit comments

Comments
 (0)