Skip to content
This repository has been archived by the owner on Apr 11, 2019. It is now read-only.

File viewer: Support 'hashchange' navigation events #195

Merged
merged 1 commit into from
Jul 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/containers/fileViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ export default class FileViewerContainer extends Component {
}

componentDidMount() {
const { revision, path } = this.state;
this.fetchData(revision, path);
this.fetchData();
}

componentDidUpdate(prevProps) {
if (this.props.location.search === prevProps.location.search) {
return;
}
// Reset the state and fetch new data
const newState = this.parseQueryParams();
newState.coverage = undefined;
newState.parsedFile = undefined;
// eslint-disable-next-line react/no-did-update-set-state
this.setState(newState);
this.fetchData();
}

setSelectedLine(selectedLineNumber) {
Expand All @@ -31,7 +43,8 @@ export default class FileViewerContainer extends Component {
}
}

fetchData(revision, path, repoPath = 'mozilla-central') {
fetchData(repoPath = 'mozilla-central') {
const { revision, path } = this.state;
// Get source code from hg
const fileSource = async () => {
this.setState({ parsedFile: (await rawFile(revision, path, repoPath)) });
Expand Down