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 = {
7171 'compileActions.ts' ,
7272 'editor/AceEditor.tsx' ,
7373 'editor/SimpleEditor.tsx' ,
74+ 'reducers/browser.ts' ,
7475 'reducers/client.ts' ,
7576 'reducers/code.ts' ,
7677 'reducers/crates.ts' ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ node_modules
2222! compileActions.ts
2323! editor /AceEditor.tsx
2424! editor /SimpleEditor.tsx
25+ ! reducers /browser.ts
2526! reducers /client.ts
2627! reducers /code.ts
2728! reducers /crates.ts
Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ export enum ActionType {
5959 ChangeBacktrace = 'CHANGE_BACKTRACE' ,
6060 SelectText = 'SELECT_TEXT' ,
6161 NotificationSeen = 'NOTIFICATION_SEEN' ,
62- BrowserWidthChanged = 'BROWSER_WIDTH_CHANGED' ,
6362}
6463
6564export const initializeApplication = ( ) => createAction ( ActionType . InitializeApplication ) ;
@@ -200,9 +199,6 @@ const notificationSeen = (notification: Notification) =>
200199
201200export const seenRustSurvey2022 = ( ) => notificationSeen ( Notification . RustSurvey2022 ) ;
202201
203- export const browserWidthChanged = ( isSmall : boolean ) =>
204- createAction ( ActionType . BrowserWidthChanged , { isSmall } ) ;
205-
206202function parseChannel ( s ?: string ) : Channel | null {
207203 switch ( s ) {
208204 case 'stable' :
@@ -306,7 +302,6 @@ export type Action =
306302 | ReturnType < typeof changeMonacoTheme >
307303 | ReturnType < typeof selectText >
308304 | ReturnType < typeof notificationSeen >
309- | ReturnType < typeof browserWidthChanged >
310305 | ReturnType < typeof editCode >
311306 | ReturnType < typeof addCrateType >
312307 | ReturnType < typeof navigateToIndex >
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { v4 } from 'uuid';
1111import {
1212 selectText ,
1313 reExecuteWithBacktrace ,
14- browserWidthChanged ,
1514} from './actions' ;
1615import { configureRustErrors } from './highlighting' ;
1716import PageSwitcher from './PageSwitcher' ;
@@ -25,6 +24,7 @@ import { performVersionsLoad } from './reducers/versions';
2524import { performCratesLoad } from './reducers/crates' ;
2625import { gotoPosition } from './reducers/position' ;
2726import { addImport , editCode , enableFeatureGate } from './reducers/code' ;
27+ import { browserWidthChanged } from './reducers/browser' ;
2828
2929const store = configureStore ( window ) ;
3030
Original file line number Diff line number Diff line change 1- import { Action , ActionType } from '../actions ' ;
1+ import { PayloadAction , createSlice } from '@reduxjs/toolkit ' ;
22
3- const DEFAULT : State = {
3+ const initialState : State = {
44 isSmall : true ,
55} ;
66
77export type State = {
88 isSmall : boolean ;
99} ;
1010
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+ } ) ;
1520
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