mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 05:46:17 +00:00
Merge branch 'main' into feat/playtime-in-reviews
This commit is contained in:
2
.github/workflows/update-aur.yml
vendored
2
.github/workflows/update-aur.yml
vendored
@@ -95,6 +95,8 @@ jobs:
|
||||
- name: Update PKGBUILD and .SRCINFO
|
||||
if: steps.check-update.outputs.update_needed == 'true'
|
||||
run: |
|
||||
# sleeps for 1 minute to be sure GH updated the release info
|
||||
sleep 60
|
||||
# Update pkgver in PKGBUILD
|
||||
cd hydra-launcher-bin
|
||||
NEW_VERSION="${{ steps.get-version.outputs.version }}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydralauncher",
|
||||
"version": "3.7.2",
|
||||
"version": "3.7.3",
|
||||
"description": "Hydra",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "Los Broxas",
|
||||
|
||||
@@ -362,7 +362,10 @@
|
||||
"show_original": "Show original",
|
||||
"show_translation": "Show translation",
|
||||
"show_original_translated_from": "Show original (translated from {{language}})",
|
||||
"hide_original": "Hide original"
|
||||
"hide_original": "Hide original",
|
||||
"review_from_blocked_user": "Review from blocked user",
|
||||
"show": "Show",
|
||||
"hide": "Hide"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Activate Hydra",
|
||||
|
||||
@@ -361,7 +361,10 @@
|
||||
"you_seemed_to_enjoy_this_game": "Parece que has disfrutado de este juego",
|
||||
"language": "Idioma",
|
||||
"caption": "Subtítulo",
|
||||
"audio": "Audio"
|
||||
"audio": "Audio",
|
||||
"review_from_blocked_user": "Reseña de usuario bloqueado",
|
||||
"show": "Mostrar",
|
||||
"hide": "Ocultar"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Activar Hydra",
|
||||
|
||||
@@ -349,7 +349,10 @@
|
||||
"show_translation": "Mostrar tradução",
|
||||
"show_original_translated_from": "Mostrar original (traduzido do {{language}})",
|
||||
"hide_original": "Ocultar original",
|
||||
"rating_count": "Avaliação"
|
||||
"rating_count": "Avaliação",
|
||||
"review_from_blocked_user": "Avaliação de usuário bloqueado",
|
||||
"show": "Mostrar",
|
||||
"hide": "Ocultar"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Ativação",
|
||||
|
||||
@@ -180,7 +180,10 @@
|
||||
"download_error_not_cached_on_torbox": "Este download não está disponível no TorBox e a verificação do status do download não está disponível.",
|
||||
"game_removed_from_favorites": "Jogo removido dos favoritos",
|
||||
"game_added_to_favorites": "Jogo adicionado aos favoritos",
|
||||
"create_start_menu_shortcut": "Criar atalho no Menu Iniciar"
|
||||
"create_start_menu_shortcut": "Criar atalho no Menu Iniciar",
|
||||
"review_from_blocked_user": "Avaliação de utilizador bloqueado",
|
||||
"show": "Mostrar",
|
||||
"hide": "Ocultar"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Ativação",
|
||||
|
||||
@@ -351,6 +351,8 @@
|
||||
"audio": "Аудио",
|
||||
"filter_by_source": "Фильтр по источнику",
|
||||
"no_repacks_found": "Источники для этой игры не найдены",
|
||||
"show": "Показать",
|
||||
"hide": "Скрыть",
|
||||
"delete_review": "Удалить отзыв",
|
||||
"remove_review": "Удалить отзыв",
|
||||
"delete_review_modal_title": "Вы уверены, что хотите удалить свой отзыв?",
|
||||
@@ -361,7 +363,8 @@
|
||||
"show_original": "Показать оригинал",
|
||||
"show_translation": "Показать перевод",
|
||||
"show_original_translated_from": "Показать оригинал (переведено с {{language}})",
|
||||
"hide_original": "Скрыть оригинал"
|
||||
"hide_original": "Скрыть оригинал",
|
||||
"review_from_blocked_user": "Отзыв от заблокированного пользователя"
|
||||
},
|
||||
"activation": {
|
||||
"title": "Активировать Hydra",
|
||||
|
||||
@@ -167,6 +167,8 @@ export class AchievementWatcherManager {
|
||||
shop: GameShop,
|
||||
objectId: string
|
||||
) {
|
||||
if (shop === "custom") return;
|
||||
|
||||
const gameKey = levelKeys.game(shop, objectId);
|
||||
if (this.alreadySyncedGames.get(gameKey)) return;
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ 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),
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import type { Game } from "@types";
|
||||
import { HydraApi } from "../hydra-api";
|
||||
|
||||
export const updateGamePlaytime = async (
|
||||
export const trackGamePlaytime = async (
|
||||
game: Game,
|
||||
deltaInMillis: number,
|
||||
lastTimePlayed: Date
|
||||
) => {
|
||||
return HydraApi.put(`/profile/games/${game.remoteId}`, {
|
||||
if (game.shop === "custom") {
|
||||
return;
|
||||
}
|
||||
|
||||
return HydraApi.put(`/profile/games/${game.shop}/${game.objectId}`, {
|
||||
playTimeDeltaInSeconds: Math.trunc(deltaInMillis / 1000),
|
||||
lastTimePlayed,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WindowManager } from "./window-manager";
|
||||
import { createGame, updateGamePlaytime } from "./library-sync";
|
||||
import { createGame, trackGamePlaytime } from "./library-sync";
|
||||
import type { Game, GameRunning, UserPreferences } from "@types";
|
||||
import { PythonRPC } from "./python-rpc";
|
||||
import axios from "axios";
|
||||
@@ -198,11 +198,6 @@ export const watchProcesses = async () => {
|
||||
function onOpenGame(game: Game) {
|
||||
const now = performance.now();
|
||||
|
||||
AchievementWatcherManager.firstSyncWithRemoteIfNeeded(
|
||||
game.shop,
|
||||
game.objectId
|
||||
);
|
||||
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
lastTick: now,
|
||||
firstTick: now,
|
||||
@@ -220,8 +215,15 @@ function onOpenGame(game: Game) {
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
if (game.shop === "custom") return;
|
||||
|
||||
AchievementWatcherManager.firstSyncWithRemoteIfNeeded(
|
||||
game.shop,
|
||||
game.objectId
|
||||
);
|
||||
|
||||
if (game.remoteId) {
|
||||
updateGamePlaytime(
|
||||
trackGamePlaytime(
|
||||
game,
|
||||
game.unsyncedDeltaPlayTimeInMilliseconds ?? 0,
|
||||
new Date()
|
||||
@@ -255,43 +257,46 @@ function onTickGame(game: Game) {
|
||||
|
||||
const delta = now - gamePlaytime.lastTick;
|
||||
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
const updatedGame: Game = {
|
||||
...game,
|
||||
playTimeInMilliseconds: (game.playTimeInMilliseconds ?? 0) + delta,
|
||||
lastTimePlayed: new Date(),
|
||||
});
|
||||
};
|
||||
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), updatedGame);
|
||||
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
...gamePlaytime,
|
||||
lastTick: now,
|
||||
});
|
||||
|
||||
if (currentTick % TICKS_TO_UPDATE_API === 0) {
|
||||
if (currentTick % TICKS_TO_UPDATE_API === 0 && game.shop !== "custom") {
|
||||
const deltaToSync =
|
||||
now -
|
||||
gamePlaytime.lastSyncTick +
|
||||
(game.unsyncedDeltaPlayTimeInMilliseconds ?? 0);
|
||||
|
||||
const gamePromise = game.remoteId
|
||||
? updateGamePlaytime(game, deltaToSync, game.lastTimePlayed!)
|
||||
? trackGamePlaytime(game, deltaToSync, game.lastTimePlayed!)
|
||||
: createGame(game);
|
||||
|
||||
gamePromise
|
||||
.then(() => {
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
...game,
|
||||
...updatedGame,
|
||||
unsyncedDeltaPlayTimeInMilliseconds: 0,
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
...game,
|
||||
...updatedGame,
|
||||
unsyncedDeltaPlayTimeInMilliseconds: deltaToSync,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
gamesPlaytime.set(levelKeys.game(game.shop, game.objectId), {
|
||||
...gamePlaytime,
|
||||
lastTick: now,
|
||||
lastSyncTick: now,
|
||||
});
|
||||
});
|
||||
@@ -299,11 +304,24 @@ function onTickGame(game: Game) {
|
||||
}
|
||||
|
||||
const onCloseGame = (game: Game) => {
|
||||
const now = performance.now();
|
||||
const gamePlaytime = gamesPlaytime.get(
|
||||
levelKeys.game(game.shop, game.objectId)
|
||||
)!;
|
||||
gamesPlaytime.delete(levelKeys.game(game.shop, game.objectId));
|
||||
|
||||
const delta = now - gamePlaytime.lastTick;
|
||||
|
||||
const updatedGame: Game = {
|
||||
...game,
|
||||
playTimeInMilliseconds: (game.playTimeInMilliseconds ?? 0) + delta,
|
||||
lastTimePlayed: new Date(),
|
||||
};
|
||||
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), updatedGame);
|
||||
|
||||
if (game.shop === "custom") return;
|
||||
|
||||
if (game.remoteId) {
|
||||
if (game.automaticCloudSync) {
|
||||
CloudSync.uploadSaveGame(
|
||||
@@ -315,20 +333,20 @@ const onCloseGame = (game: Game) => {
|
||||
}
|
||||
|
||||
const deltaToSync =
|
||||
performance.now() -
|
||||
now -
|
||||
gamePlaytime.lastSyncTick +
|
||||
(game.unsyncedDeltaPlayTimeInMilliseconds ?? 0);
|
||||
|
||||
return updateGamePlaytime(game, deltaToSync, game.lastTimePlayed!)
|
||||
return trackGamePlaytime(game, deltaToSync, game.lastTimePlayed!)
|
||||
.then(() => {
|
||||
return gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
...game,
|
||||
...updatedGame,
|
||||
unsyncedDeltaPlayTimeInMilliseconds: 0,
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
return gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
...game,
|
||||
...updatedGame,
|
||||
unsyncedDeltaPlayTimeInMilliseconds: deltaToSync,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -289,12 +289,6 @@ export class WindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static loadNotificationWindowURL() {
|
||||
if (this.notificationWindow) {
|
||||
this.loadWindowURL(this.notificationWindow, "achievement-notification");
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly NOTIFICATION_WINDOW_WIDTH = 360;
|
||||
private static readonly NOTIFICATION_WINDOW_HEIGHT = 140;
|
||||
|
||||
@@ -302,46 +296,58 @@ export class WindowManager {
|
||||
position: AchievementCustomNotificationPosition | undefined
|
||||
) {
|
||||
const display = screen.getPrimaryDisplay();
|
||||
const { width, height } = display.workAreaSize;
|
||||
const {
|
||||
x: displayX,
|
||||
y: displayY,
|
||||
width: displayWidth,
|
||||
height: displayHeight,
|
||||
} = display.bounds;
|
||||
|
||||
if (position === "bottom-left") {
|
||||
return {
|
||||
x: 0,
|
||||
y: height - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
x: displayX,
|
||||
y: displayY + displayHeight - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
if (position === "bottom-center") {
|
||||
return {
|
||||
x: (width - this.NOTIFICATION_WINDOW_WIDTH) / 2,
|
||||
y: height - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
x: displayX + (displayWidth - this.NOTIFICATION_WINDOW_WIDTH) / 2,
|
||||
y: displayY + displayHeight - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
if (position === "bottom-right") {
|
||||
return {
|
||||
x: width - this.NOTIFICATION_WINDOW_WIDTH,
|
||||
y: height - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
x: displayX + displayWidth - this.NOTIFICATION_WINDOW_WIDTH,
|
||||
y: displayY + displayHeight - this.NOTIFICATION_WINDOW_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
if (position === "top-left") {
|
||||
return {
|
||||
x: displayX,
|
||||
y: displayY,
|
||||
};
|
||||
}
|
||||
|
||||
if (position === "top-center") {
|
||||
return {
|
||||
x: (width - this.NOTIFICATION_WINDOW_WIDTH) / 2,
|
||||
y: 0,
|
||||
x: displayX + (displayWidth - this.NOTIFICATION_WINDOW_WIDTH) / 2,
|
||||
y: displayY,
|
||||
};
|
||||
}
|
||||
|
||||
if (position === "top-right") {
|
||||
return {
|
||||
x: width - this.NOTIFICATION_WINDOW_WIDTH,
|
||||
y: 0,
|
||||
x: displayX + displayWidth - this.NOTIFICATION_WINDOW_WIDTH,
|
||||
y: displayY,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
x: 0,
|
||||
y: 0,
|
||||
x: displayX,
|
||||
y: displayY,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -387,7 +393,7 @@ export class WindowManager {
|
||||
this.notificationWindow.setIgnoreMouseEvents(true);
|
||||
|
||||
this.notificationWindow.setAlwaysOnTop(true, "screen-saver", 1);
|
||||
this.loadNotificationWindowURL();
|
||||
this.loadWindowURL(this.notificationWindow, "achievement-notification");
|
||||
|
||||
if (!app.isPackaged || isStaging) {
|
||||
this.notificationWindow.webContents.openDevTools();
|
||||
|
||||
@@ -60,7 +60,7 @@ export function Header() {
|
||||
};
|
||||
|
||||
const handleSearch = (value: string) => {
|
||||
dispatch(setFilters({ title: value }));
|
||||
dispatch(setFilters({ title: value.slice(0, 255) }));
|
||||
|
||||
if (!location.pathname.startsWith("/catalogue")) {
|
||||
navigate("/catalogue");
|
||||
|
||||
@@ -293,6 +293,8 @@ export function GameDetailsContextProvider({
|
||||
}, [objectId, shop, userDetails]);
|
||||
|
||||
useEffect(() => {
|
||||
if (shop === "custom") return;
|
||||
|
||||
const fetchDownloadSources = async () => {
|
||||
try {
|
||||
const sources = await window.electron.getDownloadSources();
|
||||
|
||||
@@ -35,7 +35,7 @@ export default function Catalogue() {
|
||||
|
||||
const { steamDevelopers, steamPublishers, downloadSources } = useCatalogue();
|
||||
|
||||
const { steamGenres, steamUserTags } = useAppSelector(
|
||||
const { steamGenres, steamUserTags, filters, page } = useAppSelector(
|
||||
(state) => state.catalogueSearch
|
||||
);
|
||||
|
||||
@@ -47,8 +47,6 @@ export default function Catalogue() {
|
||||
|
||||
const { formatNumber } = useFormat();
|
||||
|
||||
const { filters, page } = useAppSelector((state) => state.catalogueSearch);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const { t, i18n } = useTranslation("catalogue");
|
||||
|
||||
@@ -163,7 +163,6 @@ export function GameReviews({
|
||||
take: "20",
|
||||
skip: skip.toString(),
|
||||
sortBy: reviewsSortBy,
|
||||
language: i18n.language,
|
||||
});
|
||||
|
||||
const response = await window.electron.hydraApi.get(
|
||||
|
||||
@@ -66,25 +66,18 @@ export function ReviewItem({
|
||||
|
||||
const [showOriginal, setShowOriginal] = useState(false);
|
||||
|
||||
// Check if this is the user's own review
|
||||
const isOwnReview = userDetailsId === review.user.id;
|
||||
|
||||
// Helper to get base language code (e.g., "pt" from "pt-BR")
|
||||
const getBaseLanguage = (lang: string) => lang.split("-")[0];
|
||||
const getBaseLanguage = (lang: string | null) => lang?.split("-")[0] || "";
|
||||
|
||||
// Check if the review is in a different language (comparing base language codes)
|
||||
const isDifferentLanguage =
|
||||
getBaseLanguage(review.detectedLanguage) !== getBaseLanguage(i18n.language);
|
||||
|
||||
// Check if translation is available and needed (but not for own reviews)
|
||||
const needsTranslation =
|
||||
!isOwnReview &&
|
||||
isDifferentLanguage &&
|
||||
review.translations &&
|
||||
review.translations[i18n.language];
|
||||
!isOwnReview && isDifferentLanguage && review.translations[i18n.language];
|
||||
|
||||
// Get the full language name using Intl.DisplayNames
|
||||
const getLanguageName = (languageCode: string) => {
|
||||
const getLanguageName = (languageCode: string | null) => {
|
||||
if (!languageCode) return "";
|
||||
try {
|
||||
const displayNames = new Intl.DisplayNames([i18n.language], {
|
||||
type: "language",
|
||||
@@ -118,12 +111,12 @@ export function ReviewItem({
|
||||
return (
|
||||
<div className="game-details__review-item">
|
||||
<div className="game-details__blocked-review-simple">
|
||||
Review from blocked user —{" "}
|
||||
{t("review_from_blocked_user")}
|
||||
<button
|
||||
className="game-details__blocked-review-show-link"
|
||||
onClick={() => onToggleVisibility(review.id)}
|
||||
>
|
||||
Show
|
||||
{t("show")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -338,7 +331,7 @@ export function ReviewItem({
|
||||
className="game-details__blocked-review-hide-link"
|
||||
onClick={() => onToggleVisibility(review.id)}
|
||||
>
|
||||
Hide
|
||||
{t("hide")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -89,7 +89,7 @@ export function SettingsDownloadSources() {
|
||||
try {
|
||||
await window.electron.removeDownloadSource(false, downloadSource.id);
|
||||
const sources = await window.electron.getDownloadSources();
|
||||
setDownloadSources(sources as DownloadSource[]);
|
||||
setDownloadSources(sources);
|
||||
showSuccessToast(t("removed_download_source"));
|
||||
} catch (error) {
|
||||
logger.error("Failed to remove download source:", error);
|
||||
@@ -104,7 +104,7 @@ export function SettingsDownloadSources() {
|
||||
try {
|
||||
await window.electron.removeDownloadSource(true);
|
||||
const sources = await window.electron.getDownloadSources();
|
||||
setDownloadSources(sources as DownloadSource[]);
|
||||
setDownloadSources(sources);
|
||||
showSuccessToast(t("removed_all_download_sources"));
|
||||
} catch (error) {
|
||||
logger.error("Failed to remove all download sources:", error);
|
||||
@@ -117,7 +117,7 @@ export function SettingsDownloadSources() {
|
||||
const handleAddDownloadSource = async () => {
|
||||
try {
|
||||
const sources = await window.electron.getDownloadSources();
|
||||
setDownloadSources(sources as DownloadSource[]);
|
||||
setDownloadSources(sources);
|
||||
} catch (error) {
|
||||
logger.error("Failed to refresh download sources:", error);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ export function SettingsDownloadSources() {
|
||||
try {
|
||||
await window.electron.syncDownloadSources();
|
||||
const sources = await window.electron.getDownloadSources();
|
||||
setDownloadSources(sources as DownloadSource[]);
|
||||
setDownloadSources(sources);
|
||||
|
||||
showSuccessToast(t("download_sources_synced_successfully"));
|
||||
} finally {
|
||||
|
||||
@@ -253,7 +253,7 @@ export interface GameReview {
|
||||
translations: {
|
||||
[key: string]: string;
|
||||
};
|
||||
detectedLanguage: string;
|
||||
detectedLanguage: string | null;
|
||||
}
|
||||
|
||||
export interface TrendingGame extends ShopAssets {
|
||||
|
||||
Reference in New Issue
Block a user