cleanup and track friends data (if not being already tracked)

This commit is contained in:
Lee
2024-10-17 07:12:03 +01:00
parent 64f918c325
commit 7f5587546c
19 changed files with 59 additions and 38 deletions

@ -1,4 +1,6 @@
import { PlayerHistory } from "../types/player/player-history";
import { kyFetch } from "./utils";
import { Config } from "../config";
/**
* Sorts the player history based on date,
@ -11,3 +13,12 @@ export function sortPlayerHistory(history: Map<string, PlayerHistory>) {
(a, b) => Date.parse(b[0]) - Date.parse(a[0]) // Sort in descending order
);
}
/**
* Ensure the player is being tracked.
*
* @param id the player id
*/
export async function trackPlayer(id: string) {
await kyFetch(`${Config.apiUrl}/player/history/${id}?createIfMissing=true`);
}