convert to map and remove shift param

This commit is contained in:
Shelley Vohr 2017-10-24 15:47:09 -04:00
parent 491a00fd84
commit 98df153750
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -36,24 +36,20 @@ ipcMain.on(electronSources, (event, captureWindow, captureScreen, thumbnailSize,
desktopCapturer.emit = (event, name, sources) => {
// Receiving sources result from main process, now send them back to renderer.
const handledRequest = requestsQueue.shift(0)
const handledRequest = requestsQueue.shift()
const handledWebContents = handledRequest.webContents
const unhandledRequestsQueue = []
const result = () => {
const results = []
sources.forEach(source => {
results.push({
id: source.id,
name: source.name,
thumbnail: source.thumbnail.toDataURL()
})
})
return results
}
const result = sources.map(source => {
return {
id: source.id,
name: source.name,
thumbnail: source.thumbnail.toDataURL()
}
})
if (handledWebContents != null) {
handledWebContents.send(capturerResult(handledRequest.id), result())
handledWebContents.send(capturerResult(handledRequest.id), result)
}
// Check the queue to see whether there is other same request. If has, handle
@ -63,7 +59,7 @@ desktopCapturer.emit = (event, name, sources) => {
const webContents = request.webContents
if (deepEqual(handledRequest.options, request.options)) {
if (webContents != null) {
webContents.send(capturerResult(request.id), result())
webContents.send(capturerResult(request.id), result)
}
} else {
unhandledRequestsQueue.push(request)