0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-11 04:42:42 +00:00

Remove checkForScript state

This commit is contained in:
G.Ambatte
2024-11-10 19:29:28 +13:00
parent 27f14b042b
commit 952b67aed3

View File

@@ -18,15 +18,14 @@ const BrewLookup = createClass({
foundBrew : null, foundBrew : null,
searching : false, searching : false,
error : null, error : null,
checkForScript : false, scriptCount : 0
scriptCount : undefined
}; };
}, },
handleChange(e){ handleChange(e){
this.setState({ query: e.target.value }); this.setState({ query: e.target.value });
}, },
lookup(){ lookup(){
this.setState({ searching: true, error: null, checkForScript: false, scriptCount: undefined }); this.setState({ searching: true, error: null, scriptCount: 0 });
request.get(`/admin/lookup/${this.state.query}`) request.get(`/admin/lookup/${this.state.query}`)
.then((res)=>{ .then((res)=>{
@@ -35,7 +34,6 @@ const BrewLookup = createClass({
this.setState({ this.setState({
foundBrew : foundBrew, foundBrew : foundBrew,
scriptCount : scriptCheck?.length || 0, scriptCount : scriptCheck?.length || 0,
checkForScript : scriptCheck?.length > 0
}); });
}) })
.catch((err)=>this.setState({ error: err })) .catch((err)=>this.setState({ error: err }))
@@ -52,7 +50,7 @@ const BrewLookup = createClass({
request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`) request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`)
.then((res)=>this.setState({ foundBrew: res.body })) .then((res)=>this.setState({ foundBrew: res.body }))
.catch((err)=>this.setState({ error: err })) .catch((err)=>this.setState({ error: err }))
.finally(()=>this.setState({ checkForScript: false, scriptCount: 0 })); .finally(()=>this.setState({ scriptCount: 0 }));
}, },
renderFoundBrew(){ renderFoundBrew(){
@@ -83,7 +81,7 @@ const BrewLookup = createClass({
<dt>Number of SCRIPT tags detected</dt> <dt>Number of SCRIPT tags detected</dt>
<dd>{this.state.scriptCount}</dd> <dd>{this.state.scriptCount}</dd>
</dl> </dl>
{this.state.checkForScript && {this.state.scriptCount > 0 &&
<div className='cleanButton'> <div className='cleanButton'>
<button onClick={this.cleanScript}>CLEAN BREW</button> <button onClick={this.cleanScript}>CLEAN BREW</button>
</div> </div>