mirror of
https://github.com/rhysd/Mstdn.git
synced 2025-01-21 20:52:11 +01:00
request user's permission for 'media' and 'geolocation'
This commit is contained in:
parent
16b224d973
commit
7fa8cdac10
@ -8,7 +8,7 @@ Features:
|
||||
- [x] Small window on your menubar (or isolated window)
|
||||
- [x] Desktop notification
|
||||
- [x] Customizable shortcut keybinds
|
||||
- [ ] Multi-account
|
||||
- [ ] Multi-account (switching among accounts)
|
||||
|
||||
Mastodon is an open source project. So if you want to make a new UI, you can just fork the project,
|
||||
implement your favorite UI and host it on your place. Then you can participate Mastodon networks from it.
|
||||
|
21
main/app.ts
21
main/app.ts
@ -1,5 +1,5 @@
|
||||
import * as path from 'path';
|
||||
import {app, BrowserWindow, globalShortcut, Tray, shell} from 'electron';
|
||||
import {app, BrowserWindow, globalShortcut, Tray, shell, dialog} from 'electron';
|
||||
import windowState = require('electron-window-state');
|
||||
import * as menubar from 'menubar';
|
||||
import log from './log';
|
||||
@ -23,6 +23,7 @@ export class App {
|
||||
}
|
||||
|
||||
open() {
|
||||
this.win.loadURL(`https://${this.account.host}${this.account.default_page}`);
|
||||
this.win.webContents.on('will-navigate', (e, url) => {
|
||||
if (!url.startsWith(`https://${this.account.host}`)) {
|
||||
e.preventDefault();
|
||||
@ -33,7 +34,23 @@ export class App {
|
||||
e.preventDefault();
|
||||
shell.openExternal(url);
|
||||
});
|
||||
this.win.loadURL(`https://${this.account.host}${this.account.default_page}`);
|
||||
this.win.webContents.session.setPermissionRequestHandler((contents, permission, callback) => {
|
||||
if (permission !== 'geolocation' && permission !== 'media') {
|
||||
// Granted
|
||||
callback(true);
|
||||
return;
|
||||
}
|
||||
|
||||
dialog.showMessageBox({
|
||||
type: 'question',
|
||||
buttons: ['Accept', 'Reject'],
|
||||
message: `Permission '${permission}' is requested by ${contents.getURL()}`,
|
||||
detail: "Please choose one of 'Accept' or 'Reject'",
|
||||
}, (buttonIndex: number) => {
|
||||
const granted = buttonIndex === 0;
|
||||
callback(granted);
|
||||
});
|
||||
});
|
||||
this.win.show();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user