@opexa/portal-sdk 0.59.93 → 0.59.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var objectId = require('@opexa/object-id');
4
- var app = require('@capacitor/app');
5
4
  var core = require('@capacitor/core');
6
5
  var thumbmarkjs = require('@thumbmarkjs/thumbmarkjs');
7
6
  var cookies = require('js-cookie');
@@ -10650,14 +10649,12 @@ var Sdk = class {
10650
10649
  }
10651
10650
  watchSession(input) {
10652
10651
  const interval = clamp(input.interval ?? 3e4, 5e3, 6e4);
10652
+ let counter = 0;
10653
10653
  let timeout = null;
10654
- let isForeground = true;
10655
- const listener = app.App.addListener("appStateChange", ({ isActive }) => {
10656
- isForeground = isActive;
10657
- });
10658
10654
  const assignTimeout = () => {
10655
+ const duration = counter <= 0 ? interval * 0.5 : interval;
10659
10656
  return setTimeout(async () => {
10660
- if (isForeground) {
10657
+ {
10661
10658
  let res;
10662
10659
  try {
10663
10660
  res = await this.sessionManager.verify();
@@ -10668,15 +10665,15 @@ var Sdk = class {
10668
10665
  await input.onInvalid(res.reason ?? "INVALID_SESSION");
10669
10666
  }
10670
10667
  }
10668
+ counter += 1;
10671
10669
  timeout = assignTimeout();
10672
- }, interval);
10670
+ }, duration);
10673
10671
  };
10674
10672
  timeout = assignTimeout();
10675
10673
  return function unsubscribe() {
10676
10674
  if (timeout) {
10677
10675
  clearTimeout(timeout);
10678
10676
  }
10679
- listener.then((handle) => handle.remove());
10680
10677
  };
10681
10678
  }
10682
10679
  async session() {