Fix the whole page refresh on switch change in Teams (#7556)

This commit is contained in:
Ashish Gupta 2022-09-20 15:29:18 +05:30 committed by GitHub
parent 67ae82286f
commit 5a242e2832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -328,7 +328,7 @@ const TeamDetailsV1 = ({
...currentTeam,
isJoinable: !currentTeam.isJoinable,
};
updateTeamHandler(updatedData);
updateTeamHandler(updatedData, false);
}
};
@ -572,7 +572,7 @@ const TeamDetailsV1 = ({
<Row className="tw-mb-1" justify="space-between">
<Col>
<p className="tw-font-medium" data-testid="open-group-label">
Open Group
{`${currentTeam.isJoinable ? 'Close' : 'Open'} Group`}
</p>
</Col>
<Col>

View File

@ -101,7 +101,7 @@ export interface TeamDetailsProp {
descriptionHandler: (value: boolean) => void;
onDescriptionUpdate: (value: string) => Promise<void>;
handleTeamUsersSearchAction: (text: string) => void;
updateTeamHandler: (data: Team) => Promise<void>;
updateTeamHandler: (data: Team, fetchTeam?: boolean) => Promise<void>;
handleCurrentUserPage: (value?: number) => void;
teamUserPaginHandler: (
cursorValue: string | number,

View File

@ -266,14 +266,18 @@ const TeamsPage = () => {
.finally(() => setIsDataLoading(false));
};
const updateTeamHandler = (updatedData: Team) => {
const updateTeamHandler = (updatedData: Team, fetchTeam = true) => {
const jsonPatch = compare(selectedTeam, updatedData);
return new Promise<void>((resolve, reject) => {
patchTeamDetail(selectedTeam.id, jsonPatch)
.then((res) => {
if (res) {
fetchTeamByFqn(selectedTeam.name);
if (fetchTeam) {
fetchTeamByFqn(selectedTeam.name);
} else {
setSelectedTeam((previous) => ({ ...previous, ...res }));
}
resolve();
} else {
throw jsonData['api-error-messages']['unexpected-server-response'];