Merge pull request #384 from betagouv/fix-autosave

🐛 répare la supression de la sauvegarde
pull/389/head
Johan Girod 2018-10-03 15:37:34 +02:00 committed by GitHub
commit 4d146598f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import type {
DeletePreviousSimulationAction,
StartConversationAction
} from 'Types/ActionsTypes'
import { deletePersistedSimulation } from '../storage/persistSimulation'
export function resetSimulation(): ResetSimulationAction {
return {
@ -12,10 +13,13 @@ export function resetSimulation(): ResetSimulationAction {
}
}
export function deletePreviousSimulation(): DeletePreviousSimulationAction {
return {
export const deletePreviousSimulation = () => (
dispatch: DeletePreviousSimulationAction => void
) => {
dispatch({
type: 'DELETE_PREVIOUS_SIMULATION'
}
})
deletePersistedSimulation()
}
export function startConversation(question: ?string): StartConversationAction {

View File

@ -25,3 +25,7 @@ export function retrievePersistedSimulation(): ?SavedSimulation {
const serializedState = window.localStorage.getItem(LOCAL_STORAGE_KEY)
return serializedState ? deserialize(serializedState) : null
}
export function deletePersistedSimulation(): void {
window.localStorage.removeItem(LOCAL_STORAGE_KEY)
}