Skip to content

Tag filter#1879

Open
Dima-1 wants to merge 5 commits into
mainfrom
filter-tags
Open

Tag filter#1879
Dima-1 wants to merge 5 commits into
mainfrom
filter-tags

Conversation

@Dima-1

@Dima-1 Dima-1 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@Dima-1
Dima-1 marked this pull request as ready for review July 20, 2026 07:41

@alisa911 alisa911 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal was "one filtering logic". In practice only the predicates (shouldDisplayKey, isKeyToSkip, getPoiAdditionalType) were moved into the shared AdditionalInfoBundle, while the loop that assembles "which tags to show" was duplicated: one copy in SearchService.checkTagsVisibility, a second in Android's AmenityUIHelper.buildInternal, and a third (partial) one in the web fallback fixTagsKeysFallback plus the extra work in groupLocalizedTags. Three sources of truth instead of one.

Move the whole logic into a method in AdditionalInfoBundle. The web should receive a ready to display list of tags, and there should be no groupLocalizedTags or other such logic on the web. The web should only build the UI, which icon, a list or a tag, and so on.

AMENITY_PREFIX + SUBTYPE,
];

const HIDDEN_EXTENSIONS_POI = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename HIDDEN_EXTENSIONS_POI to web tags, and HIDDEN_EXTENSIONS should not exist, it duplicates the server logic

tagObj = addWikidataTags(key, value, tagObj);
}
res.push(tagObj);
const poiNameTags = {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear name remainingTags remaining after what, filterTagsByVisibility does not filter, the fallback with duplication is not needed, pick one thing either mainTag or mainEntry, const SVG is a magic constant

const arr = tag.key.split(':');
tag.key = arr[0];
tag.lang = arr[1];
async function buildTagObj(key, value, lang, ctx, subtypeTag) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildTagObj has a large number of arguments, use {}

tagObj.needLinks = false;
tagObj.textPrefix = value;
break;
case OPENING_HOURS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you touched the switch in buildTagObj, then rewrite it properly

}
}

res = res.filter((t) => !t.key.startsWith(WEB_PREFIX));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the WEB_PREFIX filter?

}

function fixTagsKeys(tags) {
async function filterTagsByVisibility(tags) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server returns an untyped map where a value is either a string or a nested localizations object. With no schema, the client has to rebuild what the server already computed: groupLocalizedTags re-splits the keys, re-picks the main language and rebuilds otherLangs. That double interpretation is where the bugs came from, and if the server changes the shape the web breaks silently.

Fix: return a typed, render ready list like { key, value, lang, otherLangs } already grouped, so the client only renders it.

@alisa911

Copy link
Copy Markdown
Contributor

This violates map/CLAUDE.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses tag rendering in the OsmAnd Web map “WPT/Favorites” info block by introducing a server-backed visibility filter for tags (related to osmandapp/OsmAnd#24809), and refactoring tag-building to better handle localized variants and POI name tags.

Changes:

  • Add a /search/get-tags-visibility POST call to filter/normalize tag visibility before rendering.
  • Refactor tag construction into helpers (buildTagObj, grouping localized tags, handling POI name + other languages).
  • Add client-side filtering of certain web-only/internal keys before visibility processing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +501 to +506
if (
key.startsWith(ALT_NAME) ||
HIDDEN_EXTENSIONS_POI.includes(key) ||
key.startsWith(ORIGINAL_ICON) ||
key === SVG
) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants