fix: CollapseActive.vue: fixed 5-second delay in unstakePosition() should be replaced with polling (#448)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
becfb98198
commit
e85ff85950
1 changed files with 10 additions and 3 deletions
|
|
@ -93,7 +93,7 @@ import { useUnstake } from '@/composables/useUnstake';
|
|||
import { useAdjustTaxRate } from '@/composables/useAdjustTaxRates';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { getTaxDue, payTax } from '@/contracts/stake';
|
||||
import { type Position, loadPositions } from '@/composables/usePositions';
|
||||
import { type Position, loadPositions, loadActivePositions } from '@/composables/usePositions';
|
||||
import { useStatCollection } from '@/composables/useStatCollection';
|
||||
import { useWallet } from '@/composables/useWallet';
|
||||
import { DEFAULT_CHAIN_ID } from '@/config';
|
||||
|
|
@ -213,8 +213,15 @@ async function changeTax(id: bigint, nextTaxRateIndex: number | null) {
|
|||
async function unstakePosition() {
|
||||
await unstake.exitPosition(props.id);
|
||||
loading.value = true;
|
||||
// eslint-disable-next-line no-restricted-syntax -- Polling with timeout: no push event exists for Ponder indexing completion; Ponder GraphQL has no subscription endpoint. See AGENTS.md #Engineering Principles.
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
const POLL_INTERVAL_MS = 1000;
|
||||
const TIMEOUT_MS = 30_000;
|
||||
const deadline = Date.now() + TIMEOUT_MS;
|
||||
while (Date.now() < deadline) {
|
||||
const { positions } = await loadActivePositions(currentChainId.value);
|
||||
if (!positions.some(p => BigInt(p.id) === props.id)) break;
|
||||
// eslint-disable-next-line no-restricted-syntax -- Poll interval; Ponder has no push endpoint. See AGENTS.md #Engineering Principles.
|
||||
await new Promise<void>(resolve => setTimeout(resolve, POLL_INTERVAL_MS));
|
||||
}
|
||||
await loadPositions(currentChainId.value);
|
||||
loading.value = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue