Closed fire-eggs closed 2 months ago
Hi @fire-eggs
thank you for using HomeGallery and your issue. It is a good catch.
How would you like to merge and display the tags of multiple cases? Which case should win?
Who about renaming the tags via the multi selection to one unified case?
Are you able to provide an PR for it? That would be awesome!
I'm afraid Typescript/Javascript are read-only languages for me right now, so I can't provide a PR.
Tags are displayed as case-sensitive, but search behaves as case-insensitive. I think the "easiest" solution would be to change the tag display to be case-insensitive. This has no impact on existing data, no change to the tag import logic, no change to the tag editing dialog, etc.
I think the required change would be to this chunk of code in packages/webapp/src/tags/Tags.tsx
:
const tags = useMemo(() => {
const tagsCount = {};
allEntries.forEach(({tags}) => {
if (tags) {
tags.forEach((tag) => {
if (tagsCount[tag]) {
tagsCount[tag] += 1;
} else {
tagsCount[tag] = 1;
}
})
}
});
changing to:
const tags = useMemo(() => {
const tagsCount = {};
allEntries.forEach(({tags}) => {
if (tags) {
tags.forEach((tag) => {
if (tagsCount[tag.toLowerCase()]) {
tagsCount[tag.toLowerCase()] += 1;
} else {
tagsCount[tag.toLowerCase()] = 1;
}
})
}
});
I believe what this change accomplishes, is that all tags are merged in a case-insensitive way for display purposes, without impacting the original data. I.e. my "Cat -1" and "cat -3" entries are replaced with a single entry "cat - 4".
You found the right spot and I think that would work. Good job!
So you propose to display all tags in lowercase? Would that be OK for you?
What if there are unique tags but with capital letters? Still show them in lower case?
Yes, my preference would be for all tags to be shown in lower case. Without specific counter-examples, I can't think of a situation where capital letters would be important.
Hi @fire-eggs
I've fixed the issue in the current master 569348b. However if there are multiple cases the most use case is shown. On parity the lower case is preferred. I think this algorithms fits best if someone works with capitalized tags.
Examples:
Please test it by pulling the latest docker image or downloading the binary home-gallery-master-20240913-569348ba-...
from unstable/master if the solution fits your needs.
Hey, @xemle this works really nice! I like the idea of taking the most common "case" [pun intended!] too.
@fire-eggs can we close this issue?
In my image set, some tags have a discrepancy in case (upper vs lower): [screen cap from home gallery tag list]
If I click on either one of those tags in home-gallery, all four images are shown.
For myself, I'd like the "cat" and "Cat" tags to be combined (ignore case).