Skip to content

Commit

Permalink
Avoid suggesting discardable or _1 style tags in raw tag editor
Browse files Browse the repository at this point in the history
  • Loading branch information
bhousel committed Nov 14, 2023
1 parent ffb66d0 commit a993f04
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/ui/sections/raw_tag_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { utilGetSetValue, utilNoAuto, utilRebind } from '../../util';


export function uiSectionRawTagEditor(context, id) {
const dataloader = context.systems.dataloader;
const editor = context.systems.editor;
const l10n = context.systems.l10n;
const storage = context.systems.storage;
Expand All @@ -30,6 +31,10 @@ export function uiSectionRawTagEditor(context, id) {
.disclosureContent(renderDisclosureContent);


let _discardKeys = new Set();
dataloader.getDataAsync('discarded')
.then(data => _discardKeys = new Set(Object.keys(data)));

let _tagView = storage.getItem('raw-tag-editor-view') || 'list'; // 'list, 'text'
let _readOnlyTags = [];
let _orderedKeys = []; // the keys in the order we want them to display
Expand Down Expand Up @@ -407,7 +412,12 @@ export function uiSectionRawTagEditor(context, id) {
query: value
}, function(err, data) {
if (!err) {
const filtered = data.filter(d => _tags[d.value] === undefined);
const filtered = data.filter(d => {
if (/_\d$/.test(d.value)) return false; // tag like `_1`, see iD#9422
if (_discardKeys.has(d.value)) return false; // discardable, see iD#9817
if (_tags[d.value] !== undefined) return false; // already used as a tag
return true;
});
callback(sort(value, filtered));
}
});
Expand Down

0 comments on commit a993f04

Please sign in to comment.