From cba61d3f7e6a154c3552d16942c51f770314fecb Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Wed, 3 Oct 2018 11:28:18 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20r=C3=A9pare=20la=20supression=20de=20la?= =?UTF-8?q?=20sauvegarde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/actions/actions.js | 10 +++++++--- source/storage/persistSimulation.js | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/actions/actions.js b/source/actions/actions.js index 2189faf03..94f2433c8 100644 --- a/source/actions/actions.js +++ b/source/actions/actions.js @@ -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 { diff --git a/source/storage/persistSimulation.js b/source/storage/persistSimulation.js index 2766c00c7..79c521537 100644 --- a/source/storage/persistSimulation.js +++ b/source/storage/persistSimulation.js @@ -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) +}