mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
21 lines
659 B
TypeScript
21 lines
659 B
TypeScript
import type { Game } from "@types";
|
|
import { HydraApi } from "../hydra-api";
|
|
import { gamesSublevel, levelKeys } from "@main/level";
|
|
|
|
export const createGame = async (game: Game) => {
|
|
return HydraApi.post(`/profile/games`, {
|
|
objectId: game.objectId,
|
|
playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds),
|
|
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,
|
|
});
|
|
});
|
|
};
|