From a521e66435f736208db2450bd8cdb5b48b7fd540 Mon Sep 17 00:00:00 2001 From: Christian Sadilek Date: Tue, 26 May 2020 17:44:16 -0400 Subject: [PATCH] Closes #7103 #5217: Move queued download state to browser store --- .../browser/state/reducer/DownloadStateReducer.kt | 11 +++++++++++ .../browser/state/action/DownloadActionTest.kt | 3 +++ .../feature/downloads/AbstractFetchDownloadService.kt | 3 +++ .../downloads/AbstractFetchDownloadServiceTest.kt | 3 +++ .../org/mozilla/samples/browser/DefaultComponents.kt | 4 ++++ 5 files changed, 24 insertions(+) diff --git a/components/browser/state/src/main/java/mozilla/components/browser/state/reducer/DownloadStateReducer.kt b/components/browser/state/src/main/java/mozilla/components/browser/state/reducer/DownloadStateReducer.kt index e33476ba67a..6919582d1ec 100644 --- a/components/browser/state/src/main/java/mozilla/components/browser/state/reducer/DownloadStateReducer.kt +++ b/components/browser/state/src/main/java/mozilla/components/browser/state/reducer/DownloadStateReducer.kt @@ -6,7 +6,10 @@ package mozilla.components.browser.state.reducer import mozilla.components.browser.state.action.DownloadAction import mozilla.components.browser.state.state.BrowserState +<<<<<<< HEAD import mozilla.components.browser.state.state.content.DownloadState +======= +>>>>>>> Closes #7103 #5217: Move queued download state to browser store internal object DownloadStateReducer { @@ -15,9 +18,14 @@ internal object DownloadStateReducer { */ fun reduce(state: BrowserState, action: DownloadAction): BrowserState { return when (action) { +<<<<<<< HEAD is DownloadAction.QueueDownloadAction -> updateQueuedDownloads(state, action.download) is DownloadAction.UpdateQueuedDownloadAction -> { updateQueuedDownloads(state, action.download) +======= + is DownloadAction.QueueDownloadAction -> { + state.copy(queuedDownloads = state.queuedDownloads + (action.download.id to action.download)) +>>>>>>> Closes #7103 #5217: Move queued download state to browser store } is DownloadAction.RemoveQueuedDownloadAction -> { state.copy(queuedDownloads = state.queuedDownloads - action.downloadId) @@ -27,7 +35,10 @@ internal object DownloadStateReducer { } } } +<<<<<<< HEAD private fun updateQueuedDownloads(state: BrowserState, download: DownloadState) = state.copy(queuedDownloads = state.queuedDownloads + (download.id to download)) +======= +>>>>>>> Closes #7103 #5217: Move queued download state to browser store } diff --git a/components/browser/state/src/test/java/mozilla/components/browser/state/action/DownloadActionTest.kt b/components/browser/state/src/test/java/mozilla/components/browser/state/action/DownloadActionTest.kt index c85f4feb441..19e2c7ad06a 100644 --- a/components/browser/state/src/test/java/mozilla/components/browser/state/action/DownloadActionTest.kt +++ b/components/browser/state/src/test/java/mozilla/components/browser/state/action/DownloadActionTest.kt @@ -58,6 +58,7 @@ class DownloadActionTest { store.dispatch(DownloadAction.RemoveAllQueuedDownloadsAction).joinBlocking() assertTrue(store.state.queuedDownloads.isEmpty()) } +<<<<<<< HEAD @Test fun `UpdateQueuedDownloadAction updates the provided download`() { @@ -76,4 +77,6 @@ class DownloadActionTest { assertEquals(2, store.state.queuedDownloads.size) assertEquals(updatedDownload, store.state.queuedDownloads[updatedDownload.id]) } +======= +>>>>>>> Closes #7103 #5217: Move queued download state to browser store } diff --git a/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/AbstractFetchDownloadService.kt b/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/AbstractFetchDownloadService.kt index a4c3cf0ca3e..fbad79bc4c1 100644 --- a/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/AbstractFetchDownloadService.kt +++ b/components/feature/downloads/src/main/java/mozilla/components/feature/downloads/AbstractFetchDownloadService.kt @@ -55,7 +55,10 @@ import mozilla.components.feature.downloads.AbstractFetchDownloadService.Downloa import mozilla.components.feature.downloads.AbstractFetchDownloadService.DownloadJobStatus.PAUSED import mozilla.components.feature.downloads.DownloadNotification.NOTIFICATION_DOWNLOAD_GROUP_ID import mozilla.components.feature.downloads.ext.addCompletedDownload +<<<<<<< HEAD import mozilla.components.feature.downloads.ext.isScheme +======= +>>>>>>> Closes #7103 #5217: Move queued download state to browser store import mozilla.components.feature.downloads.ext.withResponse import mozilla.components.feature.downloads.facts.emitNotificationResumeFact import mozilla.components.feature.downloads.facts.emitNotificationPauseFact diff --git a/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt b/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt index b1677ed1458..e241241665a 100644 --- a/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt +++ b/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt @@ -4,7 +4,10 @@ package mozilla.components.feature.downloads +<<<<<<< HEAD import android.app.DownloadManager +======= +>>>>>>> Closes #7103 #5217: Move queued download state to browser store import android.app.DownloadManager.EXTRA_DOWNLOAD_ID import android.app.Notification import android.app.NotificationManager diff --git a/samples/browser/src/main/java/org/mozilla/samples/browser/DefaultComponents.kt b/samples/browser/src/main/java/org/mozilla/samples/browser/DefaultComponents.kt index 8690cf6d6be..1092dc62c1b 100644 --- a/samples/browser/src/main/java/org/mozilla/samples/browser/DefaultComponents.kt +++ b/samples/browser/src/main/java/org/mozilla/samples/browser/DefaultComponents.kt @@ -120,8 +120,12 @@ open class DefaultComponents(private val applicationContext: Context) { BrowserStore(middleware = listOf( MediaMiddleware(applicationContext, MediaService::class.java), DownloadMiddleware(applicationContext, DownloadService::class.java), +<<<<<<< HEAD ReaderViewMiddleware(), ThumbnailsMiddleware(thumbnailStorage) +======= + ReaderViewMiddleware() +>>>>>>> Closes #7103 #5217: Move queued download state to browser store )) }