mirror of
https://github.com/flarum/core.git
synced 2025-08-02 22:47:33 +02:00
fix(tags): not all tags are loaded in the permission grid (#3804)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ export default function () {
|
|||||||
extend(PermissionGrid.prototype, 'oncreate', function () {
|
extend(PermissionGrid.prototype, 'oncreate', function () {
|
||||||
app.tagList.load().then(() => {
|
app.tagList.load().then(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
m.redraw();
|
m.redraw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -2,17 +2,27 @@ import app from 'flarum/common/app';
|
|||||||
import type Tag from '../../common/models/Tag';
|
import type Tag from '../../common/models/Tag';
|
||||||
|
|
||||||
export default class TagListState {
|
export default class TagListState {
|
||||||
loadedIncludes = new Set();
|
loadedIncludes?: Set<string>;
|
||||||
|
|
||||||
async load(includes: string[] = []): Promise<Tag[]> {
|
async load(includes: string[] = []): Promise<Tag[]> {
|
||||||
const unloadedIncludes = includes.filter((include) => !this.loadedIncludes.has(include));
|
if (!this.loadedIncludes) {
|
||||||
|
return this.query(includes);
|
||||||
|
}
|
||||||
|
|
||||||
|
const unloadedIncludes = includes.filter((include) => !this.loadedIncludes!.has(include));
|
||||||
|
|
||||||
if (unloadedIncludes.length === 0) {
|
if (unloadedIncludes.length === 0) {
|
||||||
return Promise.resolve(app.store.all<Tag>('tags'));
|
return Promise.resolve(app.store.all<Tag>('tags'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.store.find<Tag[]>('tags', { include: unloadedIncludes.join(',') }).then((val) => {
|
return this.query(unloadedIncludes);
|
||||||
unloadedIncludes.forEach((include) => this.loadedIncludes.add(include));
|
}
|
||||||
|
|
||||||
|
async query(includes: string[] = []): Promise<Tag[]> {
|
||||||
|
this.loadedIncludes ??= new Set();
|
||||||
|
|
||||||
|
return app.store.find<Tag[]>('tags', { include: includes.join(',') }).then((val) => {
|
||||||
|
includes.forEach((include) => this.loadedIncludes!.add(include));
|
||||||
return val;
|
return val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user