@@ -10,6 +10,7 @@ Please see LICENSE files in the repository root for full details.
10
10
import React , { useContext , useEffect , useMemo , useState } from "react" ;
11
11
import { type IContent , type MatrixEvent } from "matrix-js-sdk/src/matrix" ;
12
12
import classNames from "classnames" ;
13
+ import { Checkbox , CheckboxInput } from "@vector-im/compound-web" ;
13
14
14
15
import { _t , _td } from "../../../../languageHandler" ;
15
16
import BaseTool , { DevtoolsContext , type IDevtoolsProps } from "./BaseTool" ;
@@ -19,6 +20,8 @@ import FilteredList from "./FilteredList";
19
20
import Spinner from "../../elements/Spinner" ;
20
21
import SyntaxHighlight from "../../elements/SyntaxHighlight" ;
21
22
import { useAsyncMemo } from "../../../../hooks/useAsyncMemo" ;
23
+ import LabelledToggleSwitch from "../../elements/LabelledToggleSwitch" ;
24
+ import { set } from "lodash" ;
22
25
23
26
export const StateEventEditor : React . FC < IEditorProps > = ( { mxEvent, onBack } ) => {
24
27
const context = useContext ( DevtoolsContext ) ;
@@ -114,6 +117,7 @@ const RoomStateExplorerEventType: React.FC<IEventTypeProps> = ({ eventType, onBa
114
117
const [ query , setQuery ] = useState ( "" ) ;
115
118
const [ event , setEvent ] = useState < MatrixEvent | null > ( null ) ;
116
119
const [ history , setHistory ] = useState ( false ) ;
120
+ const [ hideEmptyState , setHideEmptyState ] = useState ( false ) ;
117
121
118
122
const events = context . room . currentState . events . get ( eventType ) ! ;
119
123
@@ -149,10 +153,13 @@ const RoomStateExplorerEventType: React.FC<IEventTypeProps> = ({ eventType, onBa
149
153
return (
150
154
< BaseTool onBack = { onBack } >
151
155
< FilteredList query = { query } onChange = { setQuery } >
152
- { Array . from ( events . entries ( ) ) . map ( ( [ stateKey , ev ] ) => (
153
- < StateEventButton key = { stateKey } label = { stateKey } onClick = { ( ) => setEvent ( ev ) } />
154
- ) ) }
156
+ { Array . from ( events . entries ( ) )
157
+ . filter ( ( [ _ , ev ] ) => ! hideEmptyState || Object . keys ( ev . getContent ( ) ) . length > 0 )
158
+ . map ( ( [ stateKey , ev ] ) => (
159
+ < StateEventButton key = { stateKey } label = { stateKey } onClick = { ( ) => setEvent ( ev ) } />
160
+ ) ) }
155
161
</ FilteredList >
162
+ < LabelledToggleSwitch label = "Hide empty state keys" onChange = { setHideEmptyState } value = { hideEmptyState } />
156
163
</ BaseTool >
157
164
) ;
158
165
} ;
0 commit comments