-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[HOLD for payment 2023-11-02] [$500] Workspace - Archived Chat shows the edit composer for the message #26887
Comments
ProposalPlease re-state the problem that we are trying to solve in this issue.If the room is archived, the edit composer should be hidden What is the root cause of that problem?We are displaying the That's why when the workspace is deleted, the room is also archived. But because there is still What changes do you think we should make in order to solve the problem?We should delete useEffect(() => {
if (!props.draftMessage || !ReportUtils.isArchivedRoom(props.report)) {
return;
}
const originalReportID = ReportUtils.getOriginalReportID(props.report.reportID, props.action)
Report.saveReportActionDraft(originalReportID, props.action.reportActionID, '');
}, [props.report]) What alternative solutions did you explore? (Optional)N/A |
Triggered auto assignment to @sakluger ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Workspace - Archived Chat shows the edit composer for the message What is the root cause of that problem?We don't delete the draft message when the workspace is deleted, so it still displays with the condition here App/src/pages/home/report/ReportActionItem.js Line 344 in d60c13e
What changes do you think we should make in order to solve the problem?In
What alternative solutions did you explore? (Optional)NA ResultScreencast.from.07-09-2023.11.12.08.webm |
ProposalPlease re-state the problem that we are trying to solve in this issue.Message stays in edit mode even after the policy/workspace chat is deleted. What is the root cause of that problem?The message enters the edit mode if it has a draft message. App/src/pages/home/report/ReportActionItem.js Lines 344 to 388 in 46e6e20
When we delete a workspace/policy, we never delete their draft message which is why it stays in the edit mode. What changes do you think we should make in order to solve the problem?Currently, there is no easy way to delete draft message from a report because the onyx key of report action draft is designed like this: If we want to clear all draft from a report, we would need to iterate over all existing report action draft and set the value to null one by one. To make everything easier, I would like to propose to change the onyx key of report actions drafts to be: reportActionsDrafts_{reportID}: {
[reportActionID]: value,
} This has the same structure as report actions onyx which will allow us to clear all the draft easily as below: (add below code to Policy.deleteWorkspace optimisticData) ..._.map(reports, ({reportID}) => ({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${reportID}`,
value: null,
})), As we change the onyx structure, we need to adjust some code access the new key correctly: viewApp/src/libs/actions/Report.js Lines 1194 to 1196 in 46e6e20
to: Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${reportID}`, {[reportActionID]: draftMessage}); App/src/pages/home/report/ReportActionItem.js Lines 628 to 634 in 46e6e20
to: const draftKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${props.report.reportID}`;
return lodashGet(drafts, [draftKey, props.action.reportActionID], ''); App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 246 to 256 in 46e6e20
to:
Last, there are 2 things to do:
migration codeimport _ from 'underscore';
import Onyx from 'react-native-onyx';
import Log from '../Log';
import ONYXKEYS from '../../ONYXKEYS';
/**
* This migration updates reportActionsDrafts data to be keyed by reportActionID.
*
* Before: reportActionsDrafts_reportID_reportActionID: value
* After: reportActionsDrafts_reportID: {[reportActionID]: value}
*
* @returns {Promise}
*/
export default function () {
return new Promise((resolve) => {
const connectionID = Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS,
waitForCollectionCallback: true,
callback: (allReportActionsDrafts) => {
Onyx.disconnect(connectionID);
if (!allReportActionsDrafts) {
Log.info('[Migrate Onyx] Skipped migration KeyReportActionsDraftByReportActionID because there were no reportActionsDrafts');
return resolve();
}
const newReportActionsDrafts = {};
_.each(allReportActionsDrafts, (reportActionDraft, onyxKey) => {
if (_.isString(reportActionDraft)) {
newReportActionsDrafts[onyxKey] = null;
const reportActionID = onyxKey.split('_').pop();
const newOnyxKey = onyxKey.replace(`_${reportActionID}`, '');
newReportActionsDrafts[newOnyxKey] = {
...(newReportActionsDrafts[newOnyxKey] || allReportActionsDrafts[newOnyxKey]),
[reportActionID]: reportActionDraft,
};
}
});
if (_.isEmpty(newReportActionsDrafts)) {
Log.info('[Migrate Onyx] Skipped migration KeyReportActionsDraftByReportActionID because there are no actions drafts to migrate');
return resolve();
}
Log.info(`[Migrate Onyx] Re-keying reportActionsDrafts by reportActionID for ${_.keys(newReportActionsDrafts).length} actions drafts`);
// eslint-disable-next-line rulesdir/prefer-actions-set-data
return Onyx.multiSet(newReportActionsDrafts).then(resolve);
},
});
});
} |
Good find! |
Job added to Upwork: https://www.upwork.com/jobs/~0144ce6446180ed0fc |
Current assignee @sakluger is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif ( |
@aimane-chnaif could you please review the proposals we've received so far? |
@bernhardoj thanks for the research. Draft is local Onyx data. How will you clear draft message when delete workspace from another device? Especially if user closed app at the moment when delete workspace so user won't receive pusher event. |
@aimane-chnaif oh, I didn't think of that case, but I found in Policy.js that we actually tried to delete the draft when deleting the workspace from another device, but it doesn't work because of how the draft onyx is structured. If we do the draft onyx migration, it should work without any further changes needed. The changes come from this PR. It successfully set the App/src/libs/actions/Policy.js Lines 18 to 40 in c36ac0c
note: we have an onyx issue where setting null doesn't really clear the data, refreshing the app will show the data again, so I think we should wait for it to be resolved. |
@sakluger, @aimane-chnaif Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Onyx PR was merged. I think we can wait a bit more until package version is bumped in app which will likely happen soon. |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@sakluger @aimane-chnaif 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! |
Current assignee @aimane-chnaif is eligible for the Internal assigner, not assigning anyone new. |
Current assignee @aimane-chnaif is eligible for the External assigner, not assigning anyone new. |
📣 @aimane-chnaif 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
📣 @jayeshmangwani 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app! |
Thanks for the confirmation.
I just checked the latest code and that code is not present anymore, so nothing to change here. PR is ready cc: @aimane-chnaif |
Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:
On to the next one 🚀 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.91-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2023-11-02. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
I've completed payment to @jayeshmangwani and @bernhardoj. @aimane-chnaif could you please complete the BZ checklist? Once you do I can finish payments and close the issue. |
No regression. This bug existed from the beginning. Regression Test Proposal
|
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!
Action Performed:
Expected Result:
If Chat is archived, the edit composer should be hidden because the Edit message for archived Chat is prevented from BE
Actual Result:
Chat is archived, but the edit composer shows the message.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: v1.3.64-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Archived-Workspace-Edit-Composer.mp4
Recording.1466.mp4
Expensify/Expensify Issue URL:
Issue reported by: @jayeshmangwani
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693300421650139
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: