Skip to content

Downloading update notification#433

Open
TJMolina wants to merge 3 commits intoLagradOst:masterfrom
TJMolina:inappupdt
Open

Downloading update notification#433
TJMolina wants to merge 3 commits intoLagradOst:masterfrom
TJMolina:inappupdt

Conversation

@TJMolina
Copy link
Copy Markdown
Contributor

Added in-app update notifications with progress tracking and refactored NotificationHelper to support general-purpose notification creation.

  • In-App Updater: Added download progress tracking (BPS, ETA) and integrated with NotificationHelper to show update status.
  • NotificationHelper: Refactored createNotification to be more modular, allowing its use for both book downloads and app updates.
  • BookDownloader2: Improved error handling with additional try-catch blocks and simplified notification logic.
  • General: Added a volatile check to prevent multiple concurrent update downloads.

…ed `NotificationHelper` to support general-purpose notification creation.

- **In-App Updater**: Added download progress tracking (BPS, ETA) and integrated with `NotificationHelper` to show update status.
- **NotificationHelper**: Refactored `createNotification` to be more modular, allowing its use for both book downloads and app updates.
- **BookDownloader2**: Improved error handling with additional `try-catch` blocks and simplified notification logic.
- **General**: Added a volatile check to prevent multiple concurrent update downloads.
Copy link
Copy Markdown
Owner

@LagradOst LagradOst left a comment

Choose a reason for hiding this comment

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

Good change, but it has some bugs that should be fixed before merging.

runBlocking {
NotificationHelper.createNotification(
context = this@downloadUpdate,
source = url,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Source is meant to be in app actions, and should be null. You need to change the signature of createNotification for that.

}
} finally {
}
catch(t: Throwable){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove.

val extraText = if (stateProgressState.total > 1) {
val unit = if (progressInBytes) "Kb" else ""
val div = if (progressInBytes) 1024 else 1
"${stateProgressState.progress / div} $unit / ${stateProgressState.total / div} $unit"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This adds an extra space.

val unit = if (progressInBytes) "Kb" else ""
val div = if (progressInBytes) 1024 else 1
"${stateProgressState.progress / div} $unit / ${stateProgressState.total / div} $unit"
} else ""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No download progress for full files.

}

logError(t)
changeDownload(id) { state = DownloadState.IsFailed }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should be moved to before setSuffixData

}
}

} catch(t: Throwable){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

How can this even throw something to catch?

output.flush()
output.close()
input.close()
runBlocking {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

if you have showNotification = false then nothing will be shown?

…efined progress text formatting and removed redundant error catching.
…nload state is updated before setting suffix data.
@TJMolina
Copy link
Copy Markdown
Contributor Author

Done

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