0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

🐛 Fixed user list behaviour after deletion (#18738)

refs https://github.com/TryGhost/Product/issues/3831

The wrong logic was used to fetch the next page, making the remaining
users show twice after deleting. Also fixed the route not updating after
deletion.

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 82a41fc</samp>

Refactor and improve `UserDetailModal` component with React Query,
TypeScript, and UX enhancements. Fix data bug and add navigation
feature.
This commit is contained in:
Jono M 2023-10-30 09:43:37 +00:00 committed by GitHub
parent 2c72c93331
commit 80392500bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -162,6 +162,7 @@ const UserDetailModalContent: React.FC<{user: User}> = ({user}) => {
await deleteUser(_user?.id);
modal?.remove();
mainModal?.remove();
navigateOnClose();
showToast({
message: 'User deleted',
type: 'success'
@ -505,7 +506,7 @@ const UserDetailModal: React.FC<RoutingModalProps> = ({params}) => {
const user = currentUser.slug === params?.slug ? currentUser : users.find(({slug}) => slug === params?.slug);
useEffect(() => {
if (!user && !hasNextPage) {
if (!user && hasNextPage) {
fetchNextPage();
}
}, [fetchNextPage, hasNextPage, user]);