mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-12 19:02:53 +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 {
|
||||
const contentJson = await contentToJson(get().contents, get().format);
|
||||
const jsonContent = await jsonToContent(JSON.stringify(contentJson, null, 2), format);
|
||||
set({ format });
|
||||
get().setContents({ contents: jsonContent, hasChanges: false });
|
||||
} catch (error) {
|
||||
get().clear();
|
||||
console.info("The content was unable to be converted, so it was cleared instead.");
|
||||
} finally {
|
||||
set({ format });
|
||||
}
|
||||
},
|
||||
setContents: async ({ contents, hasChanges = true, skipUpdate = false }) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user