|
|
|
@ -1,11 +1,10 @@
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
import debounce from 'lodash.debounce'
|
|
|
|
|
import omitBy from 'lodash.omitby'
|
|
|
|
|
import ms from 'ms'
|
|
|
|
|
|
|
|
|
|
import { fileToDataURL } from './util'
|
|
|
|
|
import firebase from './client'
|
|
|
|
|
import { DEFAULT_CODE, DEFAULT_SETTINGS } from './constants'
|
|
|
|
|
import { DEFAULT_CODE } from './constants'
|
|
|
|
|
|
|
|
|
|
export const client = axios.create({
|
|
|
|
|
baseURL: `${process.env.NEXT_PUBLIC_API_URL || ''}/api`,
|
|
|
|
@ -130,15 +129,9 @@ function listSnippets(page) {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isNotDefaultSetting(v, k) {
|
|
|
|
|
return v === DEFAULT_SETTINGS[k] || !Object.prototype.hasOwnProperty.call(DEFAULT_SETTINGS, k)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateSnippet(uid, state) {
|
|
|
|
|
const sanitized = omitBy(state, isNotDefaultSetting)
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
...sanitized,
|
|
|
|
|
...state,
|
|
|
|
|
code: state.code != null ? state.code : DEFAULT_CODE,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|