Write error to log on promise rejected
This commit is contained in:
parent
18ff3947b8
commit
2f582e66b9
@ -14,6 +14,15 @@ export type RejectedAction<T extends string> = Action<T> & {
|
|||||||
status: 'rejected'
|
status: 'rejected'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRejectedAction(
|
||||||
|
value: unknown,
|
||||||
|
): value is RejectedAction<string> {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const v = value as any
|
||||||
|
return !!v && 'type' in v && typeof v.type === 'string' &&
|
||||||
|
'status' in v && v.status === 'rejected'
|
||||||
|
}
|
||||||
|
|
||||||
export type AsyncAction<T extends string, P> =
|
export type AsyncAction<T extends string, P> =
|
||||||
PendingAction<T, P> |
|
PendingAction<T, P> |
|
||||||
ResolvedAction<T, P> |
|
ResolvedAction<T, P> |
|
||||||
|
|||||||
@ -123,7 +123,7 @@ extends React.PureComponent<ToolbarProps, ToolbarState> {
|
|||||||
if (this.props.desktopStream) {
|
if (this.props.desktopStream) {
|
||||||
this.props.onRemoveStream(ME_DESKTOP)
|
this.props.onRemoveStream(ME_DESKTOP)
|
||||||
} else {
|
} else {
|
||||||
this.props.onGetDesktopStream()
|
this.props.onGetDesktopStream().catch(() => {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import * as constants from '../constants'
|
import * as constants from '../constants'
|
||||||
import { Notification, NotificationActionType } from '../actions/NotifyActions'
|
import { error, Notification, NotificationActionType } from '../actions/NotifyActions'
|
||||||
|
import { isRejectedAction } from '../async'
|
||||||
|
import { AnyAction } from 'redux'
|
||||||
|
|
||||||
export type NotificationState = Record<string, Notification>
|
export type NotificationState = Record<string, Notification>
|
||||||
|
|
||||||
@ -7,7 +9,17 @@ const defaultState: NotificationState = {}
|
|||||||
|
|
||||||
export default function notifications (
|
export default function notifications (
|
||||||
state = defaultState,
|
state = defaultState,
|
||||||
action: NotificationActionType,
|
action: AnyAction,
|
||||||
|
) {
|
||||||
|
if (isRejectedAction(action)) {
|
||||||
|
action = error(action.payload)
|
||||||
|
}
|
||||||
|
return handleNotifications(state, action)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNotifications (
|
||||||
|
state = defaultState,
|
||||||
|
action: NotificationActionType,
|
||||||
) {
|
) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case constants.NOTIFY:
|
case constants.NOTIFY:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user