removed 'source' link from image results & fixed dynamic scrolling on image page

This commit is contained in:
partisan 2024-12-01 01:12:31 +01:00
parent ac7b468d71
commit 44e9d3356f
4 changed files with 18 additions and 21 deletions

View file

@ -273,6 +273,7 @@ func handleImageServe(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get(imageURL)
if err != nil {
printWarn("Error fetching image: %v", err)
recordInvalidImageID(imageID)
serveMissingImage(w, r)
return
}
@ -311,7 +312,18 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) {
continue
}
// Check for cached full or thumbnail images
// Check if the image ID is marked as invalid
invalidImageIDsMu.Lock()
_, isInvalid := invalidImageIDs[id]
invalidImageIDsMu.Unlock()
if isInvalid {
// Image is invalid; inform the frontend by setting the missing image URL
statusMap[id] = "/static/images/missing.svg"
continue
}
// Existing code to check for cached images
extensions := []string{"webp", "svg"} // Extensions without leading dots
imageReady := false
@ -341,15 +353,13 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) {
}
}
// If neither is ready
// If neither is ready and image is not invalid
if !imageReady {
if !config.DriveCacheEnabled {
// Hard cache is disabled; use the proxy URL
statusMap[id] = fmt.Sprintf("/image/%s_thumb", id)
} else {
// Hard cache is enabled; image is not yet cached
// Do not set statusMap[id]; the frontend will keep checking
}
// Else, do not set statusMap[id]; the frontend will keep checking
}
}