Skip to content

Commit

Permalink
Update main.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Turtlepaw authored Oct 3, 2024
1 parent 297a43a commit 4bfe7a1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,19 @@ void callbackDispatcher() {

// -1 = ended
if (challenge.getBoolValue("ended") &&
storedRankingState != null &&
storedRankingState != -1) {
await flutterLocalNotificationsPlugin.show(
challenge.id.hashCode,
"Challenge complete! ✨",
"See how you finished ${challenge.getStringValue("name")}",
notificationDetails,
payload: challenge.id);
currentPosition = -1;
} else if (isTop &&
storedRankingState != null &&
storedRankingState != -1) {
await flutterLocalNotificationsPlugin.show(
challenge.id.hashCode,
"Challenge complete! ✨",
"See how you finished ${challenge.getStringValue("name")}",
notificationDetails,
payload: challenge.id);

// Set to -1 to mark the user as notified about the challenge end
currentPosition = -1;
prefs.setInt(challenge.id, currentPosition); // Update right after notification
} else if (isTop &&
(storedRankingState == null || storedRankingState > 1)) {
// User reached the top
await flutterLocalNotificationsPlugin.show(
Expand Down

0 comments on commit 4bfe7a1

Please sign in to comment.