Fix issues with mag tempalte saving
This commit is contained in:
parent
8dc322180f
commit
c1f8cee19f
@ -2,6 +2,7 @@ import { BuildController } from "@spt-aki/controllers/BuildController";
|
||||
import { ISetMagazineRequest } from "@spt-aki/models/eft/builds/ISetMagazineRequest";
|
||||
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
||||
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
||||
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
|
||||
import { IUserBuilds } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
@ -28,11 +29,11 @@ export class BuildsCallbacks
|
||||
* Handle client/builds/magazine/save
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public createMagazineTemplate(url: string, request: ISetMagazineRequest, sessionID: string): IGetBodyResponseData<string>
|
||||
public createMagazineTemplate(url: string, request: ISetMagazineRequest, sessionID: string): INullResponseData
|
||||
{
|
||||
this.buildController.createMagazineTemplate(sessionID, request)
|
||||
|
||||
return this.httpResponse.emptyResponse();
|
||||
return this.httpResponse.nullResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,6 +243,17 @@ export class BuildController
|
||||
};
|
||||
|
||||
const profile = this.profileHelper.getFullProfile(sessionId);
|
||||
profile.userbuilds.magazineBuilds.push(result);
|
||||
|
||||
const existingArrayId = profile.userbuilds.magazineBuilds.findIndex(item => item.Name === request.Name);
|
||||
|
||||
if (existingArrayId === -1)
|
||||
{
|
||||
|
||||
profile.userbuilds.magazineBuilds.push(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile.userbuilds.magazineBuilds.splice(existingArrayId, 1, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user