Skip to content

Commit

Permalink
Add loading operations
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Jun 21, 2019
1 parent 6ad627d commit 0757905
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions finder.js
Expand Up @@ -19,6 +19,7 @@ class Finder extends React.Component {
this.commentTypes = ['TESTME', 'DOCME', 'FIXME', 'TODO'];

this.state = {
operations: [],
projectPath,
repoPath,
// Counters that will be populated while the comments are being
Expand Down Expand Up @@ -162,10 +163,22 @@ class Finder extends React.Component {
}

loadComments() {
this.setState(state => ({
operations: [...state.operations, 'Finding comments ..']
}));

gitGrep(this.state.repoPath, { rev: 'HEAD', term: `(${this.commentTypes.join(')|(')})` })
.on('data', this.onCommentFound)
.on('error', this.handleError)
.on('end', () => null);
.on('end', () => {
this.setState(state => ({
operations: [
...state.operations,
'Lookup completed ..',
'Reading authors ..'
]
}))
});
}

componentDidMount() {
Expand Down Expand Up @@ -246,8 +259,7 @@ class Finder extends React.Component {
renderLoading() {
return (
<React.Fragment>
<Color yellow>Total {Object.keys(this.state.rawComments).length} comments found</Color>
<Color green>Loading ...</Color>
{this.state.operations.map(operation => <Color key={operation} green>{operation}</Color>)}
</React.Fragment>
);
}
Expand Down

0 comments on commit 0757905

Please sign in to comment.