Skip to content

Commit

Permalink
refactor: rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEnx authored and JackEnx committed May 9, 2024
1 parent 628670f commit 825c66d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main/events/achievements/game-achievements-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { watch } from "node:fs/promises";
import { getGameAchievementsToWatch } from "./services/get-game-achievements-to-watch";
import { checkUnlockedAchievements } from "./util/check-unlocked-achievements";
import { parseAchievementFile } from "./util/parseAchievementFile";
import { steamGameAchievementsRepository } from "@main/repository";
import { steamGameAchievementRepository } from "@main/repository";

type GameAchievementObserver = {
[id: number]: AbortController | null;
Expand Down Expand Up @@ -61,7 +61,7 @@ export const startGameAchievementObserver = async (gameId: number) => {
if (checked.new) {
console.log(checked.new);

steamGameAchievementsRepository.update(
steamGameAchievementRepository.update(
{
steamGame: { id: steamId },
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
gameRepository,
steamGameAchievementsRepository,
steamGameAchievementRepository,
} from "@main/repository";
import { steamGetAchivement } from "../steam/steam-get-achivement";
import { steamFindGameAchievementFiles } from "../steam/steam-find-game-achivement-files";
Expand Down Expand Up @@ -50,7 +50,7 @@ export const getGameAchievementsToWatch = async (
}

if (checkedAchievements.new.length) {
await steamGameAchievementsRepository.update(
await steamGameAchievementRepository.update(
{
steamGame: { id: steamId },
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
steamGameAchievementsRepository,
steamGameAchievementRepository,
steamGameRepository,
} from "@main/repository";
import { steamFindGameAchievementFiles } from "../steam/steam-find-game-achivement-files";
Expand All @@ -10,7 +10,7 @@ import { parseAchievementFile } from "../util/parseAchievementFile";
import { checkUnlockedAchievements } from "../util/check-unlocked-achievements";
import { CheckedAchievements } from "../types";

export const saveAllLocalAchivements = async () => {
export const saveAllLocalSteamAchivements = async () => {
const gameAchievementFiles = steamFindGameAchievementFiles();

for (const key of Object.keys(gameAchievementFiles)) {
Expand All @@ -24,7 +24,7 @@ export const saveAllLocalAchivements = async () => {

if (!steamGame) continue;

const hasOnDb = await steamGameAchievementsRepository.existsBy({
const hasOnDb = await steamGameAchievementRepository.existsBy({
steamGame,
});

Expand All @@ -33,7 +33,7 @@ export const saveAllLocalAchivements = async () => {
const achievementPercentage = await steamGlobalAchievementPercentages(id);

if (!achievementPercentage) {
await steamGameAchievementsRepository.save({
await steamGameAchievementRepository.save({
steamGame,
achievements: "[]",
});
Expand Down Expand Up @@ -70,7 +70,7 @@ export const saveAllLocalAchivements = async () => {
);
}

await steamGameAchievementsRepository.save({
await steamGameAchievementRepository.save({
steamGame,
achievements: JSON.stringify(checkedAchievements.all),
});
Expand Down
12 changes: 6 additions & 6 deletions src/main/events/achievements/steam/steam-get-achivement.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
steamGameAchievementsRepository,
steamGameAchievementRepository,
steamGameRepository,
} from "@main/repository";
import { steamGlobalAchievementPercentages } from "./steam-global-achievement-percentages";
Expand All @@ -16,16 +16,16 @@ export const steamGetAchivement = async (

if (!steamGame) return;

const gameAchivement = await steamGameAchievementsRepository.findOne({
const steamGameAchivement = await steamGameAchievementRepository.findOne({
where: { steamGame },
});

if (!gameAchivement) {
if (!steamGameAchivement) {
const achievementPercentage =
await steamGlobalAchievementPercentages(steamGameId);

if (!achievementPercentage) {
await steamGameAchievementsRepository.save({
await steamGameAchievementRepository.save({
steamGame,
achievements: "[]",
});
Expand All @@ -43,13 +43,13 @@ export const steamGetAchivement = async (

if (!achievements) return;

await steamGameAchievementsRepository.save({
await steamGameAchievementRepository.save({
steamGame,
achievements: JSON.stringify(achievements),
});

return achievements;
} else {
return JSON.parse(gameAchivement.achievements);
return JSON.parse(steamGameAchivement.achievements);
}
};
2 changes: 1 addition & 1 deletion src/main/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const migrationScriptRepository =

export const steamGameRepository = dataSource.getRepository(SteamGame);

export const steamGameAchievementsRepository = dataSource.getRepository(
export const steamGameAchievementRepository = dataSource.getRepository(
SteamGameAchievements
);

0 comments on commit 825c66d

Please sign in to comment.