Skip to content

feat: #228 Implement request queue for offline requests with priority#529

Open
levibliz wants to merge 1 commit into
rinafcode:mainfrom
levibliz:feat/228-request-queue-priority-offline
Open

feat: #228 Implement request queue for offline requests with priority#529
levibliz wants to merge 1 commit into
rinafcode:mainfrom
levibliz:feat/228-request-queue-priority-offline

Conversation

@levibliz
Copy link
Copy Markdown

Description

Enhance request queue to persist offline requests, support priority levels, and batch similar requests during sync.

Changes

Core: src/services/api/requestQueue.ts

  • Added RequestPriority type: critical | high | normal | low
  • Added priority field to QueuedRequest interface
  • Queue is sorted by priority then FIFO
  • Batches similar requests during sync (PUT/PATCH coalesce payloads, GET runs in parallel)
  • Added network state listener for immediate processing on reconnect
  • Added resume() to restore pending requests from AsyncStorage on app restart
  • Tracks queue analytics via mobileAnalyticsService.trackEvent()
  • Added getQueueStatus() and getPendingByPriority() methods

Hook: src/hooks/usePendingRequests.ts

  • Updated to accept optional priority filter
  • Returns pendingCount and byPriority breakdown when filter is specified

Fix: App.tsx

  • Fixed incorrect import path for requestQueue (./src/services/requestQueue -> ./src/services/api/requestQueue)

Docs: docs/queue-priority-strategy.md

  • Documents priority levels, persistence strategy, batch processing, and analytics

Tests: tests/services/api/requestQueue.test.ts

  • Comprehensive test suite covering all new functionality

Acceptance Criteria

  • Persist requests to AsyncStorage with priority
  • Implement priority levels: critical, high, normal, low
  • Batch similar requests during sync
  • Resume queue on app restart
  • Test offline scenarios with network simulation
  • Monitor queue status in analytics
  • Document queue priority strategy

Closes #228

…tch sync (rinafcode#228)

- Add RequestPriority type: critical, high, normal, low
- Persist queue and metrics to AsyncStorage
- Implement priority-sorted processing within processQueue
- Batch similar requests (PUT/PATCH -> merge payload, GET -> parallel)
- Add network state listener for immediate processing on reconnect
- Add resume() to restore pending requests on app restart
- Track queue analytics (request_queued, request_dequeued, queue_batch_synced, queue_resumed)
- Add getQueueStatus() for monitoring queue health
- Add getPendingByPriority() for per-priority counts
- Update usePendingRequests hook with optional priority filter
- Fix App.tsx import path for requestQueue
- Add comprehensive test suite
- Document queue priority strategy in docs/
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@levibliz Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER
Copy link
Copy Markdown
Contributor

Kindly resolve conflict and fix workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement request queue for offline requests with priority

3 participants