Skip to content

Commit

Permalink
fix(core): Translate root Collection on first creation
Browse files Browse the repository at this point in the history
Fixes #1068
  • Loading branch information
michaelbromley committed Sep 13, 2021
1 parent 954c03a commit 46659c7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/core/src/service/services/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ApplyCollectionFiltersJobData = { ctx: SerializedRequestContext; collection

@Injectable()
export class CollectionService implements OnModuleInit {
private rootCollection: Collection | undefined;
private rootCollection: Translated<Collection> | undefined;
private applyFiltersQueue: JobQueue<ApplyCollectionFiltersJobData>;

constructor(
Expand Down Expand Up @@ -569,16 +569,16 @@ export class CollectionService implements OnModuleInit {
}),
);

const newRoot = new Collection({
isRoot: true,
position: 0,
translations: [rootTranslation],
channels: [ctx.channel],
filters: [],
});

await this.connection.getRepository(ctx, Collection).save(newRoot);
this.rootCollection = newRoot;
return newRoot;
const newRoot = await this.connection.getRepository(ctx, Collection).save(
new Collection({
isRoot: true,
position: 0,
translations: [rootTranslation],
channels: [ctx.channel],
filters: [],
}),
);
this.rootCollection = translateDeep(newRoot, ctx.languageCode);
return this.rootCollection;
}
}

0 comments on commit 46659c7

Please sign in to comment.