Skip to content

Commit 9ad875a

Browse files
victorvrvkiacolbert
authored andcommitted
Fixed time slider play functionality (#57)
* Fixed bug that made devtool refresh when we started recording. * added react-json-view to package-lock * Data stays filtered after new actions get posted * fixed time travel forward when already at tail of linked list. * Fixed time-slider play functionality.
1 parent bcc73d9 commit 9ad875a

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/app/components/App.jsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ class App extends Component {
8282
if (newDataActionType.includes(searchField.toLowerCase())) {
8383
this.setState(state => ({
8484
data: [...state.data, newData],
85-
filteredData: [...state.data, newData],
85+
isPlayingIndex: state.data.length,
86+
filteredData: [...state.filteredData, newData],
8687
}));
8788
} else {
8889
this.setState(state => ({
8990
data: [...state.data, newData],
91+
isPlayingIndex: state.data.length,
9092
}));
9193
}
9294
});
@@ -106,8 +108,8 @@ class App extends Component {
106108

107109
// functionality to change 'play' button to 'stop'
108110
setIsPlaying() {
109-
if (this.state.isPlayingIndex > this.state.data.length - 1) {
110-
this.setState({ isPlayingIndex: 0 });
111+
if (this.state.isPlayingIndex >= this.state.data.length - 1) {
112+
return;
111113
}
112114

113115
let { isPlaying } = this.state;
@@ -142,20 +144,11 @@ class App extends Component {
142144
}
143145

144146
actionInPlay() {
145-
let { isPlayingIndex } = this.state;
146-
const { isPlaying, data } = this.state;
147-
148-
if (isPlayingIndex >= data.length - 1) isPlayingIndex = 0;
149-
150-
this.setState({ isPlayingIndex: isPlayingIndex + 1 });
151-
const { id, action, state } = data[isPlayingIndex + 1];
152-
this.toTheFuture();
147+
const { data, isPlayingIndex } = this.state;
153148

154149
setTimeout(() => {
155-
this.setState((prev, props) => {
156-
return { ...prev, id, action, state };
157-
});
158-
if (isPlaying && isPlayingIndex + 1 < data.length - 1) {
150+
this.toTheFuture();
151+
if (this.state.isPlaying && isPlayingIndex + 1 < data.length - 1) {
159152
this.actionInPlay();
160153
} else {
161154
this.setState({ isPlaying: false });
@@ -289,6 +282,7 @@ class App extends Component {
289282
setIsRecording,
290283
isRecording,
291284
filteredData,
285+
searchField,
292286
} = this.state;
293287

294288
return (
@@ -304,6 +298,7 @@ class App extends Component {
304298
activeEventId={id}
305299
searchChange={this.searchChange}
306300
filteredData={filteredData}
301+
searchField={searchField}
307302
/>
308303
)}
309304
right={

src/app/components/EventCards/FilterBar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default function FilterBar(props) {
1616
type="text"
1717
placeholder="filter actions by name..."
1818
onChange={searchChange}
19+
value={props.searchField}
1920
/>
2021
</FilterWrapper>
2122
</>

src/app/container/Events.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class Events extends Component {
1818
data,
1919
searchChange,
2020
filteredData,
21+
searchField,
2122
} = this.props;
2223
return (
2324
<>
2425
<EventsNav />
25-
<FilterBar searchChange={searchChange} />
26+
<FilterBar searchChange={searchChange} searchField={searchField} />
2627
<EventsDisplay
2728
data={data}
2829
filteredData={filteredData}

0 commit comments

Comments
 (0)