diff --git a/src/renderer/src/pages/game-details/modals/download-settings-modal.scss b/src/renderer/src/pages/game-details/modals/download-settings-modal.scss index d935daf9..75add6d3 100644 --- a/src/renderer/src/pages/game-details/modals/download-settings-modal.scss +++ b/src/renderer/src/pages/game-details/modals/download-settings-modal.scss @@ -52,11 +52,6 @@ } } - &__recommendation-badge { - margin-left: calc(globals.$spacing-unit); - font-size: 10px; - } - &__downloader-item { display: flex; align-items: center; diff --git a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx index f9dc6fa0..9e3802e1 100644 --- a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx @@ -119,6 +119,17 @@ export function DownloadSettingsModal({ (value) => typeof value === "number" ) as Downloader[]; + const getDownloaderPriority = (option: { + isAvailable: boolean; + canHandle: boolean; + isAvailableButNotConfigured: boolean; + }) => { + if (option.isAvailable) return 0; + if (option.canHandle && !option.isAvailableButNotConfigured) return 1; + if (option.isAvailableButNotConfigured) return 2; + return 3; + }; + return allDownloaders .filter((downloader) => downloader !== Downloader.Hydra) // Temporarily comment out Nimbus .map((downloader) => { @@ -146,41 +157,7 @@ export function DownloadSettingsModal({ isAvailableButNotConfigured, }; }) - .sort((a, b) => { - if (a.isAvailable && !b.isAvailable) return -1; - if (!a.isAvailable && b.isAvailable) return 1; - if ( - a.canHandle && - !a.isAvailable && - !a.isAvailableButNotConfigured && - !b.canHandle - ) - return -1; - if ( - !a.canHandle && - b.canHandle && - !b.isAvailable && - !b.isAvailableButNotConfigured - ) - return 1; - if (a.isAvailableButNotConfigured && !b.canHandle) return -1; - if (!a.canHandle && b.isAvailableButNotConfigured) return 1; - if ( - a.isAvailableButNotConfigured && - b.canHandle && - !b.isAvailable && - !b.isAvailableButNotConfigured - ) - return 1; - if ( - !a.isAvailableButNotConfigured && - a.canHandle && - !a.isAvailable && - b.isAvailableButNotConfigured - ) - return -1; - return 0; - }); + .sort((a, b) => getDownloaderPriority(a) - getDownloaderPriority(b)); }, [ repack, userPreferences?.realDebridApiToken, @@ -292,6 +269,90 @@ export function DownloadSettingsModal({ !option.canHandle || (!option.isAvailable && !option.isAvailableButNotConfigured); + const getAvailabilityIndicator = () => { + if (option.isAvailable) { + return ( + + ); + } + + if (option.isAvailableButNotConfigured) { + return ( + + ); + } + + if (option.canHandle) { + return ( + + ); + } + + return ( + + ); + }; + + const getRightContent = () => { + if (isSelected) { + return ( + + + + ); + } + + if ( + option.downloader === Downloader.RealDebrid && + option.canHandle + ) { + return ( +
+ {t("recommended")} +
+ ); + } + + return null; + }; + return (
- {option.isAvailable ? ( - - ) : option.isAvailableButNotConfigured ? ( - - ) : option.canHandle ? ( - - ) : ( - - )} + {getAvailabilityIndicator()}
- {isSelected ? ( - - - - ) : option.downloader === Downloader.RealDebrid && - option.canHandle ? ( -
- {t("recommended")} -
- ) : null} + {getRightContent()}
);