diff --git a/packages/core/src/sheet.ts b/packages/core/src/sheet.ts index 1d17ae79..a80c99e9 100644 --- a/packages/core/src/sheet.ts +++ b/packages/core/src/sheet.ts @@ -145,6 +145,7 @@ export class GearPlanSheet { // General sheet properties _sheetName: string; _description: string; + lastModified: Date; readonly classJobName: JobName; readonly level: SupportedLevel; readonly ilvlSync: number | undefined; @@ -198,6 +199,12 @@ export class GearPlanSheet { this.classJobName = importedData.job ?? 'WHM'; this.ilvlSync = importedData.ilvlSync; this._description = importedData.description; + if (importedData.timestamp) { + this.lastModified = new Date(importedData.timestamp); + } + else { + this.lastModified = new Date(Date.now()); + } if (importedData.itemDisplaySettings) { Object.assign(this._itemDisplaySettings, importedData.itemDisplaySettings); } @@ -338,6 +345,7 @@ export class GearPlanSheet { } if (this.saveKey) { console.log("Saving sheet " + this.sheetName); + this.lastModified = new Date(Date.now()); const fullExport = this.exportSheet(false); localStorage.setItem(this.saveKey, JSON.stringify(fullExport)); } @@ -440,6 +448,7 @@ export class GearPlanSheet { description: this.description, customItems: this._customItems.map(ci => ci.export()), customFoods: this._customFoods.map(cf => cf.export()), + timestamp: this.lastModified.getTime(), }; if (!external) { out.saveKey = this._saveKey; diff --git a/packages/xivmath/src/geartypes.ts b/packages/xivmath/src/geartypes.ts index 43f4b703..cd4cb791 100644 --- a/packages/xivmath/src/geartypes.ts +++ b/packages/xivmath/src/geartypes.ts @@ -593,6 +593,13 @@ export interface SimExport { name?: string } +/** + * Represents fields injected by the shortlink server + */ +export type ApiInjectedValues = { + timestamp?: number +} + // TODO: further split this up. API vs Local should have different types. /** * Represents an exported set. Many of the fields fill the same role as the fields @@ -601,7 +608,7 @@ export interface SimExport { * Some of the fields are only relevant for local saves, while others are only relevant * for external (API) saves. */ -export interface SheetExport { +export type SheetExport = ApiInjectedValues & { /** * Name of the sheet. */ @@ -697,7 +704,7 @@ export interface SheetStatsExport extends SheetExport { * If it is an individual sheet export, then several of the properties that would normally live at the sheet level * will instead be here (such as job and level). */ -export interface SetExport { +export type SetExport = ApiInjectedValues & { /** * Name of the gear set. */