Restore computeNotifications
Summary: Restore the logic for setting and computing notifications that was partially removed with D10300838. Reviewed By: jknoxville Differential Revision: D10361547 fbshipit-source-id: 4d229d5f4dbeda3139463e1c348909b9c5dba66f
This commit is contained in:
committed by
Facebook Github Bot
parent
4889f5dc6a
commit
01020edbf2
@@ -22,6 +22,7 @@ import {
|
||||
} from 'flipper';
|
||||
import RequestDetails from './RequestDetails.js';
|
||||
import {URL} from 'url';
|
||||
import type {Notification} from '../../plugin';
|
||||
|
||||
type RequestId = string;
|
||||
|
||||
@@ -159,20 +160,21 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
|
||||
};
|
||||
|
||||
computeNotifications(props: *, state: State) {
|
||||
const notifications = {};
|
||||
const notifications: Array<Notification> = [];
|
||||
const persistedState = props.persistedState;
|
||||
for (const response in persistedState.responses) {
|
||||
const status = persistedState.responses[response].status;
|
||||
if (status >= 400) {
|
||||
const id = persistedState.requests[response]?.id;
|
||||
if (status >= 400 && id != null) {
|
||||
const url = persistedState.requests[response]?.url;
|
||||
const startTime = persistedState.requests[response]?.timestamp;
|
||||
const endTime = persistedState.responses[response].timestamp;
|
||||
notifications[`${url}-${startTime}`] = {
|
||||
notifications.push({
|
||||
id,
|
||||
timestamp: endTime,
|
||||
title: 'Failed network request',
|
||||
message: `Response for ${url} failed with status code ${status}`,
|
||||
severity: 'error',
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
return notifications;
|
||||
|
||||
Reference in New Issue
Block a user