-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$250] Web - Search - New messages are not updated automatically in chats section #52193
Comments
Triggered auto assignment to @CortneyOfstad ( |
@CortneyOfstad Huh... This is 4 days overdue. Who can take care of this? |
Was able to consistently recreate this between my cortney@realtownhomes.com and cortney@expensifail.com accounts. The only way I could get the messages to appear was a forced refresh or actively clicking out and back into the chats page. Going to get eyes on this! |
Job added to Upwork: https://www.upwork.com/jobs/~021856702046390987958 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav ( |
Edited by proposal-police: This proposal was edited at 2024-11-22 18:50:08 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Search - New messages are not updated automatically in chats section What is the root cause of that problem?New Feature What changes do you think we should make in order to solve the problem?We can update
and pass it to the hook here App/src/components/Search/index.tsx Lines 180 to 185 in 4bb19d7
POC: 2024-11-16.03-28-00.mp4What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issue.New messages are not updated automatically in chats section What is the root cause of that problem?This is a new feature of When User A sends a message to User B, User B will receive new data through the Pusher event. Line 29 in 4ffbd42
And User B listens to this event to receive new data from User A and stores it in Onyx.
In this new data included new message from User A sent we have update it to This new data includes a new message sent by User A, which we have updated in
As per this code, we only have a new value when the value key exists, and then we are able to pick it. To debug this, we can add the log following the path console.log('****** snapshotData[key] ******', snapshotData[key]);
console.log('****** value key ******', Object.keys(value)[0]);
if (snapshotData[key] && Object.keys(snapshotData[key]).length > 0) {
const firstValueKey = Object.keys(value)[0];
const snapshotKeys = Object.keys(snapshotData[key]);
if (!snapshotKeys.includes(firstValueKey)) {
console.log(`****** ${firstValueKey} key not exisitng in ${key} ******`, );
}
} So, because we can't add new data to snapshot_, the message will not be displayed when User A sends a new message. VIDEO: Debug this issue.What changes do you think we should make in order to solve the problem?To resolve this issue, we must update
// node_modules/react-native-onyx/dist/Onyx.js#L472
function addSnapshots(data) {
const snapshotCollectionKey = OnyxUtils_1.default.getSnapshotKey();
if (!snapshotCollectionKey)
return;
const promises = [];
const snapshotCollection = OnyxUtils_1.default.getCachedCollection(snapshotCollectionKey);
const snapshotCollectionKeyLength = snapshotCollectionKey.length;
Object.entries(snapshotCollection).forEach(([snapshotKey, snapshotValue]) => {
// Snapshots may not be present in cache. We don't know how to update them so we skip.
if (!snapshotValue) {
return;
}
let addedData = {};
data.forEach(({ key, value }) => {
// snapshots are normal keys so we want to skip update if they are written to Onyx
if (OnyxUtils_1.default.isCollectionMemberKey(snapshotCollectionKey, key, snapshotCollectionKeyLength)) {
return;
}
if (typeof snapshotValue !== 'object' || !('data' in snapshotValue)) {
return;
}
const snapshotData = snapshotValue.data;
if (!snapshotData || !snapshotData[key]) {
return;
}
let newValue = {};
// Check if snapshotData contains the key and has values
if (snapshotData[key] && Object.keys(snapshotData[key]).length > 0) {
const firstValueKey = Object.keys(value)[0];
const snapshotKeys = Object.keys(snapshotData[key]);
// Check if the first key in `value` doesn't exist in `snapshotData[key]`
if (!snapshotKeys.includes(firstValueKey)) {
const existingValue = Object.values(snapshotData[key])[0];
const newValues = Object.values(value)[0];
// Update `existingValue` with matching keys from `newValues`
Object.keys(newValues).forEach(subKey => {
if (subKey in existingValue) {
existingValue[subKey] = newValues[subKey];
}
});
newValue = existingValue;
}
}
addedData = {
...addedData,
[key]: newValue,
};
});
// Skip the update if there's no data to be merged
if (utils_1.default.isEmptyObject(addedData)) {
return;
}
promises.push(() => merge(snapshotKey, { data: addedData }));
});
return Promise.all(promises.map((p) => p()));
}
// node_modules/react-native-onyx/dist/Onyx.js#L675
return clearPromise
.then(() => Promise.all(promises.map((p) => p())))
+ .then(() => addSnapshots(data))
.then(() => updateSnapshots(data))
.then(() => undefined);
To test my proposal, you can download the file Onyx.js and replace the Onyx.js file in your node modules POCScreen.Recording.2024-11-16.at.14.55.36.mp4 |
This one's tricky. Reviewing the issue as well as proposals. Will post an update by Monday. |
Still reviewing. |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@mananjadhav @CortneyOfstad this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
@luacmartins What do you think about my proposal here? I have proposed to auto updating and highlighting new chat messages in search the same as we are doing for expenses. I have also uploaded the result. It would also be nice if you self-assign as you are the head of search 👍 Thx |
@mananjadhav, @CortneyOfstad Huh... This is 4 days overdue. Who can take care of this? |
#52826 Same RCA with this ticket |
@mananjadhav, @marcochavezf, @CortneyOfstad Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@marcochavezf @luacmartins quick bump on this. |
Thanks for the review @mananjadhav! Looks like we don't need to update onyx from the backend, but I think we can confirm in the PR. Assigning @FitseTLT 🚀 |
📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
@mananjadhav, @marcochavezf, @CortneyOfstad, @FitseTLT Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@FitseTLT do you have an ETA for your PR? Thanks! |
PR will be ready by Tomorrow 👍 |
Awesome — thanks @FitseTLT! |
@mananjadhav @marcochavezf @CortneyOfstad @FitseTLT this issue is now 4 weeks old, please consider:
Thanks! |
@mananjadhav, @marcochavezf, @CortneyOfstad, @FitseTLT Eep! 4 days overdue now. Issues have feelings too... |
@FitseTLT Can you please post an update on the PR? |
It's ready now |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
Hello! Just a heads up that I will be OOO starting this afternoon (December 20) and will be returning January 6th. A handful of folks on the BZ team will be online for a few days in between the 25th and the 1st, but we'll be operating with a skeleton crew. If any action is needed during that time, please post this issue in #expensify-open-source and someone on the team will jump in. Otherwise I will review when I am back on 1/6 — thanks! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.59-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5192577&group_by=cases:section_id&group_order=asc&group_id=296775
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
New messages should be updated in real time on chats section on main device, as it happens with new expenses or deleted messages
Actual Result:
New messages on chats section are not displayed until navigating out of the section and returning. Behaviour with deleted messages or new expenses is different, as they are displayed in real time
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6657705_1730991181627.Search_Chats.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @mananjadhavThe text was updated successfully, but these errors were encountered: