mirror of
https://github.com/kihashi/stardew_community_checklist.git
synced 2025-10-19 08:03:17 +00:00
Ensure data can be decoded and parsed into JSON before loading
This commit is contained in:
parent
73f21bffb0
commit
f1e67886d5
@ -195,8 +195,14 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
LoadData: function () {
|
LoadData: function () {
|
||||||
if (this.DataToLoad !== '') {
|
if (this.DataToLoad !== '') {
|
||||||
this.$store.commit('SetSerializedState', this.DataToLoad)
|
try {
|
||||||
alert('Data Loaded!')
|
assertDataIsValid(this.DataToLoad);
|
||||||
|
this.$store.commit('SetSerializedState', this.DataToLoad)
|
||||||
|
alert('Data Loaded!')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Invalid data string');
|
||||||
|
alert('Error loading data.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ConfirmDelete: function () {
|
ConfirmDelete: function () {
|
||||||
@ -210,6 +216,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assertDataIsValid(data) {
|
||||||
|
JSON.parse(atob(data));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user