Fix immediate achievement celebration and reliable notification delivery
This commit is contained in:
parent
431966a634
commit
60affa9a77
@ -174,6 +174,9 @@ export function Dashboard({ user }: DashboardProps) {
|
||||
const usage = await fetchUsageData();
|
||||
setUsageData(usage);
|
||||
setRefreshKey(prev => prev + 1);
|
||||
|
||||
// Check for new achievements immediately
|
||||
await checkAndUnlockAchievements(usage, updatedPrefs, achievements);
|
||||
};
|
||||
|
||||
const handleGeneratePlan = async () => {
|
||||
|
||||
@ -72,13 +72,12 @@ export function useNotifications(reminderSettings: ReminderSettings) {
|
||||
const reminderTime = new Date();
|
||||
reminderTime.setHours(hours, minutes, 0, 0);
|
||||
|
||||
// Check if it's time for the reminder (within 1 minute window)
|
||||
const timeDiff = Math.abs(now.getTime() - reminderTime.getTime());
|
||||
if (timeDiff <= 60000) {
|
||||
// If current time is past the reminder time, send it
|
||||
if (now >= reminderTime) {
|
||||
sendNotification('QuitTraq Reminder', {
|
||||
body: "Time to log your daily usage! Every day counts on your journey.",
|
||||
tag: 'daily-reminder',
|
||||
requireInteraction: false,
|
||||
tag: 'daily-reminder', // Tag ensures we don't stack multiple notifications
|
||||
requireInteraction: true, // Keep it visible until user interacts
|
||||
});
|
||||
localStorage.setItem(LAST_NOTIFICATION_KEY, today);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user