Skip to content

Commit

Permalink
fix snippet toolbar logicgs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed May 14, 2022
1 parent 859abfe commit 2c90a8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }],
})
)

Expand Down
4 changes: 4 additions & 0 deletions components/EditorContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 2c90a8f

Please sign in to comment.