File tree Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,6 @@ export const SET_BLOB_URL = 'SET_BLOB_URL';
5353export const EXPAND_SIDEBAR = 'EXPAND_SIDEBAR' ;
5454export const COLLAPSE_SIDEBAR = 'COLLAPSE_SIDEBAR' ;
5555
56- export const CONSOLE_EVENT = 'CONSOLE_EVENT' ;
57- export const CLEAR_CONSOLE = 'CLEAR_CONSOLE' ;
5856export const EXPAND_CONSOLE = 'EXPAND_CONSOLE' ;
5957export const COLLAPSE_CONSOLE = 'COLLAPSE_CONSOLE' ;
6058
Original file line number Diff line number Diff line change 1- import * as ActionTypes from '../../../constants ' ;
1+ import { consoleActions } from '../reducers/console ' ;
22
3- export function clearConsole ( ) {
4- return {
5- type : ActionTypes . CLEAR_CONSOLE
6- } ;
7- }
8-
9- export function dispatchConsoleEvent ( messages ) {
10- return {
11- type : ActionTypes . CONSOLE_EVENT ,
12- event : messages
13- } ;
14- }
3+ export const { dispatchConsoleEvent, clearConsole } = consoleActions ;
Original file line number Diff line number Diff line change 1- import * as ActionTypes from '../../../constants ' ;
1+ import { createSlice } from '@reduxjs/toolkit ' ;
22
33const consoleMax = 5000 ;
44const initialState = [ ] ;
55
6- const console = ( state = initialState , action ) => {
7- let messages ;
8- switch ( action . type ) {
9- case ActionTypes . CONSOLE_EVENT :
10- messages = [ ...action . event ] ;
6+ const consoleSlice = createSlice ( {
7+ name : 'console' ,
8+ initialState,
9+ reducers : {
10+ dispatchConsoleEvent : ( state , action ) => {
11+ const messages = [ ...action . event ] ;
1112 return state . concat ( messages ) . slice ( - consoleMax ) ;
12- case ActionTypes . CLEAR_CONSOLE :
13- return [ ] ;
14- default :
15- return state ;
13+ } ,
14+ clearConsole : ( state , action ) => [ ]
1615 }
17- } ;
16+ } ) ;
1817
19- export default console ;
18+ export const consoleActions = consoleSlice . actions ;
19+
20+ export default consoleSlice . reducer ;
You can’t perform that action at this time.
0 commit comments