Skip to content

Commit

Permalink
fix: remove stop from local storage immediately after submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobkellas committed Nov 14, 2022
1 parent cbc1af7 commit b8508b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions UI/src/components/mixins/RipaApiStopJobMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export default {
return
}
await this.submitOfficerStop(apiStop)
this.removeSingleApiStopFromLocalStorage(apiStop)
await this.timeout(1500)
}
Expand Down Expand Up @@ -273,6 +274,22 @@ export default {
localStorage.removeItem('ripa_submitted_api_stops')
},
removeSingleApiStopFromLocalStorage(apiStop) {
const apiStops = JSON.parse(
localStorage.getItem('ripa_submitted_api_stops'),
)
const index = apiStops.findIndex(s => s.time === apiStop.time)
if (index > -1) {
apiStops.splice(index, 1)
localStorage.setItem(
'ripa_submitted_api_stops',
JSON.stringify(apiStops),
)
}
},
getApiStopsFromLocalStorage() {
const apiStops = localStorage.getItem('ripa_submitted_api_stops')
return apiStops ? JSON.parse(apiStops) : []
Expand Down
1 change: 1 addition & 0 deletions UI/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ export default new Vuex.Store({
if (router.currentRoute.fullPath === '/admin') {
dispatch('getAdminStops')
}
return apiStop
}
if (response.status !== 200) {
const errorStop = {
Expand Down

0 comments on commit b8508b5

Please sign in to comment.