mirror of
				https://github.com/hydralauncher/hydra.git
				synced 2025-03-09 15:40:26 +00:00 
			
		
		
		
	feat: add test notification
This commit is contained in:
		
							parent
							
								
									7d4d434164
								
							
						
					
					
						commit
						a419b9ae38
					
				
					 5 changed files with 25 additions and 8 deletions
				
			
		| 
						 | 
					@ -12,6 +12,10 @@ import { UserPreferences } from "./entity";
 | 
				
			||||||
import { RealDebridClient } from "./services/real-debrid";
 | 
					import { RealDebridClient } from "./services/real-debrid";
 | 
				
			||||||
import { HydraApi } from "./services/hydra-api";
 | 
					import { HydraApi } from "./services/hydra-api";
 | 
				
			||||||
import { uploadGamesBatch } from "./services/library-sync";
 | 
					import { uploadGamesBatch } from "./services/library-sync";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					  publishCombinedNewAchievementNotification,
 | 
				
			||||||
 | 
					  publishNewAchievementNotification,
 | 
				
			||||||
 | 
					} from "./services/notifications";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const loadState = async (userPreferences: UserPreferences | null) => {
 | 
					const loadState = async (userPreferences: UserPreferences | null) => {
 | 
				
			||||||
  import("./events");
 | 
					  import("./events");
 | 
				
			||||||
| 
						 | 
					@ -49,5 +53,15 @@ userPreferencesRepository
 | 
				
			||||||
    where: { id: 1 },
 | 
					    where: { id: 1 },
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  .then((userPreferences) => {
 | 
					  .then((userPreferences) => {
 | 
				
			||||||
 | 
					    publishCombinedNewAchievementNotification(1000, 999);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    publishNewAchievementNotification({
 | 
				
			||||||
 | 
					      displayName: "Teste 1",
 | 
				
			||||||
 | 
					      achievementIcon:
 | 
				
			||||||
 | 
					        "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg",
 | 
				
			||||||
 | 
					      unlockedAchievementCount: 10,
 | 
				
			||||||
 | 
					      totalAchievementCount: 34,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    loadState(userPreferences);
 | 
					    loadState(userPreferences);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,8 +13,7 @@ import type { AchievementFile, UnlockedAchievement } from "@types";
 | 
				
			||||||
import { achievementsLogger } from "../logger";
 | 
					import { achievementsLogger } from "../logger";
 | 
				
			||||||
import { Cracker } from "@shared";
 | 
					import { Cracker } from "@shared";
 | 
				
			||||||
import { IsNull, Not } from "typeorm";
 | 
					import { IsNull, Not } from "typeorm";
 | 
				
			||||||
import { WindowManager } from "../window-manager";
 | 
					import { publishCombinedNewAchievementNotification } from "../notifications";
 | 
				
			||||||
import { publishNewAchievementBulkNotification } from "../notifications";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fileStats: Map<string, number> = new Map();
 | 
					const fileStats: Map<string, number> = new Map();
 | 
				
			||||||
const fltFiles: Map<string, Set<string>> = new Map();
 | 
					const fltFiles: Map<string, Set<string>> = new Map();
 | 
				
			||||||
| 
						 | 
					@ -250,10 +249,12 @@ export class AchievementWatcherManager {
 | 
				
			||||||
      0
 | 
					      0
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    publishNewAchievementBulkNotification(
 | 
					    if (totalNewAchievements > 0) {
 | 
				
			||||||
      totalNewAchievements,
 | 
					      publishCombinedNewAchievementNotification(
 | 
				
			||||||
      totalNewGamesWithAchievements
 | 
					        totalNewAchievements,
 | 
				
			||||||
    );
 | 
					        totalNewGamesWithAchievements
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.hasFinishedMergingWithRemote = true;
 | 
					    this.hasFinishedMergingWithRemote = true;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ import { getUnlockedAchievements } from "@main/events/user/get-unlocked-achievem
 | 
				
			||||||
import { Game } from "@main/entity";
 | 
					import { Game } from "@main/entity";
 | 
				
			||||||
import { achievementsLogger } from "../logger";
 | 
					import { achievementsLogger } from "../logger";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  publishNewAchievementBulkNotification as publishCombinedNewAchievementNotification,
 | 
					  publishCombinedNewAchievementNotification,
 | 
				
			||||||
  publishNewAchievementNotification,
 | 
					  publishNewAchievementNotification,
 | 
				
			||||||
} from "../notifications";
 | 
					} from "../notifications";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,7 +92,7 @@ async function downloadImage(url: string) {
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const publishNewAchievementBulkNotification = async (
 | 
					export const publishCombinedNewAchievementNotification = async (
 | 
				
			||||||
  achievementCount,
 | 
					  achievementCount,
 | 
				
			||||||
  gameCount,
 | 
					  gameCount,
 | 
				
			||||||
  achievementIcon?: string
 | 
					  achievementIcon?: string
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,6 +94,8 @@ export interface UserGame {
 | 
				
			||||||
  cover: string;
 | 
					  cover: string;
 | 
				
			||||||
  playTimeInSeconds: number;
 | 
					  playTimeInSeconds: number;
 | 
				
			||||||
  lastTimePlayed: Date | null;
 | 
					  lastTimePlayed: Date | null;
 | 
				
			||||||
 | 
					  unlockedAchievementCount: number;
 | 
				
			||||||
 | 
					  achievementCount: number;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface DownloadQueue {
 | 
					export interface DownloadQueue {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue