Skip to content

Commit

Permalink
fix(tags): not all tags are loaded in the permission grid
Browse files Browse the repository at this point in the history
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
  • Loading branch information
SychO9 committed Apr 20, 2023
1 parent 8576df1 commit 3fe3c68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions extensions/tags/js/src/admin/addTagsPermissionScope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export default function () {
});

extend(PermissionGrid.prototype, 'oncreate', function () {
app.tagList.load().then(() => {
app.tagList.query().then(() => {
this.loading = false;

m.redraw();
});
});
Expand Down
10 changes: 8 additions & 2 deletions extensions/tags/js/src/common/states/TagListState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ export default class TagListState {
async load(includes: string[] = []): Promise<Tag[]> {
const unloadedIncludes = includes.filter((include) => !this.loadedIncludes.has(include));

console.log('TagListState.load', this.loadedIncludes, unloadedIncludes);

if (unloadedIncludes.length === 0) {
return Promise.resolve(app.store.all<Tag>('tags'));
}

return app.store.find<Tag[]>('tags', { include: unloadedIncludes.join(',') }).then((val) => {
unloadedIncludes.forEach((include) => this.loadedIncludes.add(include));
return this.query(unloadedIncludes);
}

async query(includes: string[] = []): Promise<Tag[]> {
return app.store.find<Tag[]>('tags', { include: includes.join(',') }).then((val) => {
includes.forEach((include) => this.loadedIncludes.add(include));
return val;
});
}
Expand Down

0 comments on commit 3fe3c68

Please sign in to comment.