Add async-storage dependency and refactor ChatScreen refresh logic#163
Add async-storage dependency and refactor ChatScreen refresh logic#163Naren456 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds an async-storage dependency, tightens post-send refresh logic in the chat screen to require an explicit dataChanged flag, and updates RAG service success responses to include Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
Frontend/src/services/RAGService.js (2)
2090-2159: Inconsistent dataChanged flag: UPDATE and DELETE operations are missing it.While CREATE/LOG operations now correctly include
dataChanged: true, all UPDATE and DELETE operations lack this flag:UPDATE operations without the flag:
updateProfile(line 1979)updateAppointment(line 2146)updateMedicine,updateBloodPressure,updateDischarge,updateSymptoms,updateWeight,updateMood,updateSleepDELETE operations without the flag:
deleteAppointment(line 2219)deleteMedicine,deleteBloodPressure,deleteDischarge,deleteSymptoms,deleteWeight,deleteMood,deleteSleepSince these operations also mutate data, they should include
dataChanged: truein their success responses. Without it, the ChatScreen won't refresh the context after updates/deletes, potentially showing stale data.Example fix for updateAppointment
if (response.ok) { return { success: true, + dataChanged: true, message: `✅ Appointment "${updateData.title}" updated successfully!\n\n📅 Date: ${updateData.appointment_date}\n⏰ Time: ${updateData.appointment_time}\n📍 Location: ${updateData.appointment_location}` };Apply similar changes to all other UPDATE and DELETE operations.
Also applies to: 2164-2234, 3221-3250, 3255-3280, 3287-3315, 3320-3345, 3352-3379, 3384-3409, 3416-3443, 3448-3473, 3480-3507, 3512-3537, 3544-3571, 3576-3601, 3608-3637, 3642-3667
2614-2641: Missing dataChanged flag in logMood and logSleep operations.The
logMood(line 2628) andlogSleep(line 2667) operations create new data entries but their success responses don't includedataChanged: true. This means the ChatScreen won't refresh the context after logging mood or sleep data, potentially causing stale data display.Proposed fix
// In logMood function if (response.ok) { return { success: true, + dataChanged: true, message: `😊 Mood logged successfully!\n\n**Mood:** ${data.mood}\n**Intensity:** ${data.intensity || 'medium'}\n**Week:** ${userContext.current_week || 12}` }; // In logSleep function if (response.ok) { let message = `😴 Sleep logged successfully!\n\n**Duration:** ${data.duration} hours`; // ... message building ... return { success: true, + dataChanged: true, message: message };Also applies to: 2646-2680
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Frontend/src/Screens/ChatScreen.jsxFrontend/src/services/RAGService.js
🔇 Additional comments (3)
Frontend/src/Screens/ChatScreen.jsx (2)
151-155: LGTM! Smart optimization to reduce unnecessary backend calls.The addition of the
result.dataChangedcheck correctly prevents refreshing the context for read-only operations (like viewing logs, querying analytics, navigation, etc.), which avoids unnecessary backend load. The explanatory comments clearly document the intent.
1-23: Verify the PR scope: Title mentions adding async-storage, but changes remove AsyncStorage import.The PR title and description indicate this PR is meant to "add async-storage dependency for chat history," but the actual changes in this file:
- Remove the AsyncStorage import (per AI summary)
- Remove the ragService import (per AI summary)
- Add a
dataChangedflag check to optimize context refreshingThis appears to be a refactoring/optimization PR rather than adding new storage functionality. Please clarify:
- Is the async-storage dependency actually being added for future use?
- Should the PR title/description be updated to reflect the actual changes (optimizing refresh logic)?
- If storage functionality is intended, where is it implemented?
Frontend/src/services/RAGService.js (1)
1704-1707: LGTM! Consistent addition of dataChanged flag to all data-creation operations.The
dataChanged: trueflag has been correctly added to all CREATE/LOG operations (appointments, weight, symptoms, blood pressure, medicine, discharge, and tasks). This enables the ChatScreen to distinguish between operations that modify data (requiring a context refresh) and read-only operations (no refresh needed).Also applies to: 1738-1741, 1772-1775, 1808-1811, 1844-1847, 1880-1883, 1918-1921
Closes #
📝 Description:
This PR is related to dependency chnage and optimization in chatscreen .
It adds an important dependency required for the ChatScreen to store chat history using local storage.
*Dependency Name*: react native async storage.This PR is a extended PR of Redesign ChatScreen
I resolve all the conflict issue regarding dependency .
✅ Checklist
Summary by CodeRabbit
Chores
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.