convert to map and remove shift param
This commit is contained in:
parent
491a00fd84
commit
98df153750
1 changed files with 10 additions and 14 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue