Skip to content

Conversation

@CranberrySoup
Copy link
Contributor

@CranberrySoup CranberrySoup commented Oct 19, 2025

Changes the whole download system to:

  1. Add a user visible download queue
  2. Migrate away from WorkManager (since it does not work for everyone)
  3. Add instantaneous download button feedback
  4. Add batch downloading

Remaining issues to fix:

  • Batch download button (easy)
  • Fix the resume download button (easy)
  • Add link loading notification (easy)
  • Good download queue UI (hard)
  • Quality assurance

I plan to complete this pull request this week.

updateNotification(context, currentVisualDownloads, currentVisualQueue)

// Arbitrary delay to prevent hogging the CPU, decrease to make the queue feel slightly more responsive
delay(500)
Copy link
Collaborator

@fire-light42 fire-light42 Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a condition variable. Unfortunately the built in synchronization primatives are built for Java threading, and not the kotlin coroutines.

The fix for this would be something like:

val conditionSignal = CompletableDeferred<Unit>()

// ...

select {
    onTimeout(500) {
        println("Waited")
    }
    conditionSignal.onAwait {
        println("Skipped waiting")
    }
}

Select simply awaits the fastest execution. So you can conditionSignal.complete(Unit) to skip the 500ms delay. If you implement this correctly you can do a timeout of 10s or something similar.

startForeground(DOWNLOAD_QUEUE_NOTIFICATION_ID, baseNotification.build())
}

val context = this.applicationContext
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a context, I do not understand why it needs to be applicationContext

.data(url)
.apply {
headers?.forEach { (key, value) ->
extras[Extras.Key<String>(key)] = value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headerBuilder["User-Agent"] = USER_AGENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants