0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-05 18:52:38 +00:00

Merge branch 'master' into experimentalIDValidations

This commit is contained in:
G.Ambatte
2025-07-13 20:52:52 +12:00
committed by GitHub
8 changed files with 180 additions and 35 deletions

View File

@@ -190,8 +190,9 @@ const EditPage = createClass({
this.setState((prevState)=>({
brew : {
...prevState.brew,
style : newData.style,
text : newData.text
style : newData.style,
text : newData.text,
snippets : newData.snippets
}
}));
},
@@ -247,6 +248,9 @@ const EditPage = createClass({
save : async function(){
if(this.debounceSave && this.debounceSave.cancel) this.debounceSave.cancel();
const brewState = this.state.brew; // freeze the current state
const preSaveSnapshot = { ...brewState };
this.setState((prevState)=>({
isSaving : true,
error : null,
@@ -256,16 +260,14 @@ const EditPage = createClass({
await updateHistory(this.state.brew).catch(console.error);
await versionHistoryGarbageCollection().catch(console.error);
const preSaveSnapshot = { ...this.state.brew };
//Prepare content to send to server
const brew = { ...this.state.brew };
brew.text = brew.text.normalize();
this.savedBrew.text = this.savedBrew.text.normalize();
const brew = { ...brewState };
brew.text = brew.text.normalize('NFC');
this.savedBrew.text = this.savedBrew.text.normalize('NFC');
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text));
brew.hash = await md5(this.savedBrew.text);
brew.text = undefined;
//brew.text = undefined; - Temporary parallel path
brew.textBin = undefined;
const transfer = this.state.saveGoogle == _.isNil(this.state.brew.googleId);
@@ -295,8 +297,8 @@ const EditPage = createClass({
shareId : res.body.shareId,
version : res.body.version
},
isSaving : false,
unsavedTime : new Date()
isSaving : false,
unsavedTime : new Date()
}), ()=>{
this.setState({ unsavedChanges : this.hasChanges() });
});

View File

@@ -42,6 +42,7 @@ function parseBrewForStorage(brew, slot = 0) {
title : brew.title,
text : brew.text,
style : brew.style,
snippets : brew.snippets,
version : brew.version,
shareId : brew.shareId,
savedAt : brew?.savedAt || new Date(),