From 3b255f3ce4a1456ec3fa6bc836621a8f119e874f Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 11 Jan 2024 11:53:19 +0000 Subject: [PATCH] Fix `createMagazineTemplate` failing when no `userbuilds.magazineBuilds` array exists --- project/src/controllers/BuildController.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/project/src/controllers/BuildController.ts b/project/src/controllers/BuildController.ts index d378bd27..25e9e24c 100644 --- a/project/src/controllers/BuildController.ts +++ b/project/src/controllers/BuildController.ts @@ -193,6 +193,9 @@ export class BuildController this.logger.error(`Unable to delete preset, cannot find ${id} in weapon, equipment or magazine presets`); } + /** + * Handle client/builds/magazine/save + */ public createMagazineTemplate(sessionId: string, request: ISetMagazineRequest): void { const result: IMagazineBuild = { @@ -206,6 +209,11 @@ export class BuildController const profile = this.profileHelper.getFullProfile(sessionId); + if (!profile.userbuilds.magazineBuilds) + { + profile.userbuilds.magazineBuilds = []; + } + const existingArrayId = profile.userbuilds.magazineBuilds.findIndex(item => item.Name === request.Name); if (existingArrayId === -1)