Fix variable scope error in Dashboard.tsx
This commit is contained in:
parent
60affa9a77
commit
1556cf69c6
@ -150,6 +150,8 @@ export function Dashboard({ user }: DashboardProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let latestPrefs = preferences;
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
const today = getTodayString();
|
const today = getTodayString();
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
@ -161,12 +163,12 @@ export function Dashboard({ user }: DashboardProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Update preferences with last usage time
|
// Update preferences with last usage time
|
||||||
const updatedPrefs = {
|
latestPrefs = {
|
||||||
...preferences,
|
...preferences,
|
||||||
[substance === 'nicotine' ? 'lastNicotineUsageTime' : 'lastWeedUsageTime']: now,
|
[substance === 'nicotine' ? 'lastNicotineUsageTime' : 'lastWeedUsageTime']: now,
|
||||||
};
|
};
|
||||||
await savePreferencesAsync(updatedPrefs);
|
await savePreferencesAsync(latestPrefs);
|
||||||
setPreferences(updatedPrefs);
|
setPreferences(latestPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
setShowUsagePrompt(false);
|
setShowUsagePrompt(false);
|
||||||
@ -176,7 +178,7 @@ export function Dashboard({ user }: DashboardProps) {
|
|||||||
setRefreshKey(prev => prev + 1);
|
setRefreshKey(prev => prev + 1);
|
||||||
|
|
||||||
// Check for new achievements immediately
|
// Check for new achievements immediately
|
||||||
await checkAndUnlockAchievements(usage, updatedPrefs, achievements);
|
await checkAndUnlockAchievements(usage, latestPrefs, achievements);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGeneratePlan = async () => {
|
const handleGeneratePlan = async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user