Skip to content

fix: refresh recent#1125

Merged
simon-the-shark merged 3 commits intomainfrom
refresh
Mar 29, 2026
Merged

fix: refresh recent#1125
simon-the-shark merged 3 commits intomainfrom
refresh

Conversation

@MarmoPL
Copy link
Copy Markdown
Member

@MarmoPL MarmoPL commented Mar 28, 2026

Although the bug couldn't be confirmed on my end, I've prepared a potential fix.
Pulling down to refresh on the current meals screen now also refreshes the recent dishes list. Additionally, the cache duration has been reduced from 1 day to 1 hour, bringing it in line with the current menu behavior.
Hopefully this addresses the issue.

@MarmoPL MarmoPL self-assigned this Mar 28, 2026
@MarmoPL MarmoPL linked an issue Mar 28, 2026 that may be closed by this pull request
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR fixes stale data in the "recent dishes" list by hooking its cache invalidation into the pull-to-refresh flow of the SKS menu screen, and reduces its TTL from 1 day (defaultSks) to 1 hour (defaultSksMenu) to match the current-menu cache behaviour.

  • TTL reduction (sks_favourite_dishes_repository.dart line 38): TtlDays.defaultSks (1 day) → TtlDays.defaultSksMenu (1 hour). Keeps the recent-dishes list in sync with the freshness policy of the live menu.
  • New clearCache() method (sks_favourite_dishes_repository.dart lines 63-68): Mirrors the existing pattern in SksMenuRepository; clears only the _recentEndpoint cache. The subscription endpoint (/subscriptions/{deviceKey}) already carries extraValidityCheck: (_) => false, so it is always re-fetched from the network and does not need explicit invalidation.
  • Coordinated refresh in _SksMenuView (sks_menu_screen.dart lines 88-96): Both cache clears are now awaited in parallel, and then all three providers—menu, live user data, and favourite dishes—are refreshed in a single Future.wait, preserving the correct clear-before-refresh ordering.

The implementation is consistent with existing patterns and introduces no new technical debt.

Confidence Score: 5/5

Safe to merge — changes are minimal, follow established codebase patterns, and introduce no new risk.

All changes are P2 or lower. The new clearCache() method mirrors the identical method already present in SksMenuRepository, the TTL reduction is intentional and consistent with the live-menu policy, and the coordinated refresh in the screen correctly follows the clear-before-refresh ordering already used for the menu provider. No logic bugs, security concerns, or data-integrity issues were found.

No files require special attention.

Important Files Changed

Filename Overview
lib/features/sks/sks_favourite_dishes/data/repository/sks_favourite_dishes_repository.dart Reduces TTL from 1 day to 1 hour (defaultSksMenu) and adds a clearCache() method following the same pattern as SksMenuRepository.
lib/features/sks/sks_menu/presentation/sks_menu_screen.dart Expands onRefresh to clear and re-fetch sksFavouriteDishesRepositoryProvider in parallel with the existing menu and user-data providers.

Sequence Diagram

sequenceDiagram
    participant U as User (pull-to-refresh)
    participant Screen as _SksMenuView
    participant MenuRepo as SksMenuRepository
    participant FavRepo as SksFavouriteDishesRepository
    participant Cache as CacheManager

    U->>Screen: onRefresh triggered
    par Clear caches in parallel
        Screen->>MenuRepo: clearCache()
        MenuRepo->>Cache: removeFile(/meals/current)
        MenuRepo->>Cache: removeFile(/info)
    and
        Screen->>FavRepo: clearCache()
        FavRepo->>Cache: removeFile(/meals/recent)
    end
    par Refresh providers in parallel
        Screen->>MenuRepo: ref.refresh(future)
        MenuRepo-->>Screen: ExtendedSksMenuResponse
    and
        Screen->>FavRepo: ref.refresh(future)
        FavRepo-->>Screen: SksFavouriteDishesMap
    and
        Screen->>Screen: ref.refresh(getLatestSksUserDataProvider.future)
    end
    Screen-->>U: UI updated
Loading

Reviews (3): Last reviewed commit: "chore: reorder imports" | Re-trigger Greptile

@simon-the-shark simon-the-shark merged commit a6ce396 into main Mar 29, 2026
8 checks passed
@simon-the-shark simon-the-shark deleted the refresh branch March 29, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sks-favs): current's day meals are missing from sks favs list

2 participants