File tree Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ module.exports = {
71
71
'compileActions.ts' ,
72
72
'editor/AceEditor.tsx' ,
73
73
'editor/SimpleEditor.tsx' ,
74
+ 'reducers/browser.ts' ,
74
75
'reducers/client.ts' ,
75
76
'reducers/code.ts' ,
76
77
'reducers/crates.ts' ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ node_modules
22
22
! compileActions.ts
23
23
! editor /AceEditor.tsx
24
24
! editor /SimpleEditor.tsx
25
+ ! reducers /browser.ts
25
26
! reducers /client.ts
26
27
! reducers /code.ts
27
28
! reducers /crates.ts
Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ export enum ActionType {
59
59
ChangeBacktrace = 'CHANGE_BACKTRACE' ,
60
60
SelectText = 'SELECT_TEXT' ,
61
61
NotificationSeen = 'NOTIFICATION_SEEN' ,
62
- BrowserWidthChanged = 'BROWSER_WIDTH_CHANGED' ,
63
62
}
64
63
65
64
export const initializeApplication = ( ) => createAction ( ActionType . InitializeApplication ) ;
@@ -200,9 +199,6 @@ const notificationSeen = (notification: Notification) =>
200
199
201
200
export const seenRustSurvey2022 = ( ) => notificationSeen ( Notification . RustSurvey2022 ) ;
202
201
203
- export const browserWidthChanged = ( isSmall : boolean ) =>
204
- createAction ( ActionType . BrowserWidthChanged , { isSmall } ) ;
205
-
206
202
function parseChannel ( s ?: string ) : Channel | null {
207
203
switch ( s ) {
208
204
case 'stable' :
@@ -306,7 +302,6 @@ export type Action =
306
302
| ReturnType < typeof changeMonacoTheme >
307
303
| ReturnType < typeof selectText >
308
304
| ReturnType < typeof notificationSeen >
309
- | ReturnType < typeof browserWidthChanged >
310
305
| ReturnType < typeof editCode >
311
306
| ReturnType < typeof addCrateType >
312
307
| ReturnType < typeof navigateToIndex >
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { v4 } from 'uuid';
11
11
import {
12
12
selectText ,
13
13
reExecuteWithBacktrace ,
14
- browserWidthChanged ,
15
14
} from './actions' ;
16
15
import { configureRustErrors } from './highlighting' ;
17
16
import PageSwitcher from './PageSwitcher' ;
@@ -25,6 +24,7 @@ import { performVersionsLoad } from './reducers/versions';
25
24
import { performCratesLoad } from './reducers/crates' ;
26
25
import { gotoPosition } from './reducers/position' ;
27
26
import { addImport , editCode , enableFeatureGate } from './reducers/code' ;
27
+ import { browserWidthChanged } from './reducers/browser' ;
28
28
29
29
const store = configureStore ( window ) ;
30
30
Original file line number Diff line number Diff line change 1
- import { Action , ActionType } from '../actions ' ;
1
+ import { PayloadAction , createSlice } from '@reduxjs/toolkit ' ;
2
2
3
- const DEFAULT : State = {
3
+ const initialState : State = {
4
4
isSmall : true ,
5
5
} ;
6
6
7
7
export type State = {
8
8
isSmall : boolean ;
9
9
} ;
10
10
11
- export default function code ( state = DEFAULT , action : Action ) : State {
12
- switch ( action . type ) {
13
- case ActionType . BrowserWidthChanged :
14
- return { ...state , isSmall : action . isSmall } ;
11
+ const slice = createSlice ( {
12
+ name : 'browser' ,
13
+ initialState,
14
+ reducers : {
15
+ browserWidthChanged : ( state , action : PayloadAction < boolean > ) => {
16
+ state . isSmall = action . payload ;
17
+ } ,
18
+ } ,
19
+ } ) ;
15
20
16
- default :
17
- return state ;
18
- }
19
- }
21
+ export const { browserWidthChanged } = slice . actions ;
22
+
23
+ export default slice . reducer ;
You can’t perform that action at this time.
0 commit comments