New: Warn if UI won't update due to SignalR errors

pull/770/head
ta264 4 years ago committed by Qstick
parent 786247e9bc
commit 44d73f3e7e

@ -120,7 +120,7 @@ class SignalRConnector extends Component {
this.connection.on('receiveMessage', this.onReceiveMessage); this.connection.on('receiveMessage', this.onReceiveMessage);
this.connection.start().then(this.onConnected); this.connection.start().then(this.onStart, this.onStartFail);
} }
componentWillUnmount() { componentWillUnmount() {
@ -286,7 +286,19 @@ class SignalRConnector extends Component {
// //
// Listeners // Listeners
onConnected = () => { onStartFail = (error) => {
console.error('[signalR] failed to connect');
console.error(error);
this.props.dispatchSetAppValue({
isConnected: false,
isReconnecting: false,
isDisconnected: false,
isRestarting: false
});
}
onStart = () => {
console.debug('[signalR] connected'); console.debug('[signalR] connected');
this.props.dispatchSetAppValue({ this.props.dispatchSetAppValue({

@ -0,0 +1,24 @@
import { createSelector } from 'reselect';
function createHealthCheckSelector() {
return createSelector(
(state) => state.system.health,
(state) => state.app,
(health, app) => {
const items = [...health.items];
if (!app.isConnected) {
items.push({
source: 'UI',
type: 'warning',
message: 'Could not connect to SignalR, UI won\'t update',
wikiUrl: 'https://wiki.servarr.com/Readarr_System#could_not_connect_to_signalr'
});
}
return items;
}
);
}
export default createHealthCheckSelector;

@ -4,18 +4,19 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { testAllDownloadClients, testAllIndexers } from 'Store/Actions/settingsActions'; import { testAllDownloadClients, testAllIndexers } from 'Store/Actions/settingsActions';
import { fetchHealth } from 'Store/Actions/systemActions'; import { fetchHealth } from 'Store/Actions/systemActions';
import createHealthCheckSelector from 'Store/Selectors/createHealthCheckSelector';
import Health from './Health'; import Health from './Health';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createHealthCheckSelector(),
(state) => state.system.health, (state) => state.system.health,
(state) => state.settings.downloadClients.isTestingAll, (state) => state.settings.downloadClients.isTestingAll,
(state) => state.settings.indexers.isTestingAll, (state) => state.settings.indexers.isTestingAll,
(health, isTestingAllDownloadClients, isTestingAllIndexers) => { (items, health, isTestingAllDownloadClients, isTestingAllIndexers) => {
const { const {
isFetching, isFetching,
isPopulated, isPopulated
items
} = health; } = health;
return { return {

@ -4,17 +4,19 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus'; import PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus';
import { fetchHealth } from 'Store/Actions/systemActions'; import { fetchHealth } from 'Store/Actions/systemActions';
import createHealthCheckSelector from 'Store/Selectors/createHealthCheckSelector';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.app, (state) => state.app,
createHealthCheckSelector(),
(state) => state.system.health, (state) => state.system.health,
(app, health) => { (app, items, health) => {
const count = health.items.length; const count = items.length;
let errors = false; let errors = false;
let warnings = false; let warnings = false;
health.items.forEach((item) => { items.forEach((item) => {
if (item.type === 'error') { if (item.type === 'error') {
errors = true; errors = true;
} }

Loading…
Cancel
Save