mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-12 14:26:16 +00:00
Compare commits
1 Commits
fix/lint-b
...
feat/LBX-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96b12cb27e |
@@ -35,27 +35,18 @@ export class DownloadManager {
|
||||
): string | undefined {
|
||||
if (originalUrl?.includes("#")) {
|
||||
const hashPart = originalUrl.split("#")[1];
|
||||
if (hashPart && !hashPart.startsWith("http") && hashPart.includes(".")) {
|
||||
return hashPart;
|
||||
}
|
||||
if (hashPart && !hashPart.startsWith("http")) return hashPart;
|
||||
}
|
||||
|
||||
if (url.includes("#")) {
|
||||
const hashPart = url.split("#")[1];
|
||||
if (hashPart && !hashPart.startsWith("http") && hashPart.includes(".")) {
|
||||
return hashPart;
|
||||
}
|
||||
if (hashPart && !hashPart.startsWith("http")) return hashPart;
|
||||
}
|
||||
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
const pathname = urlObj.pathname;
|
||||
const pathParts = pathname.split("/");
|
||||
const filename = pathParts[pathParts.length - 1];
|
||||
|
||||
if (filename?.includes(".") && filename.length > 0) {
|
||||
return decodeURIComponent(filename);
|
||||
}
|
||||
const filename = urlObj.pathname.split("/").pop();
|
||||
if (filename?.length) return filename;
|
||||
} catch {
|
||||
// Invalid URL
|
||||
}
|
||||
@@ -64,7 +55,7 @@ export class DownloadManager {
|
||||
}
|
||||
|
||||
private static sanitizeFilename(filename: string): string {
|
||||
return filename.replaceAll(/[<>:"/\\|?*]/g, "_");
|
||||
return filename.replace(/[<>:"/\\|?*]/g, "_");
|
||||
}
|
||||
|
||||
private static createDownloadPayload(
|
||||
@@ -73,19 +64,13 @@ export class DownloadManager {
|
||||
downloadId: string,
|
||||
savePath: string
|
||||
) {
|
||||
const filename =
|
||||
this.extractFilename(originalUrl, directUrl) ||
|
||||
this.extractFilename(directUrl);
|
||||
const filename = this.extractFilename(directUrl, originalUrl);
|
||||
const sanitizedFilename = filename
|
||||
? this.sanitizeFilename(filename)
|
||||
: undefined;
|
||||
|
||||
if (sanitizedFilename) {
|
||||
logger.log(`[DownloadManager] Using filename: ${sanitizedFilename}`);
|
||||
} else {
|
||||
logger.log(
|
||||
`[DownloadManager] No filename extracted, aria2 will use default`
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -242,10 +227,10 @@ export class DownloadManager {
|
||||
)
|
||||
) {
|
||||
gameFilesManager.extractDownloadedFile();
|
||||
} else if (download.folderName) {
|
||||
} else {
|
||||
gameFilesManager
|
||||
.extractFilesInDirectory(
|
||||
path.join(download.downloadPath, download.folderName)
|
||||
path.join(download.downloadPath, download.folderName!)
|
||||
)
|
||||
.then(() => gameFilesManager.setExtractionComplete());
|
||||
}
|
||||
|
||||
@@ -130,6 +130,32 @@ export default function Notifications() {
|
||||
return () => unsubscribe();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = window.electron.onSyncNotificationCount(() => {
|
||||
if (userDetails) {
|
||||
fetchApiNotifications(0, false);
|
||||
}
|
||||
fetchLocalNotifications();
|
||||
});
|
||||
|
||||
return () => unsubscribe();
|
||||
}, [userDetails, fetchApiNotifications, fetchLocalNotifications]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleVisibilityChange = () => {
|
||||
if (!document.hidden && userDetails) {
|
||||
fetchApiNotifications(0, false);
|
||||
fetchLocalNotifications();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("visibilitychange", handleVisibilityChange);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||
};
|
||||
}, [userDetails, fetchApiNotifications, fetchLocalNotifications]);
|
||||
|
||||
const mergedNotifications = useMemo<MergedNotification[]>(() => {
|
||||
const sortByDate = (a: MergedNotification, b: MergedNotification) =>
|
||||
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
||||
|
||||
@@ -116,5 +116,6 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user