Created
April 22, 2018 22:27
-
-
Save a-one-d-one/2863bcf0680278bbea0525cbd8a13292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getDownloadItems = (state) => { | |
if (!state || !state.get('downloads')) { | |
return Immutable.List() | |
} | |
const downloadsSize = state.get('downloads').size | |
const downloadItemWidth = domUtil.getStyleConstants('download-item-width') | |
const downloadItemMargin = domUtil.getStyleConstants('download-item-margin') | |
const downloadBarPadding = domUtil.getStyleConstants('download-bar-padding') | |
const downloadBarButtons = domUtil.getStyleConstants('download-bar-buttons') | |
const numItems = Math.floor( | |
(window.innerWidth - (downloadBarPadding * 2) - downloadBarButtons) / | |
(downloadItemWidth + downloadItemMargin) | |
) | |
return state.get('downloads') | |
.sort((x, y) => x.get('startTime') - y.get('startTime')) | |
.skip(downloadsSize - numItems) | |
.reverse() | |
.map((download, downloadId) => downloadId) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment