Backoff live subscription retries after a failed connect
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -732,6 +732,7 @@ export class NestQuestPartyBoardCard extends LitElement {
|
|||||||
private _unsubs: Array<() => void> = [];
|
private _unsubs: Array<() => void> = [];
|
||||||
private _subscribed = false;
|
private _subscribed = false;
|
||||||
private _subGeneration = 0;
|
private _subGeneration = 0;
|
||||||
|
private _retryTimer?: number;
|
||||||
|
|
||||||
setConfig(config: CardConfig): void {
|
setConfig(config: CardConfig): void {
|
||||||
if (!config || typeof config !== "object") {
|
if (!config || typeof config !== "object") {
|
||||||
@@ -775,7 +776,7 @@ export class NestQuestPartyBoardCard extends LitElement {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (token === this._subGeneration) {
|
if (token === this._subGeneration) {
|
||||||
this._unsubscribeLive();
|
this._unsubscribeLive();
|
||||||
this.requestUpdate();
|
this._armSubscribeRetry();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -786,7 +787,25 @@ export class NestQuestPartyBoardCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _armSubscribeRetry(): void {
|
||||||
|
if (this._retryTimer !== undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._retryTimer = window.setTimeout(() => {
|
||||||
|
this._retryTimer = undefined;
|
||||||
|
this._subscribeLive();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _clearSubscribeRetry(): void {
|
||||||
|
if (this._retryTimer !== undefined) {
|
||||||
|
window.clearTimeout(this._retryTimer);
|
||||||
|
this._retryTimer = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _unsubscribeLive(): void {
|
private _unsubscribeLive(): void {
|
||||||
|
this._clearSubscribeRetry();
|
||||||
this._subGeneration++;
|
this._subGeneration++;
|
||||||
for (const unsub of this._unsubs) {
|
for (const unsub of this._unsubs) {
|
||||||
unsub();
|
unsub();
|
||||||
|
|||||||
@@ -1378,6 +1378,7 @@ export class NestQuestQuestLogCard extends LitElement {
|
|||||||
private _unsubs: Array<() => void> = [];
|
private _unsubs: Array<() => void> = [];
|
||||||
private _subscribed = false;
|
private _subscribed = false;
|
||||||
private _subGeneration = 0;
|
private _subGeneration = 0;
|
||||||
|
private _retryTimer?: number;
|
||||||
|
|
||||||
setConfig(config: QuestLogCardConfig): void {
|
setConfig(config: QuestLogCardConfig): void {
|
||||||
if (!config || typeof config !== "object") {
|
if (!config || typeof config !== "object") {
|
||||||
@@ -1421,7 +1422,7 @@ export class NestQuestQuestLogCard extends LitElement {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (token === this._subGeneration) {
|
if (token === this._subGeneration) {
|
||||||
this._unsubscribeLive();
|
this._unsubscribeLive();
|
||||||
this.requestUpdate();
|
this._armSubscribeRetry();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1432,7 +1433,25 @@ export class NestQuestQuestLogCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _armSubscribeRetry(): void {
|
||||||
|
if (this._retryTimer !== undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._retryTimer = window.setTimeout(() => {
|
||||||
|
this._retryTimer = undefined;
|
||||||
|
this._subscribeLive();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _clearSubscribeRetry(): void {
|
||||||
|
if (this._retryTimer !== undefined) {
|
||||||
|
window.clearTimeout(this._retryTimer);
|
||||||
|
this._retryTimer = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _unsubscribeLive(): void {
|
private _unsubscribeLive(): void {
|
||||||
|
this._clearSubscribeRetry();
|
||||||
this._subGeneration++;
|
this._subGeneration++;
|
||||||
for (const unsub of this._unsubs) {
|
for (const unsub of this._unsubs) {
|
||||||
unsub();
|
unsub();
|
||||||
|
|||||||
Reference in New Issue
Block a user