Skip to content

Commit

Permalink
WIP on fixing the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
julien4215 committed May 5, 2024
1 parent db5f56d commit 880ba7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/src/model/puzzle/puzzle_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ Future<PuzzleContext?> nextPuzzle(

@riverpod
Future<PuzzleStreakResponse> streak(StreakRef ref) {
return ref.withClient((client) => PuzzleRepository(client).streak());
return Future.delayed(const Duration(seconds: 3), () {
return ref.withClient((client) => PuzzleRepository(client).streak());
});
}

@riverpod
Future<PuzzleStormResponse> storm(StormRef ref) {
return ref.withClient((client) => PuzzleRepository(client).storm());
return Future.delayed(const Duration(seconds: 3), () {
return ref.withClient((client) => PuzzleRepository(client).storm());
});
}

/// Fetches a puzzle from the local storage if available, otherwise fetches it from the server.
Expand Down
1 change: 1 addition & 0 deletions lib/src/model/puzzle/puzzle_streak.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PuzzleStreak with _$PuzzleStreak {
required int index,
required bool hasSkipped,
required bool finished,
required DateTime timestamp,
}) = _PuzzleStreak;

PuzzleId? get nextId => streak.getOrNull(index + 1);
Expand Down
5 changes: 1 addition & 4 deletions lib/src/view/puzzle/streak_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class _Load extends ConsumerWidget {
index: 0,
hasSkipped: false,
finished: false,
timestamp: DateTime.now(),
),
);
},
Expand Down Expand Up @@ -365,10 +366,6 @@ class _BottomBar extends ConsumerWidget {
onTap: ref.read(streakProvider).isLoading == false
? () {
ref.invalidate(streakProvider);
// Since the API sends the same streak during an
// interval of time, the provider will receive the
// same arguments and so will not be recomputed
ref.invalidate(ctrlProvider);
}
: null,
highlighted: true,
Expand Down

0 comments on commit 880ba7f

Please sign in to comment.