mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix: set format after error
This commit is contained in:
parent
c281b232df
commit
b874fbef30
@ -100,11 +100,12 @@ const useFile = create<FileStates & JsonActions>()((set, get) => ({
|
|||||||
try {
|
try {
|
||||||
const contentJson = await contentToJson(get().contents, get().format);
|
const contentJson = await contentToJson(get().contents, get().format);
|
||||||
const jsonContent = await jsonToContent(JSON.stringify(contentJson, null, 2), format);
|
const jsonContent = await jsonToContent(JSON.stringify(contentJson, null, 2), format);
|
||||||
set({ format });
|
|
||||||
get().setContents({ contents: jsonContent, hasChanges: false });
|
get().setContents({ contents: jsonContent, hasChanges: false });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
get().clear();
|
get().clear();
|
||||||
console.info("The content was unable to be converted, so it was cleared instead.");
|
console.info("The content was unable to be converted, so it was cleared instead.");
|
||||||
|
} finally {
|
||||||
|
set({ format });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setContents: async ({ contents, hasChanges = true, skipUpdate = false }) => {
|
setContents: async ({ contents, hasChanges = true, skipUpdate = false }) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user