From 2c90a8fb85a9c22916d744b92a20e3364d0b6ea0 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sat, 14 May 2022 14:25:21 -0700 Subject: [PATCH] fix snippet toolbar logicgs --- components/Editor.js | 2 +- components/EditorContainer.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/Editor.js b/components/Editor.js index ac71158..357657d 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -298,7 +298,7 @@ class Editor extends React.Component { this.context.snippet.update(this.props.snippet.id, this.state).then(() => this.props.setToasts({ type: 'SET', - toast: { children: 'Snippet saved', timeout: 3000 }, + toast: [{ children: 'Snippet saved', timeout: 3000 }], }) ) diff --git a/components/EditorContainer.js b/components/EditorContainer.js index b24226c..3423886 100644 --- a/components/EditorContainer.js +++ b/components/EditorContainer.js @@ -25,6 +25,9 @@ function onReset() { function toastsReducer(curr, action) { switch (action.type) { + case 'ADD': { + return curr.concat(action.toast) + } case 'SET': { return action.toasts } @@ -49,6 +52,7 @@ function EditorContainer(props) { // XXX use context const [snippet, setSnippet] = React.useState(props.snippet || null) + // TODO update this reducer to only take one action const [toasts, setToasts] = React.useReducer(toastsReducer, []) const snippetId = snippet && snippet.id