Compare commits

..

6 Commits

Author SHA1 Message Date
Moyasee
91adb97013 refactor: improve code formatting and consistency in DownloadManager 2025-12-27 02:50:27 +02:00
Chubby Granny Chaser
f138b2efcb Merge pull request #1906 from Wkeynhk/main
Buzzheavier fix
2025-12-27 00:47:44 +00:00
Wkeynhk
991aa05760 Sonar fix2 2025-12-27 03:23:36 +03:00
Wkeynhk
aff9e13bca Sonar fix 2025-12-27 03:17:42 +03:00
Wkeynhk
240a75c1d0 Buzzheavier fix 2025-12-27 03:02:35 +03:00
Chubby Granny Chaser
edbe86a1fb Merge pull request #1904 from hydralauncher/feat/LBX-155
fix: notification item styling
2025-12-26 22:54:13 +00:00
3 changed files with 23 additions and 35 deletions

View File

@@ -35,18 +35,27 @@ export class DownloadManager {
): string | undefined {
if (originalUrl?.includes("#")) {
const hashPart = originalUrl.split("#")[1];
if (hashPart && !hashPart.startsWith("http")) return hashPart;
if (hashPart && !hashPart.startsWith("http") && hashPart.includes(".")) {
return hashPart;
}
}
if (url.includes("#")) {
const hashPart = url.split("#")[1];
if (hashPart && !hashPart.startsWith("http")) return hashPart;
if (hashPart && !hashPart.startsWith("http") && hashPart.includes(".")) {
return hashPart;
}
}
try {
const urlObj = new URL(url);
const filename = urlObj.pathname.split("/").pop();
if (filename?.length) return filename;
const pathname = urlObj.pathname;
const pathParts = pathname.split("/");
const filename = pathParts[pathParts.length - 1];
if (filename?.includes(".") && filename.length > 0) {
return decodeURIComponent(filename);
}
} catch {
// Invalid URL
}
@@ -55,7 +64,7 @@ export class DownloadManager {
}
private static sanitizeFilename(filename: string): string {
return filename.replace(/[<>:"/\\|?*]/g, "_");
return filename.replaceAll(/[<>:"/\\|?*]/g, "_");
}
private static createDownloadPayload(
@@ -64,13 +73,19 @@ export class DownloadManager {
downloadId: string,
savePath: string
) {
const filename = this.extractFilename(directUrl, originalUrl);
const filename =
this.extractFilename(originalUrl, directUrl) ||
this.extractFilename(directUrl);
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 {
@@ -227,10 +242,10 @@ export class DownloadManager {
)
) {
gameFilesManager.extractDownloadedFile();
} else {
} else if (download.folderName) {
gameFilesManager
.extractFilesInDirectory(
path.join(download.downloadPath, download.folderName!)
path.join(download.downloadPath, download.folderName)
)
.then(() => gameFilesManager.setExtractionComplete());
}

View File

@@ -130,32 +130,6 @@ 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();

View File

@@ -116,6 +116,5 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
}
}