-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/#313 autosave local storage step 1 #350
Conversation
src/core/autosave/autosave.hook.tsx
Outdated
const { filename, setFilename, setLoadSample } = | ||
useCanvasViewSettingsContext(); | ||
|
||
const INTERVAL = 6000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interval should be at least 60000 (60 seconds)
src/core/autosave/autosave.hook.tsx
Outdated
} | ||
}; | ||
|
||
return { stopAutosave }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing startAutosave
stopAutoSave
src/core/autosave/autosave.hook.tsx
Outdated
const stopAutosave = () => { | ||
if (timerRef.current) { | ||
clearInterval(timerRef.current); | ||
timerRef.current = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing trying to save on close
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible? what I think is happening is that stopAutosave
will be executed when component has already been unmounted, so it doesn't have access to canvasSchema
to save it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my doubt, well the provider is created at App level, I think it would be a good idea to give a try and check what happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to App level, and still unable to get it to work
src/pods/canvas/canvas.pod.tsx
Outdated
|
||
export const CanvasPod: React.FC = () => { | ||
const { stopAutosave } = useAutosave(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { startAutosave, stopAutoSave} = useAutosave();
By doing this we have granular control when we start (component mounted) and stop
src/pods/canvas/canvas.pod.tsx
Outdated
|
||
React.useEffect(() => { | ||
return stopAutosave; | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.useEffect(() => {
+ startAutosave();
return stopAutosave;
}, []);
console.error('File retrieve error', error); | ||
localStorage.removeItem(key); | ||
localStorage.setItem( | ||
'autoSaveFile', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic string found, I think we where using a const somewhere?
filename: '', | ||
canvasSchema: createDefaultDatabaseSchemaVm(), | ||
}) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove this code here, if it fails because of error on local storage, it will likely again and it can throw another error, rather to swallow on first instance and that's all
…ng the save at catch error
…d schema, when multiple version exist
-I can't make the auto save when closing the tab. +Moved |
Closed #313