Merge pull request #4936 from matrix-org/travis/general/perf/js-roomstate-map
Convert devtools dialog to use new room state format
This commit is contained in:
commit
8b65b19e60
1 changed files with 11 additions and 13 deletions
|
@ -19,7 +19,7 @@ import PropTypes from 'prop-types';
|
||||||
import * as sdk from '../../../index';
|
import * as sdk from '../../../index';
|
||||||
import SyntaxHighlight from '../elements/SyntaxHighlight';
|
import SyntaxHighlight from '../elements/SyntaxHighlight';
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import { Room } from "matrix-js-sdk";
|
import { Room, MatrixEvent } from "matrix-js-sdk";
|
||||||
import Field from "../elements/Field";
|
import Field from "../elements/Field";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
||||||
|
@ -327,6 +327,8 @@ class RoomStateExplorer extends React.PureComponent {
|
||||||
|
|
||||||
static contextType = MatrixClientContext;
|
static contextType = MatrixClientContext;
|
||||||
|
|
||||||
|
roomStateEvents: Map<string, Map<string, MatrixEvent>>;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
@ -412,30 +414,26 @@ class RoomStateExplorer extends React.PureComponent {
|
||||||
if (this.state.eventType === null) {
|
if (this.state.eventType === null) {
|
||||||
list = <FilteredList query={this.state.queryEventType} onChange={this.onQueryEventType}>
|
list = <FilteredList query={this.state.queryEventType} onChange={this.onQueryEventType}>
|
||||||
{
|
{
|
||||||
Object.keys(this.roomStateEvents).map((evType) => {
|
Array.from(this.roomStateEvents.entries()).map(([eventType, allStateKeys]) => {
|
||||||
const stateGroup = this.roomStateEvents[evType];
|
|
||||||
const stateKeys = Object.keys(stateGroup);
|
|
||||||
|
|
||||||
let onClickFn;
|
let onClickFn;
|
||||||
if (stateKeys.length === 1 && stateKeys[0] === '') {
|
if (allStateKeys.size() === 1 && allStateKeys.has("")) {
|
||||||
onClickFn = this.onViewSourceClick(stateGroup[stateKeys[0]]);
|
onClickFn = this.onViewSourceClick(allStateKeys.get(""));
|
||||||
} else {
|
} else {
|
||||||
onClickFn = this.browseEventType(evType);
|
onClickFn = this.browseEventType(eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <button className={classes} key={evType} onClick={onClickFn}>
|
return <button className={classes} key={eventType} onClick={onClickFn}>
|
||||||
{ evType }
|
{eventType}
|
||||||
</button>;
|
</button>;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</FilteredList>;
|
</FilteredList>;
|
||||||
} else {
|
} else {
|
||||||
const stateGroup = this.roomStateEvents[this.state.eventType];
|
const stateGroup = this.roomStateEvents.get(this.state.eventType);
|
||||||
|
|
||||||
list = <FilteredList query={this.state.queryStateKey} onChange={this.onQueryStateKey}>
|
list = <FilteredList query={this.state.queryStateKey} onChange={this.onQueryStateKey}>
|
||||||
{
|
{
|
||||||
Object.keys(stateGroup).map((stateKey) => {
|
Array.from(stateGroup.entries()).map(([stateKey, ev]) => {
|
||||||
const ev = stateGroup[stateKey];
|
|
||||||
return <button className={classes} key={stateKey} onClick={this.onViewSourceClick(ev)}>
|
return <button className={classes} key={stateKey} onClick={this.onViewSourceClick(ev)}>
|
||||||
{ stateKey }
|
{ stateKey }
|
||||||
</button>;
|
</button>;
|
||||||
|
|
Loading…
Reference in a new issue