From 545f11d742db110325a579c673de6f3ebcb08393 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 8 Jul 2020 22:23:51 -0600 Subject: [PATCH 1/2] Convert devtools dialog to use new room state format --- src/components/views/dialogs/DevtoolsDialog.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index 08817cdfee..b3f9ef4537 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -412,13 +412,13 @@ class RoomStateExplorer extends React.PureComponent { if (this.state.eventType === null) { list = { - Object.keys(this.roomStateEvents).map((evType) => { - const stateGroup = this.roomStateEvents[evType]; - const stateKeys = Object.keys(stateGroup); + Array.from(this.roomStateEvents.keys()).map((evType) => { + const stateGroup = this.roomStateEvents.get(evType); + const stateKeys = Array.from(stateGroup.keys()); let onClickFn; if (stateKeys.length === 1 && stateKeys[0] === '') { - onClickFn = this.onViewSourceClick(stateGroup[stateKeys[0]]); + onClickFn = this.onViewSourceClick(stateGroup.get(stateKeys[0])); } else { onClickFn = this.browseEventType(evType); } @@ -430,12 +430,12 @@ class RoomStateExplorer extends React.PureComponent { } ; } else { - const stateGroup = this.roomStateEvents[this.state.eventType]; + const stateGroup = this.roomStateEvents.get(this.state.eventType); list = { - Object.keys(stateGroup).map((stateKey) => { - const ev = stateGroup[stateKey]; + Array.from(stateGroup.keys()).map((stateKey) => { + const ev = stateGroup.get(stateKey); return ; From 9c9ff281e7c700dd8a0db650c3ae541f0a4a9e1f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 16 Jul 2020 13:00:02 -0600 Subject: [PATCH 2/2] Use .entries() --- .../views/dialogs/DevtoolsDialog.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index b3f9ef4537..26ab71a873 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -19,7 +19,7 @@ import PropTypes from 'prop-types'; import * as sdk from '../../../index'; import SyntaxHighlight from '../elements/SyntaxHighlight'; import { _t } from '../../../languageHandler'; -import { Room } from "matrix-js-sdk"; +import { Room, MatrixEvent } from "matrix-js-sdk"; import Field from "../elements/Field"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import {useEventEmitter} from "../../../hooks/useEventEmitter"; @@ -327,6 +327,8 @@ class RoomStateExplorer extends React.PureComponent { static contextType = MatrixClientContext; + roomStateEvents: Map>; + constructor(props) { super(props); @@ -412,19 +414,16 @@ class RoomStateExplorer extends React.PureComponent { if (this.state.eventType === null) { list = { - Array.from(this.roomStateEvents.keys()).map((evType) => { - const stateGroup = this.roomStateEvents.get(evType); - const stateKeys = Array.from(stateGroup.keys()); - + Array.from(this.roomStateEvents.entries()).map(([eventType, allStateKeys]) => { let onClickFn; - if (stateKeys.length === 1 && stateKeys[0] === '') { - onClickFn = this.onViewSourceClick(stateGroup.get(stateKeys[0])); + if (allStateKeys.size() === 1 && allStateKeys.has("")) { + onClickFn = this.onViewSourceClick(allStateKeys.get("")); } else { - onClickFn = this.browseEventType(evType); + onClickFn = this.browseEventType(eventType); } - return ; }) } @@ -434,8 +433,7 @@ class RoomStateExplorer extends React.PureComponent { list = { - Array.from(stateGroup.keys()).map((stateKey) => { - const ev = stateGroup.get(stateKey); + Array.from(stateGroup.entries()).map(([stateKey, ev]) => { return ;