Skip to content

Commit 687c2b2

Browse files
committed
this is a test
2 parents 284dd05 + 9ad875a commit 687c2b2

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

src/app/components/App.jsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +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],
8685
isPlayingIndex: state.data.length,
86+
filteredData: [...state.filteredData, newData],
8787
}));
8888
} else {
8989
this.setState(state => ({
9090
data: [...state.data, newData],
91+
isPlayingIndex: state.data.length,
9192
}));
9293
}
9394
});
@@ -107,12 +108,13 @@ class App extends Component {
107108

108109
// functionality to change 'play' button to 'stop'
109110
setIsPlaying() {
110-
if (this.state.isPlayingIndex >= this.state.data.length) {
111-
this.setState(prevState => ({ ...prevState, isPlayingIndex: 0 }));
111+
if (this.state.isPlayingIndex >= this.state.data.length - 1) {
112+
return;
112113
}
113114

114115
let { isPlaying } = this.state;
115-
this.setState(prevState => ({ ...prevState, isPlaying: !prevState.isPlaying }));
116+
isPlaying = !isPlaying;
117+
this.setState({ isPlaying });
116118

117119
if (isPlaying) {
118120
this.actionInPlay();
@@ -142,23 +144,14 @@ 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(prevState => ({ ...prevState, 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 {
161-
this.setState(prevState => ({ ...prevState, isPlaying: false }));
154+
this.setState({ isPlaying: false });
162155
}
163156
}, 1000);
164157
}
@@ -226,7 +219,7 @@ class App extends Component {
226219
direction: 'forward',
227220
});
228221

229-
if (this.state.isPlayingIndex >= this.state.data.length - 1) this.setState(prev => ({ ...prev, isPlayingIndex: 0 }));
222+
// if (isPlayingIndex >= this.state.data.length - 1) isPlayingIndex = 0;
230223

231224
const { id, action, state } = data[isPlayingIndex + 1];
232225
this.setState(prev => ({
@@ -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={
@@ -331,5 +326,4 @@ class App extends Component {
331326
);
332327
}
333328
}
334-
335-
export default App;
329+
export default App;

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)