sfc-utils 1.4.132 → 1.4.134
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/accountswap.js +9 -10
- package/package.json +1 -1
package/accountswap.js
CHANGED
|
@@ -12,12 +12,12 @@ const pollForAccount = async function (i, isNav) {
|
|
|
12
12
|
i = 0;
|
|
13
13
|
}
|
|
14
14
|
// Safecheck for treg since it might not be global yet
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
window.treg
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (window && window.treg && window.treg.identity) {
|
|
16
|
+
// Now we have all the vars to know if we're logged in
|
|
17
|
+
if (!window.treg.identity.id) {
|
|
18
|
+
// If we don't have an identity, we're not logged in
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
21
|
if (isNav) {
|
|
22
22
|
// We got a valid entitlement! Let's see if the button exists and swap our new one in
|
|
23
23
|
const subButton = document.querySelector("#nav2-sub-box");
|
|
@@ -43,12 +43,11 @@ const pollForAccount = async function (i, isNav) {
|
|
|
43
43
|
return true;
|
|
44
44
|
} else {
|
|
45
45
|
if (i > 10) {
|
|
46
|
-
// If we've waited
|
|
46
|
+
// If we've waited 5 seconds and there's still no entitlement, assume we aren't getting one
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
// Check again after
|
|
50
|
-
|
|
51
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
49
|
+
// Check again after 0.5 sec using a Promise with async/await
|
|
50
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
52
51
|
return await pollForAccount(i + 1, isNav);
|
|
53
52
|
}
|
|
54
53
|
};
|