Skip to content

Performance Optimizations — 4 Tasks - #1064

Merged
RUKAYAT-CODER merged 5 commits into
rinafcode:mainfrom
m-hajjo:refactor/performance-optimizations
Aug 27, 2026
Merged

Performance Optimizations — 4 Tasks#1064
RUKAYAT-CODER merged 5 commits into
rinafcode:mainfrom
m-hajjo:refactor/performance-optimizations

Conversation

@m-hajjo

@m-hajjo m-hajjo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary
This PR addresses four performance and code quality issues across the TeachLink Mobile codebase: component re-render waste, duplicate sync conflict logic, unbounded request queuing, and undocumented analytics sampling.

Closes #996

Closes #997

Closes #998

Closes #999

m-hajjo and others added 4 commits August 27, 2026 08:16
…sections

Extract each visual section into its own React.memo component so a
toggle in one section only repaints that section, not the entire screen.
MobileSettings (619→91 lines) and SubscriptionManager (619→208 lines)
are now thin orchestrators over memoised sub-components. Each section
owns its own hooks and handlers. Accessibility labels added throughout.

New files:
- SettingRow.tsx, settingsIcons.tsx, settingsOptions.ts (shared primitives)
- AccountSection, AppSection, PrivacySection, DownloadsSection,
  SyncSection, PerformanceSection, AccountActionsSection
- subscription/: CurrentPlanCard, BillingToggle, PlanCard,
  FreePlanCard, RestoreFooter, subscriptionMeta

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
Three independent paths detected or resolved sync conflicts:
  1. syncService.ts — isConflictError, resolveConflicts, normalizeStrategy
  2. axios.config.ts — inline 409 ConflictData construction
  3. syncEntityManager — used by WebSocket path

Consolidated into:
  - sync/httpConflictDetection.ts — single HTTP conflict detection entry
    (isConflictError, buildConflictDataFromHttpError, extractConflictPayload)
  - syncService.ts — delegates to syncEntityManager, removed duplicate
    resolveConflicts/normalizeConflictStrategy/isConflictError
  - axios.config.ts — delegates to httpConflictDetection utility

Updated docs/conflict-resolution-strategy.md to document the unified
architecture and added end-to-end tests for the HTTP detection path.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
…ueue

The request queue had deduplication via fingerprint (rinafcode#813) but no size
bound — during extended offline periods a polling screen could enqueue
the same GET repeatedly, and on reconnection all of them would replay.

Changes:
- MAX_QUEUE_SIZE (100) with oldest-first eviction by priority
  (critical requests are never evicted)
- GET requests are collapsed: newer entry replaces older one so
  reconnection replays only the most recent read per endpoint
- Dropped request counter (getDroppedCount) for observability
- Eviction and dedup events logged for debugging
- Extended test coverage for dedup, GET collapsing, eviction, and
  duplicate write prevention on reconnection
- Updated docs/queue-priority-strategy.md

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
Analytics events fired on high-frequency paths had no documented
sampling policy — the hardcoded 10% rate was not aligned with event
importance, and there was no session-level volume bound.

Changes:
- New samplingPolicy.ts: per-event frequency classification (critical/
  high/medium/low), per-category sampling rates (100%/20%/10%/5%),
  documented high-frequency throttle rate, and session budget constant
- MobileAnalyticsService: replaced hardcoded 10% sampling with the
  policy-based system, added droppedCount for observability
- AnalyticsBatchQueue: enforce SESSION_EVENT_BUDGET (500 events/session),
  track and log budget exhaustion
- Updated docs/PERFORMANCE_MONITORING.md with full sampling policy docs

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@m-hajjo 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

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit c508b0f into rinafcode:main Aug 27, 2026
2 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment