feat: user online only if not idle#176
Conversation
WalkthroughAdded a 30s idle timer via useIdle(30*1000) in two user store files and changed updateOnline to return early if the user id is missing or the idle flag is true (only send online update when id exists and user is NOT idle). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UserStore as UserStore
participant IdleHook as useIdle(30s)
participant OnlineSvc as Online Update API
User ->> UserStore: call updateOnline()
UserStore ->> IdleHook: read idle.value
alt id.value present AND idle.value == false
UserStore ->> OnlineSvc: POST /online
OnlineSvc -->> UserStore: 200 OK
else missing id OR idle.value == true
UserStore -->> User: return early (no request)
end
note over IdleHook: Idle state from 30s timer (true when idle)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/atrium-telegram/app/stores/user.ts(2 hunks)apps/web-app/app/stores/user.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (2)
apps/atrium-telegram/app/stores/user.ts (1)
23-24: Confirm VueUse auto-import for this app or add explicit import; optional aliasSearch shows '@vueuse/nuxt' only in packages/ui/nuxt.config.ts (not in apps/atrium-telegram), so auto-import may not be enabled for this app — add an explicit import in apps/atrium-telegram/app/stores/user.ts or enable '@vueuse/nuxt' for the app.
Suggested change:
+import { useIdle } from '@vueuse/core' - const { idle } = useIdle(30 * 1000) // 30 sec + const { idle: isIdle } = useIdle(30 * 1000) // 30sUse isIdle.value in guards.
apps/web-app/app/stores/user.ts (1)
27-28: EnsureuseIdleis resolvable; optionally alias toisIdle.
- I found '@vueuse/nuxt' in packages/ui/nuxt.config.ts only — confirm apps/web-app actually inherits/uses that module; if it doesn't, add an explicit import in apps/web-app/app/stores/user.ts (line ~27).
- Optional readability change: alias
idle→isIdleand keep the same guard semantics.Suggested diffs:
+import { useIdle } from '@vueuse/core' - const { idle } = useIdle(30 * 1000) // 30 sec + const { idle: isIdle } = useIdle(30 * 1000) // 30sIf aliasing, update the guard (preserve original logic):
- if (!id.value || !idle.value) { + if (!id.value || !isIdle.value) { return }
|



Summary by CodeRabbit
New Features
Bug Fixes