mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 09:42:43 +00:00
Fix infinite loop
This commit is contained in:
@@ -5,7 +5,7 @@ const createClass = require('create-react-class');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|
||||||
import { historyCheck, loadHistory } from '../../utils/versionHistory.js';
|
import { loadHistory } from '../../utils/versionHistory.js';
|
||||||
|
|
||||||
//Import all themes
|
//Import all themes
|
||||||
const ThemeSnippets = {};
|
const ThemeSnippets = {};
|
||||||
@@ -70,23 +70,27 @@ const Snippetbar = createClass({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkHistoryExists = (await historyCheck(this.props.brew)) ?? false;
|
// Update history list if it has changed
|
||||||
if(checkHistoryExists != prevState.historyExists){
|
const checkHistoryItems = await loadHistory(this.props.brew);
|
||||||
|
|
||||||
|
// If all items have the noData property, there is no saved data
|
||||||
|
const checkHistoryExists = !checkHistoryItems.every((historyItem)=>{
|
||||||
|
return historyItem?.noData;
|
||||||
|
});
|
||||||
|
if(prevState.historyExists != checkHistoryExists){
|
||||||
this.setState({
|
this.setState({
|
||||||
historyExists : checkHistoryExists
|
historyExists : checkHistoryExists
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update history list if it has changed
|
// If any history items have changed, update the list
|
||||||
const checkHistoryItems = await loadHistory(this.props.brew);
|
if(checkHistoryExists && checkHistoryItems.some((historyItem, index)=>{
|
||||||
if(checkHistoryItems.some((historyItem, index)=>{
|
return index >= prevState.historyItems.length || !_.isEqual(historyItem, prevState.historyItems[index]);
|
||||||
return !index < this.state.historyItems.length || historyItem != this.state.historyItems[index];
|
|
||||||
})){
|
})){
|
||||||
this.setState({
|
this.setState({
|
||||||
historyItems : checkHistoryItems
|
historyItems : checkHistoryItems
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mergeCustomizer : function(oldValue, newValue, key) {
|
mergeCustomizer : function(oldValue, newValue, key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user