File tree 3 files changed +15
-27
lines changed
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';
53
53
export const EXPAND_SIDEBAR = 'EXPAND_SIDEBAR' ;
54
54
export const COLLAPSE_SIDEBAR = 'COLLAPSE_SIDEBAR' ;
55
55
56
- export const CONSOLE_EVENT = 'CONSOLE_EVENT' ;
57
- export const CLEAR_CONSOLE = 'CLEAR_CONSOLE' ;
58
56
export const EXPAND_CONSOLE = 'EXPAND_CONSOLE' ;
59
57
export const COLLAPSE_CONSOLE = 'COLLAPSE_CONSOLE' ;
60
58
Original file line number Diff line number Diff line change 1
- import * as ActionTypes from '../../../constants ' ;
1
+ import { consoleActions } from '../reducers/console ' ;
2
2
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 ' ;
2
2
3
3
const consoleMax = 5000 ;
4
4
const initialState = [ ] ;
5
5
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 ] ;
11
12
return state . concat ( messages ) . slice ( - consoleMax ) ;
12
- case ActionTypes . CLEAR_CONSOLE :
13
- return [ ] ;
14
- default :
15
- return state ;
13
+ } ,
14
+ clearConsole : ( state , action ) => [ ]
16
15
}
17
- } ;
16
+ } ) ;
18
17
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