reduce imports and exports

main
Mike Fix 6 years ago committed by Michael Fix
parent 3aec3ebc28
commit dbde17a65f

@ -30,8 +30,7 @@ import {
DEFAULT_CODE, DEFAULT_CODE,
DEFAULT_SETTINGS, DEFAULT_SETTINGS,
DEFAULT_LANGUAGE, DEFAULT_LANGUAGE,
DEFAULT_PRESET_ID, DEFAULT_PRESET_ID
MAX_PAYLOAD_SIZE
} from '../lib/constants' } from '../lib/constants'
import { serializeState, getQueryStringState } from '../lib/routing' import { serializeState, getQueryStringState } from '../lib/routing'
import { import {
@ -40,8 +39,7 @@ import {
unescapeHtml, unescapeHtml,
formatCode, formatCode,
omit, omit,
isSafari, verifyPayloadSize
sizeOf
} from '../lib/util' } from '../lib/util'
import LanguageIcon from './svg/Language' import LanguageIcon from './svg/Language'
import ThemeIcon from './svg/Theme' import ThemeIcon from './svg/Theme'
@ -113,7 +111,10 @@ class Editor extends React.Component {
window.addEventListener('offline', this.setOffline) window.addEventListener('offline', this.setOffline)
window.addEventListener('online', this.setOnline) window.addEventListener('online', this.setOnline)
this.isSafari = isSafari() this.isSafari =
window.navigator &&
window.navigator.userAgent.indexOf('Safari') !== -1 &&
window.navigator.userAgent.indexOf('Chrome') === -1
} }
componentWillUnmount() { componentWillUnmount() {
@ -271,9 +272,7 @@ class Editor extends React.Component {
updateBackground({ photographer, ...changes } = {}) { updateBackground({ photographer, ...changes } = {}) {
if (this.isSafari) { if (this.isSafari) {
this.disablePNG = this.disablePNG = !verifyPayloadSize(changes.backgroundImage)
typeof changes.backgroundImage === 'string' &&
sizeOf(changes.backgroundImage) > MAX_PAYLOAD_SIZE
} }
if (photographer) { if (photographer) {

@ -641,5 +641,3 @@ export const DEFAULT_PRESETS = [
id: 'preset:6' id: 'preset:6'
} }
] ]
export const MAX_PAYLOAD_SIZE = 5000000 //bytes

@ -77,10 +77,9 @@ export const stringifyRGBA = obj => `rgba(${obj.r},${obj.g},${obj.b},${obj.a})`
export const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1) export const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1)
export const isSafari = () => const MAX_PAYLOAD_SIZE = 5e6
window && export const verifyPayloadSize = str => {
window.navigator && if (typeof str !== 'string') return true
window.navigator.userAgent.indexOf('Safari') !== -1 &&
window.navigator.userAgent.indexOf('Chrome') === -1
export const sizeOf = str => str.length * 2 //bytes return new Blob([str]).size < MAX_PAYLOAD_SIZE // bytes
}

Loading…
Cancel
Save