mirror of
https://github.com/gosticks/web.git
synced 2026-08-12 20:20:25 +00:00
Simplify nextID in LiveLog
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user