Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions chrome/panel.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/DevtoolsPanel/helpers/sortState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const sortState = (currentState) => {
const alphabeticallySortedCurrentState = {};
Object.keys(currentState)
.sort()
.forEach((state) => {
Object.assign(alphabeticallySortedCurrentState, { [state]: currentState[state]})
});
return alphabeticallySortedCurrentState;
}
7 changes: 5 additions & 2 deletions src/DevtoolsPanel/modules/CurrentState/CurrentState.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect} from 'react';
import React, { useMemo, useEffect, useCallback } from 'react';
import { useEmit, useEventrixState } from 'eventrix';
import RefreshIcon from '@material-ui/icons/Refresh';
import StorageIcon from '@material-ui/icons/Storage';
Expand All @@ -13,6 +13,7 @@ import Chip from "@material-ui/core/Chip";
import ListenerIcon from '@material-ui/icons/WifiTethering';
import ReceiverIcon from '@material-ui/icons/SettingsInputAntenna';
import Divider from "@material-ui/core/Divider";
import { sortState } from '../../helpers/sortState';

const CurrentState = () => {
const emit = useEmit();
Expand All @@ -24,10 +25,12 @@ const CurrentState = () => {
fetchState();
fetchStateListeners();
}, [fetchState, fetchStateListeners]);
const alphabeticallySortedCurrentState = useMemo(() => sortState(currentState), [currentState])

useEffect(() => {
fetchAll()
}, [fetchAll]);

return (
<div className={styles.moduleContainer}>
<ModuleHeader icon={<StorageIcon fontSize="medium"/>} title="Current state">
Expand All @@ -38,7 +41,7 @@ const CurrentState = () => {
</ModuleHeader>
<div className={styles.moduleContent}>
<div className={styles.statePreview}>
<ObjectInspector data={currentState} />
<ObjectInspector data={alphabeticallySortedCurrentState} />
</div>
<div className={styles.stateListenersList}>
<h4>States that are listening</h4>
Expand Down