mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
fix: Prevent race condition in unviewed validations count update
- Added a guard to ensure the unviewed count is only updated if the current project matches the reference, preventing potential race conditions during state updates.
This commit is contained in:
@@ -31,7 +31,10 @@ export function useUnviewedValidations(currentProject: Project | null) {
|
||||
const hoursSince = (Date.now() - new Date(v.validatedAt).getTime()) / (1000 * 60 * 60);
|
||||
return hoursSince <= 24;
|
||||
});
|
||||
setCount(unviewed.length);
|
||||
// Only update count if we're still on the same project (guard against race condition)
|
||||
if (projectPathRef.current === projectPath) {
|
||||
setCount(unviewed.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user