mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
Fix bugs related to getDisplayMedia API (screen sharing) (#83)
This commit is contained in:
parent
4f1fa2c061
commit
19131b1a48
2 changed files with 26 additions and 21 deletions
|
|
@ -43,7 +43,7 @@ const create = (viewId) => {
|
|||
win.removeListener('close', onClose);
|
||||
win.close();
|
||||
};
|
||||
ipcMain.on('display-media-selected', onSelected);
|
||||
ipcMain.once('display-media-selected', onSelected);
|
||||
|
||||
win.on('closed', () => {
|
||||
win = null;
|
||||
|
|
|
|||
|
|
@ -45,35 +45,40 @@ class DisplayMedia extends React.Component {
|
|||
const { sources } = this.state;
|
||||
const { classes } = this.props;
|
||||
|
||||
const screenSources = sources.filter((source) => source.id.startsWith('screen'));
|
||||
const windowSources = sources.filter((source) => source.id.startsWith('window'));
|
||||
// remove first item as it is the display media window itself
|
||||
windowSources.shift();
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Typography variant="body1" className={classes.text}>
|
||||
The app wants to use the contents of your screen. Choose what you’d like to share.
|
||||
</Typography>
|
||||
<List>
|
||||
{sources.map((source) => source.id.startsWith('screen') && (
|
||||
<ListItem
|
||||
button
|
||||
onClick={() => {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('display-media-selected', source.id);
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={source.name} />
|
||||
</ListItem>
|
||||
{screenSources.map((source) => (
|
||||
<ListItem
|
||||
button
|
||||
onClick={() => {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('display-media-selected', source.id);
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={source.name} />
|
||||
</ListItem>
|
||||
))}
|
||||
<Divider />
|
||||
<ListSubheader disableSticky>Windows</ListSubheader>
|
||||
{sources.map((source) => !source.id.startsWith('screen') && (
|
||||
<ListItem
|
||||
button
|
||||
onClick={() => {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('display-media-selected', source.id);
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={source.name} />
|
||||
</ListItem>
|
||||
{windowSources.map((source) => (
|
||||
<ListItem
|
||||
button
|
||||
onClick={() => {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('display-media-selected', source.id);
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={source.name} />
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue