Skip to content
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

fix: deleted workspace room display in task share somewhere #41636

Merged
merged 6 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/components/OptionListContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,11 @@ function OptionsListContextProvider({reports, children}: OptionsListProviderProp
return;
}

const lastUpdatedReport = ReportUtils.getLastUpdatedReport();

if (!lastUpdatedReport) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the return early when no existing item need to update allow this useEffect to handle adding the new items which should handle in the next useEffect that lead to duplicated new items in the list, and it handled here #43094


const newOption = OptionsListUtils.createOptionFromReport(lastUpdatedReport, personalDetails);
const replaceIndex = options.reports.findIndex((option) => option.reportID === lastUpdatedReport.reportID);

if (replaceIndex === -1) {
return;
}
const newReports = OptionsListUtils.createOptionList({}, reports).reports;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating the whole optionList whenever any report changes looks inefficient. Can we just update the last three or five updated reports?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Deleting workspace is too buggy for me. I couldn't delete one. Even if so, the #admins and #accounce room are not archived.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry. I see that there can be many policy expense chats of other invited members as well. So just deleting 5 reports might not suffice because the other reports still appear in the results.

deleteFiveReports.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are passing empty object for the personal details? The personal details are used to get the correct icons. This is causing #42232. While testing I also found that the list becomes irresponsive and get into infinite loop (could be related to change here too?)


setOptions((prevOptions) => {
const newOptions = {...prevOptions};
newOptions.reports[replaceIndex] = newOption;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to note that the old code was mutating data here which is pretty bad in React.

newOptions.reports = newReports;
return newOptions;
});
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Loading