fix snippet toolbar logicgs

main
Mike Fix 3 years ago
parent 859abfe369
commit 2c90a8fb85
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -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 }],
})
)

@ -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

Loading…
Cancel
Save