Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit 9c8827f

Browse files
author
codrut.topliceanu
committed
For #7364 - Adds sessionId to DownloadState and populates it in DownloadFeature
1 parent 7cb2889 commit 9c8827f

File tree

2 files changed

+6
-4
lines changed
  • components
    • browser/state/src/main/java/mozilla/components/browser/state/state/content
    • feature/downloads/src/main/java/mozilla/components/feature/downloads

2 files changed

+6
-4
lines changed

components/browser/state/src/main/java/mozilla/components/browser/state/state/content/DownloadState.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import kotlin.random.Random
2222
* @property referrerUrl The site that linked to this download.
2323
* @property skipConfirmation Whether or not the confirmation dialog should be shown before the download begins.
2424
* @property id The unique identifier of this download.
25+
* @property sessionId Identifier of the session that spawned the download.
26+
* @
2527
*/
2628
@Suppress("Deprecation")
2729
@Parcelize
@@ -34,7 +36,8 @@ data class DownloadState(
3436
val destinationDirectory: String = Environment.DIRECTORY_DOWNLOADS,
3537
val referrerUrl: String? = null,
3638
val skipConfirmation: Boolean = false,
37-
val id: Long = Random.nextLong()
39+
val id: Long = Random.nextLong(),
40+
val sessionId: String? = null
3841
) : Parcelable {
3942
val filePath: String get() =
4043
Environment.getExternalStoragePublicDirectory(destinationDirectory).path + "/" + fileName

components/feature/downloads/src/main/java/mozilla/components/feature/downloads/DownloadsFeature.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ class DownloadsFeature(
9393
flow.mapNotNull { state -> state.findTabOrCustomTabOrSelectedTab(tabId) }
9494
.ifChanged { it.content.download }
9595
.collect { state ->
96-
val download = state.content.download
97-
if (download != null) {
98-
processDownload(state, download)
96+
state.content.download?.let { downloadState ->
97+
processDownload(state, downloadState.copy(sessionId = state.id))
9998
}
10099
}
101100
}

0 commit comments

Comments
 (0)