mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Permalink search regressed in https://github.com/discourse/discourse/pull/30633 where the search implementation was changed from server side to client side. Prior to that change, we included a `filter` param in the request to make the server find permalinks that matched the given filter and return the results limited to 100 records. However, with that change, we stopped sending the `filter` param with the request, which made the server always return the same 100 records which would then be filtered on the client side. That means if a site has more than 100 records, any records that don't make it in the first 100 will never be found using search. Meta topic: https://meta.discourse.org/t/permalinks-no-longer-has-a-way-to-search-or-show-all-permalinks/351922?u=osama
28 lines
777 B
JavaScript
28 lines
777 B
JavaScript
import { ajax } from "discourse/lib/ajax";
|
|
import discourseComputed from "discourse/lib/decorators";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import Category from "discourse/models/category";
|
|
import RestModel from "discourse/models/rest";
|
|
|
|
export default class Permalink extends RestModel {
|
|
static async findAll(filter) {
|
|
const data = await ajax("/admin/permalinks.json", { data: { filter } });
|
|
return data.map((p) => Permalink.create(p));
|
|
}
|
|
|
|
@discourseComputed("category_id")
|
|
category(category_id) {
|
|
return Category.findById(category_id);
|
|
}
|
|
|
|
@discourseComputed("external_url")
|
|
linkIsExternal(external_url) {
|
|
return !DiscourseURL.isInternal(external_url);
|
|
}
|
|
|
|
@discourseComputed("url")
|
|
key(url) {
|
|
return url.replace("/", "_");
|
|
}
|
|
}
|