mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: uses new format for search tag endpoint to prevent issues (#15328)
Due to our usage of fixtures, backend changes didn't get catch.
This commit is contained in:
parent
2a4df93b8e
commit
81b0ac1766
|
@ -42,15 +42,10 @@ function searchTags(term, categories, limit) {
|
|||
const categoryNames = cats.map((c) => c.model.get("name"));
|
||||
|
||||
const tags = r.results.map((tag) => {
|
||||
const tagName = tag.text;
|
||||
|
||||
return {
|
||||
name: tagName,
|
||||
text: categoryNames.includes(tagName)
|
||||
? `${tagName}${TAG_HASHTAG_POSTFIX}`
|
||||
: tagName,
|
||||
count: tag.count,
|
||||
};
|
||||
tag.text = categoryNames.includes(tag.text)
|
||||
? `${tag.text}${TAG_HASHTAG_POSTFIX}`
|
||||
: tag.text;
|
||||
return tag;
|
||||
});
|
||||
|
||||
returnVal = cats.concat(tags);
|
||||
|
|
|
@ -379,9 +379,9 @@ acceptance("Tag info", function (needs) {
|
|||
server.get("/tags/filter/search", () =>
|
||||
helper.response({
|
||||
results: [
|
||||
{ id: "monkey", text: "monkey", count: 1 },
|
||||
{ id: "not-monkey", text: "not-monkey", count: 1 },
|
||||
{ id: "happy-monkey", text: "happy-monkey", count: 1 },
|
||||
{ id: "monkey", name: "monkey", count: 1 },
|
||||
{ id: "not-monkey", name: "not-monkey", count: 1 },
|
||||
{ id: "happy-monkey", name: "happy-monkey", count: 1 },
|
||||
],
|
||||
})
|
||||
);
|
||||
|
|
|
@ -136,8 +136,8 @@ export function applyDefaultHandlers(pretender) {
|
|||
pretender.get("/tags/filter/search", () => {
|
||||
return response({
|
||||
results: [
|
||||
{ text: "monkey", count: 1 },
|
||||
{ text: "gazelle", count: 2 },
|
||||
{ id: "monkey", name: "monkey", count: 1 },
|
||||
{ id: "gazelle", name: "gazelle", count: 2 },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,11 +38,11 @@ discourseModule(
|
|||
pretender.get("/tags/filter/search", (params) => {
|
||||
if (params.queryParams.q === "rég") {
|
||||
return response({
|
||||
results: [{ id: "régis", text: "régis", count: 2, pm_count: 0 }],
|
||||
results: [{ id: "régis", name: "régis", count: 2, pm_count: 0 }],
|
||||
});
|
||||
} else if (params.queryParams.q === "dav") {
|
||||
return response({
|
||||
results: [{ id: "David", text: "David", count: 2, pm_count: 0 }],
|
||||
results: [{ id: "David", name: "David", count: 2, pm_count: 0 }],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -96,14 +96,6 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||
results = results.sort((a, b) => a.text.localeCompare(b.text));
|
||||
}
|
||||
|
||||
return results
|
||||
.filter((r) => !makeArray(context.tags).includes(r.id))
|
||||
.map((result) => {
|
||||
return {
|
||||
id: result.text,
|
||||
name: result.description,
|
||||
count: result.count,
|
||||
};
|
||||
});
|
||||
return results.filter((r) => !makeArray(context.tags).includes(r.id));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -126,8 +126,6 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||
results = results.sort((a, b) => a.id > b.id);
|
||||
}
|
||||
|
||||
return results.uniqBy("text").map((result) => {
|
||||
return { id: result.text, name: result.text, count: result.count };
|
||||
});
|
||||
return results.uniqBy("id");
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user