fix forking snippet with no code

main
Mike Fix 5 years ago
parent da5c77b0e1
commit e2fb62c068

@ -3,7 +3,7 @@ import React from 'react'
import Editor from './Editor'
import Toasts from './Toasts'
import { THEMES, DEFAULT_CODE } from '../lib/constants'
import { THEMES } from '../lib/constants'
import { updateRouteState } from '../lib/routing'
import { getThemes, saveThemes, clearSettings, saveSettings } from '../lib/util'
@ -76,10 +76,7 @@ function EditorContainer(props) {
updateRouteState(props.router, state)
saveSettings(state)
} else {
const updates = {
...state,
code: state.code != null ? state.code : DEFAULT_CODE
}
const updates = state
if (!snippet) {
update(snippetId, updates).then(newSnippet => {
if (newSnippet && newSnippet.id) {

@ -2,6 +2,8 @@ import axios from 'axios'
import debounce from 'lodash.debounce'
import ms from 'ms'
import { DEFAULT_CODE } from './constants'
import { fileToDataURL } from './util'
export const client = axios.create({
@ -80,7 +82,11 @@ function getSnippet(uid, { host } = {}) {
})
}
function updateSnippet(uid, data) {
function updateSnippet(uid, state) {
const data = {
...state,
code: state.code != null ? state.code : DEFAULT_CODE
}
if (uid) {
return client
.patch(`/snippets/${uid}`, data)

Loading…
Cancel
Save