* Fix infinite skeleton in different use cases * Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * Update app/utils/teams.js Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
32 lines
984 B
TypeScript
32 lines
984 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {ErrorTypes} from '@mm-redux/action_types';
|
|
import {GenericAction} from '@mm-redux/types/actions';
|
|
export default ((state: Array<{error: any;displayable?: boolean;date: string}> = [], action: GenericAction) => {
|
|
switch (action.type) {
|
|
case ErrorTypes.DISMISS_ERROR: {
|
|
const nextState = [...state];
|
|
nextState.splice(action.index!, 1);
|
|
|
|
return nextState;
|
|
}
|
|
case ErrorTypes.LOG_ERROR: {
|
|
const nextState = state.length ? [...state] : [];
|
|
const {displayable, error} = action;
|
|
nextState.push({
|
|
displayable,
|
|
error,
|
|
date: new Date(Date.now()).toUTCString(),
|
|
});
|
|
|
|
return nextState;
|
|
}
|
|
case ErrorTypes.RESTORE_ERRORS:
|
|
return action.data;
|
|
case ErrorTypes.CLEAR_ERRORS: {
|
|
return [];
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
});
|