0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-01 17:22:42 +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 updateHistory(this.state.brew).catch(console.error);
await versionHistoryGarbageCollection().catch(console.error); await versionHistoryGarbageCollection().catch(console.error);
const preSaveSnapshot = { ...this.state.brew } const preSaveSnapshot = { ...this.state.brew };
//Prepare content to send to server //Prepare content to send to server
const brew = { ...this.state.brew }; const brew = { ...this.state.brew };
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1; 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.hash = await md5(this.savedBrew.text);
brew.text = undefined; brew.text = undefined;
brew.textBin = undefined; brew.textBin = undefined;

View File

@@ -356,7 +356,7 @@ const api = {
let brew = _.assign(brewFromServer, brewFromClient); let brew = _.assign(brewFromServer, brewFromClient);
brew.title = brew.title.trim(); brew.title = brew.title.trim();
brew.description = brew.description.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); brew.text = api.mergeBrewText(brew);
const googleId = brew.googleId; const googleId = brew.googleId;