-
Notifications
You must be signed in to change notification settings - Fork 1
fix: resolve architecture rule violations from AGENTS.md #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,8 +68,15 @@ export const RemindersPage: React.FC<RemindersPageProps> = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| const [now, setNow] = React.useState(() => Date.now()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| React.useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const timer = setInterval(() => setNow(Date.now()), 10000) // update every 10s for better responsiveness | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return () => clearInterval(timer) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| let timeoutId: ReturnType<typeof setTimeout> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const scheduleNext = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| timeoutId = setTimeout(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setNow(Date.now()) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| scheduleNext() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, 10000) // update every 10s for better responsiveness | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| scheduleNext() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return () => clearTimeout(timeoutId) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent post-unmount re-scheduling in the recursive timer. Line 73 can still schedule the next timeout after unmount if teardown happens while the callback is in flight, which leaves a dangling timer. Add a cancellation flag and nullable timeout guard in cleanup. Suggested patch React.useEffect(() => {
- let timeoutId: ReturnType<typeof setTimeout>
+ let timeoutId: ReturnType<typeof setTimeout> | null = null
+ let cancelled = false
const scheduleNext = () => {
+ if (cancelled) return
timeoutId = setTimeout(() => {
+ if (cancelled) return
setNow(Date.now())
scheduleNext()
}, 10000) // update every 10s for better responsiveness
}
scheduleNext()
- return () => clearTimeout(timeoutId)
+ return () => {
+ cancelled = true
+ if (timeoutId) clearTimeout(timeoutId)
+ }
}, [])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }, []) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsubscribe contract is implemented but not consumed by current renderer callers.
onTriggerNewNote/onTriggerTasksnow return disposers, butsrc/hooks/useGlobalHotkey.ts(Lines 124-138 in provided context) does not capture or invoke them inuseEffectcleanup, so listeners can still accumulate.Suggested caller-side fix (outside this file)
As per coding guidelines, trace context across related files to ensure cross-file contracts are actually enforced at usage sites.
🤖 Prompt for AI Agents