Skip to content

Commit

Permalink
Refactor update logic for yt-dlp installation and version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Jan 26, 2025
1 parent 6c3855f commit f189861
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions desktop/src/pages/home/viewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ export function viewModel() {
const isUpToDate = config.ytDlpVersion === preference.ytDlpVersion
const exists = await ytDlp.exists()
if (!exists || (!isUpToDate && preference.shouldCheckYtDlpVersion)) {
let shouldInstall = false
let shouldInstallOrUpdate = false
if (!isUpToDate) {
shouldInstall = await dialog.ask(t('common.ask-for-update-ytdlp-message'), {
shouldInstallOrUpdate = await dialog.ask(t('common.ask-for-update-ytdlp-message'), {
title: t('common.ask-for-update-ytdlp-title'),
kind: 'info',
cancelLabel: t('common.later'),
okLabel: t('common.update-now'),
})
} else {
shouldInstall = await dialog.ask(t('common.ask-for-install-ytdlp-message'), {
shouldInstallOrUpdate = await dialog.ask(t('common.ask-for-install-ytdlp-message'), {
title: t('common.ask-for-install-ytdlp-title'),
kind: 'info',
cancelLabel: t('common.cancel'),
okLabel: t('common.install-now'),
})
}

if (shouldInstall) {
if (shouldInstallOrUpdate) {
try {
toast.setMessage(t('common.downloading-ytdlp'))
toast.setProgress(0)
Expand All @@ -130,9 +130,10 @@ export function viewModel() {
preference.setHomeTabIndex(2)
} catch (e) {
console.error(e)

setErrorModal?.({ log: String(e), open: true })
}
} else if (exists) {
preference.setHomeTabIndex(2)
}
} else {
preference.setHomeTabIndex(2)
Expand Down

0 comments on commit f189861

Please sign in to comment.