Skip to content

Commit

Permalink
fix problem with search in side-navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Verhoelen committed Apr 26, 2019
1 parent e085860 commit 0701975
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/renderer/explorer-app/side-navigation/SecretTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export default class SecretTreeViewer extends React.Component<SecretTreeViewerPr
public async componentDidMount() {
const secretNames = await Gopass.getAllSecretNames()
this.setState({ secretNames })
await this.calculateAndSetTreeState()
await this.calculateAndSetTreeState(this.props.searchValue)
}

public async componentWillReceiveProps(props: SecretTreeViewerProps) {
if (props.searchValue !== this.props.searchValue) {
await this.calculateAndSetTreeState()
public async componentWillReceiveProps(newProps: SecretTreeViewerProps) {

if (newProps.searchValue !== this.props.searchValue) {
await this.calculateAndSetTreeState(newProps.searchValue)
}
}

Expand All @@ -44,8 +45,8 @@ export default class SecretTreeViewer extends React.Component<SecretTreeViewerPr
)
}

private async calculateAndSetTreeState() {
const filteredSecretNames = SecretsFilterService.filterBySearch(this.state.secretNames, this.props.searchValue)
private async calculateAndSetTreeState(searchValue: string) {
const filteredSecretNames = SecretsFilterService.filterBySearch(this.state.secretNames, searchValue)
const tree: Tree = SecretsDirectoryService.secretPathsToTree(filteredSecretNames)
this.setState({ ...this.state, tree })
}
Expand Down

0 comments on commit 0701975

Please sign in to comment.