Created
April 23, 2018 01:34
-
-
Save a-one-d-one/af3cf04bfe098145aab3a033ed9be003 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) => { | |
const isPrivate = state.get('currentWindow') | |
.get('frames') | |
.get('0') | |
.get('isPrivate') | |
if (!isPrivate) { | |
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