mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-18 16:53:57 +00:00
26 lines
713 B
TypeScript
26 lines
713 B
TypeScript
import type { Game } from "@types";
|
|
import { HydraApi } from "../hydra-api";
|
|
import { gamesSublevel, levelKeys } from "@main/level";
|
|
|
|
export const createGame = async (game: Game) => {
|
|
if (game.shop === "custom") {
|
|
return;
|
|
}
|
|
|
|
return HydraApi.post(`/profile/games`, {
|
|
objectId: game.objectId,
|
|
playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds ?? 0),
|
|
shop: game.shop,
|
|
lastTimePlayed: game.lastTimePlayed,
|
|
}).then((response) => {
|
|
const { id: remoteId, playTimeInMilliseconds, lastTimePlayed } = response;
|
|
|
|
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
|
...game,
|
|
remoteId,
|
|
playTimeInMilliseconds,
|
|
lastTimePlayed,
|
|
});
|
|
});
|
|
};
|