Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
startCount() {
const startedTime = Date.now();
const maxTimeoutFactor = 10;
const interval = 200;
BackgroundTimer.clearTimeout(this.intervalId);
this.intervalId = BackgroundTimer.setInterval(() => {
const timeDiff = Date.now() - startedTime;
this.setState({fill: 100 - timeDiff * maxTimeoutFactor / 1000});
if (this.state.fill <= 0) {
// when timeout
BackgroundTimer.clearTimeout(this.intervalId);
this.setState({receivedNewOrder: false});
this.props.setWaitingNewOrder(true);
}
}, interval);
}
function startTimer(dispatch, getState) {
if (Platform.OS === 'android') {
this.intervalId = BackgroundTimer.setInterval(() => {
dispatch(setDuration(getState().activity.duration + 1));
}, 1000);
} else {
// Not tested for iOS
BackgroundTimer.start();
setInterval(() => {
dispatch(setDuration(getState().activity.duration + 1));
}, 1000);
}
}
onConferenceJoined = () => {
RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e));
if (this.jitsiTimeout) {
BackgroundTimer.clearInterval(this.jitsiTimeout);
}
this.jitsiTimeout = BackgroundTimer.setInterval(() => {
RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e));
}, 10000);
}
export const startSessionTimer = (cb: any, interval: number) => {
const duration = interval || backgroundDuration
if (!cb) {
backgroundTimerEndTime = getCurrentTimeStamp() + duration
currentCallback = defaultCallback
} else {
currentCallback = cb
}
if (!currentCallback) {
return
}
stopSessionTimer()
BackgroundTimer.start()
timeout = BackgroundTimer.setInterval(currentCallback, duration)
}