0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 22:52:40 +00:00

Merge pull request #4310 from dbolack-ab/2025-06-09_Debug

Add Patch wrapper/unwrapper for saves
This commit is contained in:
Trevor Buckner
2025-07-09 18:42:23 -04:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -256,12 +256,12 @@ const EditPage = createClass({
await updateHistory(this.state.brew).catch(console.error);
await versionHistoryGarbageCollection().catch(console.error);
const preSaveSnapshot = { ...this.state.brew }
const preSaveSnapshot = { ...this.state.brew };
//Prepare content to send to server
const brew = { ...this.state.brew };
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
brew.patches = makePatches(this.savedBrew.text, brew.text);
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
brew.hash = await md5(this.savedBrew.text);
brew.text = undefined;
brew.textBin = undefined;

View File

@@ -352,11 +352,11 @@ const api = {
res.setHeader('Content-Type', 'application/json');
return res.status(409).send(JSON.stringify({ message: `The server copy is out of sync with the saved brew. Please save your changes elsewhere, refresh, and try again.` }));
}
let brew = _.assign(brewFromServer, brewFromClient);
brew.title = brew.title.trim();
brew.description = brew.description.trim() || '';
brew.text = applyPatches(brewFromClient.patches, brewFromServer.text)[0];
brew.text = applyPatches(parsePatch(brewFromClient.patches), brewFromServer.text)[0];
brew.text = api.mergeBrewText(brew);
const googleId = brew.googleId;