fix(shared): Saving pattern in edit mode
This reverts the temporary fix for #5534
(commit 99b6e75956
)
and implements a proper fix.
This also closes #5570 as that was a side-effect of the initial
half-assed fix.
This commit is contained in:
parent
031be5820b
commit
d442e23d69
3 changed files with 16 additions and 30 deletions
|
@ -21,7 +21,7 @@ import { Loading } from 'shared/components/spinner.mjs'
|
||||||
const ns = nsMerge('$$design$$', wbNs, pageNs)
|
const ns = nsMerge('$$design$$', wbNs, pageNs)
|
||||||
|
|
||||||
const EditDesignComponent = ({ id, design, Design, settings }) => (
|
const EditDesignComponent = ({ id, design, Design, settings }) => (
|
||||||
<Workbench preload={{ settings }} saveAs={{ pattern: id, edit: 0 }} {...{ design, Design }} />
|
<Workbench preload={{ settings }} saveAs={{ pattern: id }} {...{ design, Design }} />
|
||||||
)
|
)
|
||||||
|
|
||||||
const Edit$$Design$$Page = ({ page }) => {
|
const Edit$$Design$$Page = ({ page }) => {
|
||||||
|
|
|
@ -105,10 +105,9 @@ export const Workbench = ({ design, Design, saveAs = false, preload = false }) =
|
||||||
// Handle preload
|
// Handle preload
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (preload) {
|
if (preload) {
|
||||||
// This will run a few times while variouos things bootstrap
|
// This will run a few times while things bootstrap
|
||||||
// but should not run after that.
|
// but should not run after that.
|
||||||
if (preload.settings && preloaded < 3) {
|
if (preload.settings && preloaded < 2) {
|
||||||
console.log('preloading settings', { mounted, preloaded })
|
|
||||||
setSettings(preload.settings)
|
setSettings(preload.settings)
|
||||||
setView('draft')
|
setView('draft')
|
||||||
setPreloaded(preloaded + 1)
|
setPreloaded(preloaded + 1)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { capitalize, shortDate } from 'shared/utils.mjs'
|
import { capitalize, shortDate } from 'shared/utils.mjs'
|
||||||
import { controlLevels } from 'shared/config/freesewing.config.mjs'
|
import { controlLevels } from 'shared/config/freesewing.config.mjs'
|
||||||
// Hooks
|
// Hooks
|
||||||
import { useEffect, useContext, useMemo } from 'react'
|
import { useContext, useMemo } from 'react'
|
||||||
import { useMobileAction } from 'shared/context/mobile-menubar-context.mjs'
|
import { useMobileAction } from 'shared/context/mobile-menubar-context.mjs'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { useBackend } from 'shared/hooks/use-backend.mjs'
|
import { useBackend } from 'shared/hooks/use-backend.mjs'
|
||||||
|
@ -99,32 +99,19 @@ export const DraftHeader = ({
|
||||||
// add the zoom buttons as an action on the mobile menubar
|
// add the zoom buttons as an action on the mobile menubar
|
||||||
useMobileAction('zoom', { order: 0, actionContent: headerZoomButtons })
|
useMobileAction('zoom', { order: 0, actionContent: headerZoomButtons })
|
||||||
|
|
||||||
/*
|
const savePattern = async () => {
|
||||||
* This saves the pattern on intial load which side-steps #5534 until
|
setLoadingStatus([true, 'savingPattern'])
|
||||||
* we figure out what's causing it exactly
|
|
||||||
*/
|
|
||||||
useEffect(() => {
|
|
||||||
if (saveAs && saveAs.edit === 0) {
|
|
||||||
savePattern(true)
|
|
||||||
saveAs.edit++
|
|
||||||
}
|
|
||||||
}, [saveAs])
|
|
||||||
|
|
||||||
const savePattern = async (silent = false) => {
|
|
||||||
if (!silent) setLoadingStatus([true, 'savingPattern'])
|
|
||||||
const result = await backend.updatePattern(saveAs.pattern, { settings })
|
const result = await backend.updatePattern(saveAs.pattern, { settings })
|
||||||
if (!silent) {
|
if (result.success)
|
||||||
if (result.success)
|
setLoadingStatus([
|
||||||
setLoadingStatus([
|
true,
|
||||||
true,
|
<>
|
||||||
<>
|
{t('status:patternSaved')} <small>[#{saveAs.pattern}]</small>
|
||||||
{t('status:patternSaved')} <small>[#{saveAs.pattern}]</small>
|
</>,
|
||||||
</>,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
])
|
||||||
])
|
else setLoadingStatus([true, 'backendError', true, false])
|
||||||
else setLoadingStatus([true, 'backendError', true, false])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bookmarkPattern = async () => {
|
const bookmarkPattern = async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue