Skip to content

Commit

Permalink
fix: "Ok" message after auto repair not working anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed May 26, 2021
1 parent 6c910af commit e5b6e01
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
const prevText = text
json = updatedJson
text = undefined
state = syncState(json, prevState, [], defaultExpand)
addHistoryItem({ prevJson, prevState, prevText })
Expand Down Expand Up @@ -327,6 +328,7 @@
} catch (err) {
try {
applyExternalJson(JSON.parse(jsonrepair(updatedText)))
text = updatedText
textIsRepaired = true
} catch (err) {
// no valid JSON, will show empty document or invalid json
Expand Down Expand Up @@ -469,6 +471,11 @@
})
}
function handleApplyAutoRepair () {
textIsRepaired = false
emitOnChange()
}
async function handleCut () {
if (readOnly || !hasSelectionContents()) {
return
Expand Down Expand Up @@ -1546,15 +1553,15 @@
selectError={handleSelectValidationError}
/>

{#if textIsRepaired && text !== undefined}
{#if textIsRepaired}
<Message
type="success"
message="The loaded JSON document was invalid but is successfully repaired."
actions={[
{
icon: faCheck,
text: 'Ok',
onClick: emitOnChange
onClick: handleApplyAutoRepair
},
{
icon: faCode,
Expand Down

0 comments on commit e5b6e01

Please sign in to comment.