Fix always passing the first result to renderer when the API is called multiple
time at once.
This commit is contained in:
parent
fb4efec55d
commit
9c861b9ad3
2 changed files with 11 additions and 7 deletions
|
@ -1,9 +1,13 @@
|
|||
ipc = require 'ipc'
|
||||
NativeImage = require 'native-image'
|
||||
|
||||
nextId = 0
|
||||
getNextId = -> ++nextId
|
||||
|
||||
getSources = (options, callback) ->
|
||||
ipc.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options
|
||||
ipc.once 'ATOM_RENDERER_DESKTOP_CAPTURER_RESULT', (error_message, sources) ->
|
||||
id = getNextId()
|
||||
ipc.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, id
|
||||
ipc.once "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{id}", (error_message, sources) ->
|
||||
error = if error_message then Error error_message else null
|
||||
callback error, ({id: source.id, name: source.name, thumbnail: NativeImage.createFromDataUrl source.thumbnail} for source in sources)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue