Remove failed-to-load notification and reload the error tab on online event

This commit is contained in:
Yuya Ochiai
2016-08-16 00:20:34 +09:00
parent ea14b0d963
commit f16543ca44

View File

@@ -329,20 +329,18 @@ var MattermostView = React.createClass({
return; return;
} }
// should use permanent way to indicate
var did_fail_load_notification = new Notification(`Failed to load "${thisObj.props.name}"`, {
body: `ErrorCode: ${e.errorCode}`,
icon: '../resources/appicon.png'
});
thisObj.setState({ thisObj.setState({
errorInfo: e errorInfo: e
}); });
setTimeout(() => { const reload = () => {
thisObj.setState({ window.removeEventListener('online', reload);
errorInfo: null thisObj.reload();
}); };
webview.reload(); if (navigator.onLine) {
}, 30000); setTimeout(reload, 30000);
} else {
window.addEventListener('online', reload);
}
}); });
// Open link in browserWindow. for exmaple, attached files. // Open link in browserWindow. for exmaple, attached files.
@@ -442,10 +440,16 @@ var MattermostView = React.createClass({
}); });
}, },
reload: function() { reload: function() {
this.setState({
errorInfo: null
});
var webview = ReactDOM.findDOMNode(this.refs.webview); var webview = ReactDOM.findDOMNode(this.refs.webview);
webview.reload(); webview.reload();
}, },
clearCacheAndReload() { clearCacheAndReload() {
this.setState({
errorInfo: null
});
var webContents = ReactDOM.findDOMNode(this.refs.webview).getWebContents(); var webContents = ReactDOM.findDOMNode(this.refs.webview).getWebContents();
webContents.session.clearCache(() => { webContents.session.clearCache(() => {
webContents.reload(); webContents.reload();