Skip to content

Bug 2036011 - Support cancellation for Bookmarks importing#241

Closed
segunfamisa wants to merge 1 commit intomozilla-firefox:autolandfrom
segunfamisa:bookmarks/cancel
Closed

Bug 2036011 - Support cancellation for Bookmarks importing#241
segunfamisa wants to merge 1 commit intomozilla-firefox:autolandfrom
segunfamisa:bookmarks/cancel

Conversation

@segunfamisa
Copy link
Copy Markdown
Contributor

No description provided.

@segunfamisa
Copy link
Copy Markdown
Contributor Author

@github-actions
Copy link
Copy Markdown
Contributor

Warning

The base branch is currently set to main. Please Edit this PR and set the base to autoland.

@github-actions
Copy link
Copy Markdown
Contributor

View this pull request in Lando to land it once approved.

@segunfamisa segunfamisa changed the base branch from main to autoland April 30, 2026 09:47
@segunfamisa
Copy link
Copy Markdown
Contributor Author

View this pull request in Lando to land it once approved.

Correct lando link: https://lando.moz.tools/pulls/firefox-autoland/241

Comment on lines +43 to +50
val minimumWait = async { delay(1.seconds) }
val result = async { importer.importBookmarksFromUri(action.uri) }

// We want to make sure we stay in the loading state for at least one second
// during an import to prevent the dialog from flashing before the user can
// comprehend what is currently happening.
val minimumWait = async { delay(1.seconds) }
val result = async { importer.importBookmarksFromUri(action.uri) }
awaitAll(minimumWait, result)

awaitAll(minimumWait, result)
result.await()
.onFailure { store.dispatch(ImporterAction.ImportFailed) }
.onSuccess { store.dispatch(ImporterAction.ImportFinished(it.count)) }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this block will play well with cancellation, because if the insertion completed earlier than 1s, there's nothing to cancel.

I think it's a very short window, so I hope it's not going to be a frequent edge case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this ok. It's very easy to delete the folder after the import if they want to.

*/
@OptIn(ExperimentalStdlibApi::class)
internal val CoroutineScope.dispatcher: CoroutineDispatcher
get() = coroutineContext[CoroutineDispatcher] ?: Dispatchers.IO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ooo TIL, ty!

# Conflicts:
#	mobile/android/android-components/components/lib/bookmarks-file/src/test/java/mozilla/components/lib/bookmarks/file/HtmlBookmarksFileImporterTest.kt
@segunfamisa
Copy link
Copy Markdown
Contributor Author

Running another try after rebasingn & resolving conflicts: https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=42048

lando-worker Bot pushed a commit that referenced this pull request May 4, 2026
@lando-worker
Copy link
Copy Markdown

lando-worker Bot commented May 4, 2026

Pull request closed by commit 0732687

@lando-worker lando-worker Bot closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants