File tree Expand file tree Collapse file tree 4 files changed +41
-6
lines changed
features/recent-loopback-messages Expand file tree Collapse file tree 4 files changed +41
-6
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,13 @@ export const recentLoopbackMessagesSlice = createAppSlice({
3737 if ( state [ qid ] . length > 100 ) state [ qid ] . shift ( ) ;
3838 } ,
3939 ) ,
40- } ) ,
41- extraReducers : ( builder ) => {
42- // on project change, clear recent input events
43- builder . addCase ( 'projectName/setName' , ( state ) => {
40+
41+ clearAllMessages : create . reducer ( ( state ) => {
4442 Array . from ( Object . keys ( state ) ) . forEach ( ( k ) => {
4543 delete state [ k ] ;
4644 } ) ;
47- } ) ;
48- } ,
45+ } ) ,
46+ } ) ,
4947} ) ;
5048
5149export const selectRecentLoopbackMessages = ( state : RootState , id : string ) =>
Original file line number Diff line number Diff line change 1+ import { startAppListening } from '../store/listener-middleware' ;
2+ import { projectNameSlice } from '../features/project-name/project-name-slice' ;
3+ import { recentLoopbackMessagesSlice } from '../features/recent-loopback-messages/recent-loopback-messages-slice' ;
4+
5+ /**
6+ * Listens to changes to the current superset dashboard layout. This callback is invoked whenever
7+ * a gridComponent is added or removed from the layout.
8+ *
9+ * It's currently updating in a not-smart way; whenever an update happens, every IkiDynamicMarkdown
10+ * gridComponent notifies the ContextService to alert us that the layout has changed. Therefore,
11+ * we end up receiving far too many changed events
12+ */
13+ startAppListening ( {
14+ actionCreator : projectNameSlice . actions . setName ,
15+ effect : async ( action , listenerApi ) => {
16+ // ignore if the action is dispatched with the same payload
17+ if ( action . payload === listenerApi . getState ( ) . projectName . name ) {
18+ return ;
19+ }
20+
21+ listenerApi . dispatch (
22+ recentLoopbackMessagesSlice . actions . clearAllMessages ( ) ,
23+ ) ;
24+ } ,
25+ } ) ;
Original file line number Diff line number Diff line change 1+ import { createListenerMiddleware } from '@reduxjs/toolkit' ;
2+
3+ import type { AppDispatch , RootState } from './store' ;
4+
5+ export const listenerMiddleware = createListenerMiddleware ( ) ;
6+
7+ export const startAppListening = listenerMiddleware . startListening . withTypes <
8+ RootState ,
9+ AppDispatch
10+ > ( ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import { recentLoopbackMessagesSlice } from '../features/recent-loopback-message
1414import { recentRemoteMessagesSlice } from '../features/recent-remote-messages/recent-remote-messages-slice' ;
1515import { projectNameSlice } from '../features/project-name/project-name-slice' ;
1616
17+ import '../middleware/project-name-listener' ;
18+
1719const rootReducer = combineSlices (
1820 connectedDevicesSlice ,
1921 configuredDevicesSlice ,
You can’t perform that action at this time.
0 commit comments