SSW.Rewards.Mobile icon indicating copy to clipboard operation
SSW.Rewards.Mobile copied to clipboard

Fix offline support for Earn tab - prevent crashes and add caching

Open Copilot opened this issue 4 months ago • 1 comments

  1. What triggered this change? (PBI link, Email Subject, conversation + reason, etc)

Issue #1308 - Earn tab (Quiz page) crashed when offline and showed error dialogs on every "Next" button press during quiz submission.

  1. What was changed?

QuizViewModel - Implemented caching with offline support

  • Migrated from ObservableRangeCollection to AdvancedObservableCollection with IFileCacheService
  • Added OnQuizzesError() callback distinguishing HttpRequestException for network-specific messaging
  • Added connectivity check in OpenQuiz() before navigation
  • Added QuizItemViewModel.IsEqual() for efficient cache comparison

QuizDetailsViewModel - Added network checks at critical points

  • Connectivity check in Initialise() with navigation fallback
  • Silent skip in SubmitAnswer() when offline (prevents error spam on "Next")
  • Connectivity check in SubmitResponses() before final submission
  • Null checks for API responses

QuizPage.xaml - Updated binding

- ItemsSource="{Binding Quizzes}"
+ ItemsSource="{Binding Quizzes.Collection}"

QuizPage.xaml.cs - Added resource cleanup

  • OnDisappearing() to dispose timer

QuizService - Improved error propagation

  • Rethrow HttpRequestException to allow ViewModel-level handling

Pattern: Follows existing RedeemViewModel and ProfileViewModelBase offline patterns (cache-first loading, network-specific errors, silent failures with cached fallback).

  1. Did you do pair or mob programming?

No

Original prompt

This section details on the original issue you should resolve

<issue_title>🐛 Offline Support | Earn Tab [JK]</issue_title> <issue_description>Issues to fix on Mobile app:

  • [ ] Prevent crash when going on earn tab
  • [ ] Cache earn tab
  • [ ] Gracefully handle when attempting to start a quiz
  • [ ] Don't throw an error on each "Next" press in quiz when offline

Look at other pages how offline is supported.</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes SSWConsulting/SSW.Rewards.Mobile#1308

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot avatar Nov 10 '25 09:11 Copilot

@zacharykeeping, needs more testing but looks ok.

jernejk avatar Nov 14 '25 11:11 jernejk