From 753139fcae3422bc8fb26145075972b101624bdf Mon Sep 17 00:00:00 2001 From: Matthew McNaney Date: Fri, 10 Nov 2017 08:15:02 -0500 Subject: [PATCH] Added warning message when json goes bad. --- javascript/RoommateList/RoommateList.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/javascript/RoommateList/RoommateList.jsx b/javascript/RoommateList/RoommateList.jsx index 051a483..f6237e9 100644 --- a/javascript/RoommateList/RoommateList.jsx +++ b/javascript/RoommateList/RoommateList.jsx @@ -1,6 +1,5 @@ 'use strict' import React, {Component} from 'react' -import PropTypes from 'prop-types' import RoommateRow from './RoommateRow.jsx' import Waiting from '../Mixin/Html/Waiting.jsx' import SearchBar from './SearchBar.jsx' @@ -12,6 +11,7 @@ import {profileLabel} from '../Mixin/Objects/ProfileData.js' export default class RoommateList extends Component { constructor(props) { super(props) + this.error = false this.state = { roommates: null, labels: { @@ -84,12 +84,20 @@ export default class RoommateList extends Component { } else { this.setState({roommates: []}) } + }.bind(this)).fail(function(){ + this.error = true + this.setState({roommates: []}) }.bind(this)) } render() { let rows + let message + if (this.error) { + message =
An error occurred when trying to access the roommate list. Please contact the site administrators.
+ } + if (this.state.roommates === null) { return } else if (this.state.roommates.length === 0) { @@ -105,6 +113,7 @@ export default class RoommateList extends Component { return (

Roommate listing

+ {message}