Add IP Zip Code management in ShikshalokamChat and ShikshalokamVoiceChat Components - #205
Conversation
WalkthroughRefactors the Shikshalokam voice-chat component's internal state and effects, adds ipZipCode to user storage, and wires ZIP code into location initialization; WebSocket auth payload now includes a location-derived address and guards execution when location data is missing. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)
190-204: Guard condition may silently prevent WebSocket authentication.The early return at line 191 will prevent WebSocket authentication if any of
ipCity,ipState, oripZipCodeis missing. If the IP location service fails or returns partial data, the user may be stuck without any feedback.Consider either:
- Providing fallback values (e.g., empty strings or "Unknown")
- Logging a warning when location data is incomplete
- Making the address field optional in the authentication payload
const onWebSocketOpen = useCallback(() => { - if (!ipCity || !ipState || !ipZipCode) return + const address = [ipCity, ipState, ipZipCode].filter(Boolean).join(", ") || "" sendSocketMessage({ type: "authenticate", sessionid: sessionId, profileid: profileToUse, projectid: projectIdStore || searchParams.get("projectId") || "", taskid: searchParams.get("taskId") || taskId, access_token: accessToken, route: chatLanguage, bot_route: getSessionRoute(), flow_name: storageFlow, - address: `${ipCity}, ${ipState}, ${ipZipCode}`, + address, }) }, [sessionId, profileToUse, projectIdStore, searchParams, taskId, accessToken, chatLanguage, storageFlow, ipCity, ipState, ipZipCode])
🧹 Nitpick comments (1)
src/pages/shikshalokamChat.js (1)
33-33: Minor pattern inconsistency with other IP setters.
setIpZipCodeusesuseUserStorage().getState()whilesetIpCity,setIpState, andsetIpCountry(lines 30-32) use the selector patternuseUserStorage()(state => state.setX). This works correctly but creates inconsistency. Consider aligning with one pattern for maintainability.- const { setIpZipCode } = useUserStorage().getState() + const setIpZipCode = useUserStorage()(state => state.setIpZipCode)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/pages/ShikshalokamVoiceChat/voice-chat.js(8 hunks)src/pages/shikshalokamChat.js(2 hunks)src/store/slices/userData/state.js(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/store/slices/userData/state.js (1)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)
ipZipCode(173-173)
src/pages/shikshalokamChat.js (4)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)
useUserStorage(179-179)src/hooks/useStorage.js (2)
useUserStorage(24-26)useUserStorage(24-26)src/pages/UnifiedChat/UnifiedChat.jsx (1)
useUserStorage(18-18)src/pages/UnifiedChat/UnifiedVoiceBasedChat.jsx (1)
useUserStorage(98-98)
src/pages/ShikshalokamVoiceChat/voice-chat.js (6)
src/pages/shikshalokamChat.js (5)
useUserStorage(18-18)useUserStorage(33-33)ipCity(22-22)ipState(24-24)accessToken(41-41)src/pages/ssoFlow.jsx (1)
useSiteDataLocalStore(25-25)src/api/endpoints/auth.js (1)
accessToken(18-18)src/i18n.js (4)
languageToUse(13-13)languageToUse(31-31)setLanguage(29-34)setLanguage(29-34)src/pages/ShikshalokamVoiceChat/enum.js (4)
sessionFlowName(32-43)sessionFlowName(32-43)LANGUAGE_ENUMS(12-17)LANGUAGE_ENUMS(12-17)src/services/storage_service.js (1)
clearFromStorage(109-122)
🔇 Additional comments (4)
src/store/slices/userData/state.js (1)
10-18: LGTM!The
ipZipCodestate property and its setter follow the established pattern used for other IP-related fields (ipCity,ipState,ipCountry). Clean and consistent implementation.src/pages/shikshalokamChat.js (1)
134-139: LGTM!The ZIP code is properly extracted from
locationData.location.zipand set alongside other location fields, following the existing pattern.src/pages/ShikshalokamVoiceChat/voice-chat.js (2)
171-173: LGTM!The IP location state selectors are consistently implemented using the same pattern.
1227-1250: LGTM!The ParentPerceptionSurvey completion flow is well-structured with proper cleanup (storage clearing, language reset, audio stop) before navigation. The guard conditions ensure the popup only shows when appropriate.
|
@coderabbitai generate docstrings |
✅ Actions performedInitiated docstring generation; will generate only if new commits exist. |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @VishnuKrishnathu. * #205 (comment) The following files were modified: * `src/pages/shikshalokamChat.js`
…roved state handling
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/pages/shikshalokamChat.js (1)
133-139: Zip extraction is safe; consider normalizing missing values (optional)Using
setIpZipCode(locationData?.location?.zip)under the existinglocationData && locationData?.locationguard is safe and aligns with how city/state/country are set. If consumers ofipZipCodeassume a string (similar to howother_paramssends""for missing city/state/country), you might optionally normalize to an empty string:- setIpZipCode(locationData?.location?.zip) + setIpZipCode(locationData?.location?.zip ?? "")Not required for correctness, but it can simplify downstream handling.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/pages/shikshalokamChat.js(2 hunks)
🔇 Additional comments (1)
src/pages/shikshalokamChat.js (1)
29-37:setIpZipCodeselector wiring looks consistentThe new
setIpZipCodeselector mirrors how other IP-related setters (setIpCity,setIpState,setIpCountry) are accessed fromuseUserStorage, so the wiring here looks consistent with the existing pattern in this component.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
…hat components
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.