Skip to content

Commit

Permalink
Closes mozilla-mobile#7103 mozilla-mobile#5217: Move queued download …
Browse files Browse the repository at this point in the history
…state to browser store
  • Loading branch information
csadilek authored and Vishwa-Mozilla committed Jun 12, 2020
1 parent 4df1ee8 commit a521e66
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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)
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class DownloadActionTest {
store.dispatch(DownloadAction.RemoveAllQueuedDownloadsAction).joinBlocking()
assertTrue(store.state.queuedDownloads.isEmpty())
}
<<<<<<< HEAD

@Test
fun `UpdateQueuedDownloadAction updates the provided download`() {
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
))
}

Expand Down

0 comments on commit a521e66

Please sign in to comment.