Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remix PWA Push Fix #274

Merged
merged 4 commits into from
Oct 24, 2024
Merged

Remix PWA Push Fix #274

merged 4 commits into from
Oct 24, 2024

Conversation

ShafSpecs
Copy link
Member

Closes #271

This push aims to make sending notifications more streamlined, allowing you to send notifications whilst retaining errors. As well as a new utility function for filtering results:

for (const subscription of allSubscriptions) {
 const result = await sendNotifications({ ... })

 // returns an object of the following:
 type Result = {
    success: boolean;
    subscription: PushSubscription;
    statusCode: number;
    error?: undefined;
 } | {
    success: boolean;
    subscription: PushSubscription;
    error: string;
    statusCode?: undefined;
 })[]

 // using the new `getNotificationResults` util on `result`, we get an object of the following
  {
    successful: results.filter((r): r is NotificationResult & { success: true } => r.success),
    failed: results.filter((r): r is NotificationResult & { success: false } => !r.success),
    summary: {
      total: number,
      successCount: number,
      failureCount: number,
    },
  }
}

@ShafSpecs ShafSpecs added the bug Something isn't working label Oct 24, 2024
@ShafSpecs ShafSpecs linked an issue Oct 24, 2024 that may be closed by this pull request
@ShafSpecs ShafSpecs merged commit 0d39e14 into dev Oct 24, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push errors
1 participant