fix: user group pagination reset and model image caching (#19959)

- Changed default sort order in 'Edit Group' modal to 'created_at' (newest first).
  Previously it sorted by group membership, causing toggled users to invisible jump
  to the top of the list (often changing pages). using a stable sort fixes this UX issue.
- Removed unnecessary `page = 1` reset in toggleMember function so admins
  don't lose their place when selecting multiple users.

Bug 2 - Model Image Display Bug:
- Added `Cache-Control: no-cache, must-revalidate` headers to the model profile
  image endpoint. This ensures that when a model avatar is updated, the browser
  fetches the new image instead of serving a stale cached version (favicon).

Fixes #19885
This commit is contained in:
G30 2025-12-21 05:04:45 -05:00 committed by GitHub
parent 8eddff83cb
commit 0eeda79048
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View file

@ -291,12 +291,15 @@ async def get_model_by_id(id: str, user=Depends(get_verified_user)):
@router.get("/model/profile/image")
async def get_model_profile_image(id: str, user=Depends(get_verified_user)):
model = Models.get_model_by_id(id)
# Cache-control headers to prevent stale cached images
cache_headers = {"Cache-Control": "no-cache, must-revalidate"}
if model:
if model.meta.profile_image_url:
if model.meta.profile_image_url.startswith("http"):
return Response(
status_code=status.HTTP_302_FOUND,
headers={"Location": model.meta.profile_image_url},
headers={"Location": model.meta.profile_image_url, **cache_headers},
)
elif model.meta.profile_image_url.startswith("data:image"):
try:
@ -307,14 +310,17 @@ async def get_model_profile_image(id: str, user=Depends(get_verified_user)):
return StreamingResponse(
image_buffer,
media_type="image/png",
headers={"Content-Disposition": "inline; filename=image.png"},
headers={
"Content-Disposition": "inline; filename=image.png",
**cache_headers,
},
)
except Exception as e:
pass
return FileResponse(f"{STATIC_DIR}/favicon.png")
return FileResponse(f"{STATIC_DIR}/favicon.png", headers=cache_headers)
else:
return FileResponse(f"{STATIC_DIR}/favicon.png")
return FileResponse(f"{STATIC_DIR}/favicon.png", headers=cache_headers)
############################

View file

@ -30,7 +30,7 @@
let total = null;
let query = '';
let orderBy = `group_id:${groupId}`; // default sort key
let orderBy = 'created_at'; // default sort key
let direction = 'desc'; // default sort order
let page = 1;
@ -42,6 +42,7 @@
orderBy = key;
direction = 'asc';
}
page = 1;
};
const getUserList = async () => {
@ -75,7 +76,6 @@
});
}
page = 1;
getUserList();
};