Skip to content

Commit

Permalink
prevent crash when filename changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Jul 4, 2020
1 parent 9c72f01 commit 4d1a72c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/components/FileRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ export default class FileRow extends Component {
selectedOrdinal: PropTypes.number.isRequired,
};

constructor(props) {
super(props);

const file = this.props.file || {};

let isError = false;
try {
file.game.getSettings();
} catch {
isError = true;
}

// TODO: Improve error state UI but at least this doesn't crash the program
this.state = {
isError: isError,
};
}

shouldComponentUpdate(nextProps) {
return this.props.selectedOrdinal !== nextProps.selectedOrdinal;
}
Expand Down Expand Up @@ -129,6 +147,10 @@ export default class FileRow extends Component {
}

getStageName() {
if (this.state.isError) {
return null;
}

const file = this.props.file || {};

const settings = file.game.getSettings() || {};
Expand All @@ -139,6 +161,10 @@ export default class FileRow extends Component {
}

generateTeamElements() {
if (this.state.isError) {
return null;
}

const file = this.props.file || {};
const game = file.game || {};
const settings = game.getSettings() || {};
Expand Down Expand Up @@ -182,6 +208,10 @@ export default class FileRow extends Component {
}

generateStartTimeCell() {
if (this.state.isError) {
return <Table.Cell singleLine={true}>Error</Table.Cell>;
}

const file = this.props.file || {};

const metadata = file.game.getMetadata() || {};
Expand Down

0 comments on commit 4d1a72c

Please sign in to comment.