Only suggest existing tag once

This commit is contained in:
Martin Giger 2021-04-24 17:07:24 +00:00 committed by Georg Krause
parent da6e7893ac
commit c73cec641a
No known key found for this signature in database
GPG Key ID: FD479B9A4D48E632
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1 @@
Only suggest typed tag once if it already exists

View File

@ -52,7 +52,16 @@ export default {
...response,
}
if (currentSearch) {
response.results = [{name: currentSearch}, ...response.results]
let existingTag = response.results.find((result) => result.name === currentSearch)
if (existingTag) {
if (response.results.indexOf(existingTag) !== 0) {
response.results = [existingTag, ...response.results]
response.results.splice(response.results.indexOf(existingTag) + 1, 1)
}
}
else {
response.results = [{name: currentSearch}, ...response.results]
}
}
return response
}