Improve UnifiedPush reset UX: poll for endpoint and clearer status.

This commit is contained in:
2026-07-28 00:40:02 +10:00
parent 0de2fd942f
commit e460dbd34e
2 changed files with 65 additions and 19 deletions

View File

@@ -542,7 +542,18 @@ export const requestResetPushRegistration = async (): Promise<{ success: boolean
const MatrixBackgroundSync = registerPlugin<MatrixBackgroundSyncPlugin>('MatrixBackgroundSync');
const result = await MatrixBackgroundSync.requestDistributorSetup();
console.log('[BackgroundSync] requestDistributorSetup completed:', result);
return result ?? { success: false };
if (!result?.success) return { success: false };
// Endpoint arrives asynchronously from the distributor after register().
for (let i = 0; i < 20; i += 1) {
await new Promise((resolve) => setTimeout(resolve, 250));
const status = await getBackgroundSyncStatus();
if (status?.registered && status.endpoint) {
return { success: true };
}
}
return { success: true };
} catch (err) {
console.error('[BackgroundSync] requestDistributorSetup failed:', err);
return { success: false };