Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
devceline committed Apr 11, 2024
1 parent 9de5bc5 commit feec713
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/notify-client/src/controllers/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
isJsonRpcResponse,
isJsonRpcResult,
} from "@walletconnect/jsonrpc-utils";
import { FIVE_MINUTES, ONE_DAY, THIRTY_MINUTES, THIRTY_SECONDS } from "@walletconnect/time";
import {
FIVE_MINUTES,
ONE_DAY,
THIRTY_MINUTES,
THIRTY_SECONDS,
} from "@walletconnect/time";
import { JsonRpcRecord, RelayerTypes } from "@walletconnect/types";
import {
TYPE_1,
Expand Down Expand Up @@ -82,11 +87,11 @@ export class NotifyEngine extends INotifyEngine {
// If client has been offline for more than 5 minutes - call watch subscriptions
const timeSinceOffline = Date.now() - this.disconnectTimer;

// Allow for margin for error
const timeSinceOfflineTolerance = THIRTY_SECONDS * 1_000;
// Allow for margin for error
const timeSinceOfflineTolerance = THIRTY_SECONDS * 1_000;

const offlineForMoreThan5Minutes =
(timeSinceOffline + timeSinceOfflineTolerance) >= FIVE_MINUTES * 1_000;
timeSinceOffline + timeSinceOfflineTolerance >= FIVE_MINUTES * 1_000;

this.disconnectTimer = 0;

Expand All @@ -97,13 +102,16 @@ export class NotifyEngine extends INotifyEngine {
const timeSinceFirstWatchSubscriptions =
Date.now() - this.lastWatchSubscriptionsCallTimestamp;

const timeSinceFirstWatchSubscriptionsTolerance = THIRTY_MINUTES * 1_000;
const timeSinceFirstWatchSubscriptionsTolerance =
THIRTY_MINUTES * 1_000;

const clientOnlineForOverADay =
(timeSinceFirstWatchSubscriptions + timeSinceFirstWatchSubscriptionsTolerance) > ONE_DAY * 1_000;
timeSinceFirstWatchSubscriptions +
timeSinceFirstWatchSubscriptionsTolerance >
ONE_DAY * 1_000;

// Call watch subscriptionsevery 24 hours
// This check will be triggered every reconnect
// Call watch subscriptionsevery 24 hours
// This check will be triggered every reconnect
if (clientOnlineForOverADay) {
this.watchLastWatchedAccountIfExists();
this.lastWatchSubscriptionsCallTimestamp = 0;
Expand Down

0 comments on commit feec713

Please sign in to comment.