Simplify nextID in LiveLog

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
Mcat12
2019-12-17 16:12:58 -05:00
parent f5f2503f1a
commit 3e77fa827d
+20 -21
View File
@@ -33,7 +33,6 @@ interface LiveLogState {
scrollEnabled: boolean;
}
let nextId = 0;
class LiveLog extends Component<LiveLogProps & WithTranslation, LiveLogState> {
static getDerivedStateFromProps(
props: LiveLogProps,
@@ -56,10 +55,6 @@ class LiveLog extends Component<LiveLogProps & WithTranslation, LiveLogState> {
}
}
componentDidMount() {
nextId = 0;
}
scrollToBottom() {
animateScroll.scrollToBottom({
containerId: "output",
@@ -124,19 +119,23 @@ class LiveLog extends Component<LiveLogProps & WithTranslation, LiveLogState> {
export const TranslatedLiveLog = withTranslation(["live-log"])(LiveLog);
export default () => (
<WithAPIData
apiCall={() => {
return api.getLiveLog(nextId).then(response => {
nextId = response.nextID;
return response;
});
}}
repeatOptions={{ interval: 500, ignoreCancel: true }}
renderInitial={() => null}
renderOk={data => (
<TranslatedLiveLog log={data.log} refreshInterval={500} />
)}
renderErr={() => null}
/>
);
export default () => {
let nextId = 0;
return (
<WithAPIData
apiCall={() => {
return api.getLiveLog(nextId).then(response => {
nextId = response.nextID;
return response;
});
}}
repeatOptions={{ interval: 500, ignoreCancel: true }}
renderInitial={() => null}
renderOk={data => (
<TranslatedLiveLog log={data.log} refreshInterval={500} />
)}
renderErr={() => null}
/>
);
};