mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-24 10:15:22 +00:00
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:
parent
8eddff83cb
commit
0eeda79048
2 changed files with 12 additions and 6 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
############################
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue