mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 12:22:44 +00:00
Move normalization to before diffing
This commit is contained in:
@@ -259,12 +259,14 @@ const EditPage = createClass({
|
|||||||
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.text = brew.text.normalize();
|
||||||
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
|
this.savedBrew.text = this.savedBrew.text.normalize();
|
||||||
brew.hash = await md5(this.savedBrew.text.normalize());
|
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
||||||
brew.text = undefined;
|
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
|
||||||
brew.textBin = undefined;
|
brew.hash = await md5(this.savedBrew.text.normalize());
|
||||||
|
brew.text = undefined;
|
||||||
|
brew.textBin = undefined;
|
||||||
|
|
||||||
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
|
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
|
||||||
const params = `${transfer ? `?${this.state.saveGoogle ? 'saveToGoogle' : 'removeFromGoogle'}=true` : ''}`;
|
const params = `${transfer ? `?${this.state.saveGoogle ? 'saveToGoogle' : 'removeFromGoogle'}=true` : ''}`;
|
||||||
|
|||||||
@@ -339,9 +339,10 @@ const api = {
|
|||||||
// Initialize brew from request and body, destructure query params, and set the initial value for the after-save method
|
// Initialize brew from request and body, destructure query params, and set the initial value for the after-save method
|
||||||
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
||||||
const brewFromServer = req.brew;
|
const brewFromServer = req.brew;
|
||||||
|
brewFromServer.text = brewFromServer.text.normalize();
|
||||||
splitTextStyleAndMetadata(brewFromServer);
|
splitTextStyleAndMetadata(brewFromServer);
|
||||||
|
|
||||||
brewFromServer.hash = await md5(brewFromServer.text.normalize());
|
brewFromServer.hash = await md5(brewFromServer.text);
|
||||||
|
|
||||||
if((brewFromServer?.version !== brewFromClient?.version) || (brewFromServer?.hash !== brewFromClient?.hash)) {
|
if((brewFromServer?.version !== brewFromClient?.version) || (brewFromServer?.hash !== brewFromClient?.hash)) {
|
||||||
if(brewFromClient?.version !== brewFromClient?.version)
|
if(brewFromClient?.version !== brewFromClient?.version)
|
||||||
|
|||||||
Reference in New Issue
Block a user