refactor(reader): one comic-likeness predicate — panel detection was a byte-identical twin
shouldEnablePanelDetection and ShouldTreatAsComic had identical truth tables (manga/comics library x fixed_layout/comic_archive) under different names — a drift trap: adding a library type to one silently missed the other. One predicate now gates both features, with the re-split instruction in its doc comment should the features ever legitimately diverge.
This commit is contained in:
1 parent
2ba1e0960b
commit
6b3bdef052
1 file changed
+9
-17
@@ -102,7 +102,9 @@ func (h *ReaderHandler) ShowReader(c *echo.Context) error {
|
||||
}
|
||||
|
||||
// Determine if panel detection should be enabled
|
||||
enablePanelDetection := shouldEnablePanelDetection(libraryWithType.TypeName, mediaItem.FormatGroup)
|
||||
// Same comic-likeness predicate as treatAsComic below — one function
|
||||
// on purpose (see ShouldTreatAsComic's doc).
|
||||
enablePanelDetection := ShouldTreatAsComic(libraryWithType.TypeName, mediaItem.FormatGroup)
|
||||
treatAsComic := ShouldTreatAsComic(libraryWithType.TypeName, mediaItem.FormatGroup)
|
||||
|
||||
// Get reading progress
|
||||
@@ -639,6 +641,12 @@ func (h *ReaderHandler) generatePDFThumbnail(fullPath string, page int, width, h
|
||||
// only — no text-selection highlights, no annotations, no in-book search.
|
||||
// Comic archives already behave this way; this flag extends it to fixed-
|
||||
// layout PDFs shelved in comic libraries (scanned or official manga PDFs).
|
||||
//
|
||||
// This is ALSO the panel-detection gate (reader.go's enablePanelDetection):
|
||||
// the two checks were once separate functions with byte-identical bodies —
|
||||
// a drift trap (adding a library type to one silently missed the other).
|
||||
// If comic treatment and panel detection ever need to diverge, re-split
|
||||
// them with a comment saying why.
|
||||
func ShouldTreatAsComic(libraryType string, formatGroup string) bool {
|
||||
comicLibraries := map[string]bool{
|
||||
"manga": true,
|
||||
@@ -652,19 +660,3 @@ func ShouldTreatAsComic(libraryType string, formatGroup string) bool {
|
||||
|
||||
return comicLibraries[libraryType] && fixedFormats[formatGroup]
|
||||
}
|
||||
|
||||
// shouldEnablePanelDetection determines if panel detection should be enabled
|
||||
// based on library type and format group
|
||||
func shouldEnablePanelDetection(libraryType string, formatGroup string) bool {
|
||||
panelLibraries := map[string]bool{
|
||||
"manga": true,
|
||||
"comics": true,
|
||||
}
|
||||
|
||||
panelFormats := map[string]bool{
|
||||
"fixed_layout": true,
|
||||
"comic_archive": true,
|
||||
}
|
||||
|
||||
return panelLibraries[libraryType] && panelFormats[formatGroup]
|
||||
}
|
||||
Reference in new issue
Block a user