force reconnect if countdown is negative (computer woke up from sleep)

This commit is contained in:
or-else
2022-11-14 17:20:07 -08:00
parent 2156aa0877
commit c7b8ce11e0
5 changed files with 23 additions and 11 deletions
+11 -4
View File
@@ -622,7 +622,7 @@ class TinodeWeb extends React.Component {
if (prom) {
// Reconnecting now
prom.then(() => {
prom.then(_ => {
// Reconnected: clear error
this.handleError();
}).catch((err) => {
@@ -634,10 +634,17 @@ class TinodeWeb extends React.Component {
const {formatMessage} = this.props.intl;
let count = sec / 1000;
count = count | count;
this.reconnectCountdown = setInterval(() => {
const timeLeft = (count > 99) ? secondsToTime(count) : count;
this.reconnectCountdown = setInterval(_ => {
if (count < -10) {
// Count could go to negative if computer woke up from sleep.
clearInterval(this.reconnectCountdown);
this.tinode.reconnect();
return;
}
const fmtTime = (count > 99) ? secondsToTime(count) : count;
this.handleError(
formatMessage(messages.reconnect_countdown, {seconds: timeLeft}),
formatMessage(messages.reconnect_countdown, {seconds: fmtTime}),
'warn',
_ => {
clearInterval(this.reconnectCountdown);