1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 19:34:34 +00:00

fix(web): when no file is selected save the editor content to local storage

This commit is contained in:
2022-07-26 23:30:41 +05:00
parent 3c987c61dd
commit 3b1fcb937d

View File

@@ -102,7 +102,7 @@ const SASjsEditor = ({
usePrompt(
'Changes you made may not be saved.',
prevFileContent !== fileContent
prevFileContent !== fileContent && !!selectedFilePath
)
useEffect(() => {
@@ -134,11 +134,18 @@ const SASjsEditor = ({
})
.finally(() => setIsLoading(false))
} else {
setFileContent('')
const content = localStorage.getItem('fileContent') ?? ''
setFileContent(content)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedFilePath])
useEffect(() => {
if (fileContent.length && !selectedFilePath) {
localStorage.setItem('fileContent', fileContent)
}
}, [fileContent, selectedFilePath])
useEffect(() => {
if (runTimes.includes(selectedFileExtension))
setSelectedRunTime(selectedFileExtension)