-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Org settings partial updates improvements #20626
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
Changes from all commits
22aa790
674dc82
8b563ec
d9e1cf2
ced7da4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useMutation } from "@tanstack/react-query"; | ||
import { useOrgSettingsQueryInvalidator } from "./org-settings-query"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { getQueryKey, useOrgSettingsQueryInvalidator } from "./org-settings-query"; | ||
import { useCurrentOrg } from "./orgs-query"; | ||
import { organizationClient } from "../../service/public-api"; | ||
import { | ||
|
@@ -24,6 +24,8 @@ export const useUpdateOrgSettingsMutation = () => { | |
const invalidateOrgSettings = useOrgSettingsQueryInvalidator(); | ||
const invalidateWorkspaceClasses = useOrgWorkspaceClassesQueryInvalidator(); | ||
const invalidateOrgRepoSuggestions = useOrgRepoSuggestionsInvalidator(); | ||
|
||
const queryClient = useQueryClient(); | ||
const organizationId = org?.id ?? ""; | ||
|
||
return useMutation<OrganizationSettings, Error, UpdateOrganizationSettingsArgs>({ | ||
|
@@ -44,13 +46,18 @@ export const useUpdateOrgSettingsMutation = () => { | |
} | ||
} | ||
|
||
const settings = await organizationClient.updateOrganizationSettings(update); | ||
return settings.settings!; | ||
const { settings } = await organizationClient.updateOrganizationSettings(update); | ||
return settings!; | ||
}, | ||
onSuccess: () => { | ||
invalidateOrgSettings(); | ||
onSuccess: (settings) => { | ||
invalidateWorkspaceClasses(); | ||
invalidateOrgRepoSuggestions(); | ||
|
||
if (settings) { | ||
queryClient.setQueryData(getQueryKey(organizationId), settings); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this set's the query's data to not have to re-fetch data we have available to us. We do the same with updating Configurations |
||
} else { | ||
invalidateOrgSettings(); | ||
} | ||
}, | ||
onError: (err) => { | ||
if (!ErrorCode.isUserError((err as any)?.["code"])) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ export const OrgMemberAvatarInput = ({ settings, setFeaturedMemberId }: Props) = | |
const handleSelectionChange = useCallback( | ||
(selectedId: string) => { | ||
const member = members?.find((m) => m.userId === selectedId); | ||
setFeaturedMemberId(selectedId || undefined); | ||
setFeaturedMemberId(selectedId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was necessary to force the default value and not just make an empty update. |
||
setAvatarUrl(member?.avatarUrl); | ||
}, | ||
[members, setFeaturedMemberId], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧡