Skip to content

Conversation

@Bilal-Ahmad123
Copy link
Contributor

@Bilal-Ahmad123 Bilal-Ahmad123 commented Nov 29, 2025

1- Previously a coroutine was executed which imported watch history from youtube but there was no way to know the status of the import history i have a added a coroutine worker whose job is to import the watch history with a foreground notification.

2- I have also added dagger hilt in order to inject dependencies. I could have used other approaches but that wouldnt have been a clean solution

3- For now only watch history is being imported through coroutine worker. The reason is that we are inserting watch item one by one but for subscriptions one complete list is inserted which makes it nearly impossible to know the status of those imports however i will still look for a way to achieve that and for playlists too

Bug #7907

@Bilal-Ahmad123
Copy link
Contributor Author

If someone wants i can add an ongoing notification for subscription and playlist imports however that will not be able to tell how much content to import has been left

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

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

I generally think that the idea of putting the import work into a dedicated worker goes into the right direction, thanks for proposing.

However, we decided to not add Dagger/Hilt as a dependency, so please refactor your PR to work without it.

Apart from that I left some comments, please have a look at them. Without willing to attack you personally, this code looks a bit AI-generated .

We don't accept contributions that add much additional code that was AI-generated here. So please clarify that this is not the case or rewrite the AI-generated parts as we don't have any permission to license code that was stolen from other projects as GPL3.

}


private val notificationChannelId = "DemoNotificationChannelId"
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

@Bilal-Ahmad123 Bilal-Ahmad123 Dec 8, 2025

Choose a reason for hiding this comment

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

I was working on another project called Kotatsu the approach of pausing and resuming the Work manager is where i got this from.

If you want i can write my own logic for pausing and resuming the work manager i am just afraid that my solution might now be better than theirs

Copy link
Member

Choose a reason for hiding this comment

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

The question is about whether you call it DemoNotificationChannelId, that looks like it's copied from somewhere else without adapting it to our app.

Copy link
Contributor Author

@Bilal-Ahmad123 Bilal-Ahmad123 Dec 8, 2025

Choose a reason for hiding this comment

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

Yeah the name was actually copied
Sorry about that

Copy link
Contributor Author

@Bilal-Ahmad123 Bilal-Ahmad123 Dec 13, 2025

Choose a reason for hiding this comment

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

AI code removed, Dagger hilt removed

private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

val notificationChannel = NotificationChannel(
Copy link
Member

Choose a reason for hiding this comment

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

Please use NotificationChannelCompat instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will refactor it to use NotificationChannelCompat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change has now been made to use NotificationChannelCompat

get() = cancel.value

fun pause() {
paused.value = true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
paused.value = true
paused.emit(true)

same below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Problem here is that emit is a suspending function which must be called from another suspending function or a coroutine and i am calling it from a broadcast reciever method OnRecieve which is not a suspending function

Comment on lines 122 to 124
NotificationManagerCompat.IMPORTANCE_DEFAULT
).setName("Import Worker")
.setDescription("Shows a notification when importing")
Copy link
Member

Choose a reason for hiding this comment

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

These should be translatable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now moved to string.xml

if (finalState == 0) 0 else ((currentState.toFloat() / finalState) * 100).toInt()
builder.setContentText("$percent% completed")
builder.setProgress(finalState, currentState, false)
builder.clearActions()
Copy link
Member

Choose a reason for hiding this comment

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

that's a noop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shows the percentage of watch history that has been imported

) : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val id = intent?.getStringExtra(EXTRA_UUID)
val parsedId: UUID? = try {
Copy link
Member

Choose a reason for hiding this comment

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

Why do you use UUIDs instead of incrementing integer IDs like everywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose a user imports one watch history file and closes the app than again open up the app to import another watch history file than in thjat case there will be no way of knowing what the previous id was thats why i have used UUID

@Bilal-Ahmad123
Copy link
Contributor Author

Bilal-Ahmad123 commented Dec 12, 2025

@Bnyro do i need to rewrite the other code as well by that i meant the pausing handler since thats not AI generated the only Ai generated one is the notification part that too is in much smaller portion not all of it was Ai generated so please clarify

@Bnyro
Copy link
Member

Bnyro commented Dec 12, 2025

Only the AI generated code.

@Bilal-Ahmad123
Copy link
Contributor Author

okay i will be rewriting it

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.

3 participants