2023-03-03 15:23:46 +00:00
|
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
|
2023-10-19 17:21:17 +00:00
|
|
|
import { NoteCallbacks } from "@spt-aki/callbacks/NoteCallbacks";
|
|
|
|
import { HandledRoute, ItemEventRouterDefinition } from "@spt-aki/di/Router";
|
|
|
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
|
|
|
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
2023-10-25 11:54:11 +01:00
|
|
|
import { INoteActionData } from "@spt-aki/models/eft/notes/INoteActionData";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
@injectable()
|
2023-11-15 20:35:05 -05:00
|
|
|
export class NoteItemEventRouter extends ItemEventRouterDefinition
|
2023-03-03 15:23:46 +00:00
|
|
|
{
|
|
|
|
constructor(
|
2023-11-15 20:35:05 -05:00
|
|
|
@inject("NoteCallbacks") protected noteCallbacks: NoteCallbacks, // TODO: delay required
|
|
|
|
)
|
2023-03-03 15:23:46 +00:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2023-11-15 20:35:05 -05:00
|
|
|
public override getHandledRoutes(): HandledRoute[]
|
2023-03-03 15:23:46 +00:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
new HandledRoute("AddNote", false),
|
|
|
|
new HandledRoute("EditNote", false),
|
2023-11-15 20:35:05 -05:00
|
|
|
new HandledRoute("DeleteNote", false),
|
2023-03-03 15:23:46 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-11-15 20:35:05 -05:00
|
|
|
public override handleItemEvent(
|
|
|
|
url: string,
|
|
|
|
pmcData: IPmcData,
|
|
|
|
body: INoteActionData,
|
|
|
|
sessionID: string,
|
|
|
|
): IItemEventRouterResponse
|
2023-03-03 15:23:46 +00:00
|
|
|
{
|
|
|
|
switch (url)
|
|
|
|
{
|
|
|
|
case "AddNote":
|
|
|
|
return this.noteCallbacks.addNote(pmcData, body, sessionID);
|
|
|
|
case "EditNote":
|
2023-11-15 20:35:05 -05:00
|
|
|
return this.noteCallbacks.editNote(pmcData, body, sessionID);
|
2023-03-03 15:23:46 +00:00
|
|
|
case "DeleteNote":
|
2023-11-15 20:35:05 -05:00
|
|
|
return this.noteCallbacks.deleteNote(pmcData, body, sessionID);
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-15 20:35:05 -05:00
|
|
|
}
|