Debian Codegraph @

addons/mail/static/src/discuss/call/common/call_permission_dialog.js

raw symbols SCIP
1 import { Component } from "@odoo/owl";
2 import { Dialog } from "@web/core/dialog/dialog";
3
4 import { _t } from "@web/core/l10n/translation";
5 import { useService } from "@web/core/utils/hooks";
6
7 export class CallPermissionDialog extends Component {
8 static components = { Dialog };
9 static props = {
10 close: Function,
11 media: {
12 type: String,
13 validate: (s) => ["camera", "microphone"].includes(s),
14 },
15 useMicrophone: Function,
16 useCamera: Function,
17 };
18 static template = "discuss.CallPermissionDialog";
19
20 setup() {
21 this.rtc = useService("discuss.rtc");
22 }
23
24 async onClickUseMicrophone() {
25 if (await this.rtc.askForBrowserPermission({ audio: true })) {
26 await this.props.useMicrophone();
27 }
28 this.props.close();
29 }
30
31 async onClickUseCamera() {
32 if (await this.rtc.askForBrowserPermission({ video: true })) {
33 await this.props.useCamera();
34 }
35 this.props.close();
36 }
37
38 async onClickUseMicAndCamera() {
39 if (await this.rtc.askForBrowserPermission({ audio: true, video: true })) {
40 await Promise.all([this.props.useMicrophone(), this.props.useCamera()]);
41 }
42 this.props.close();
43 }
44
45 get primaryActionText() {
46 return this.props.media === "camera" ? _t("Use Camera") : _t("Use Microphone");
47 }
48
49 get permissionPrompt() {
50 if (this.props.media === "microphone") {
51 return _t("Do you want people to hear you in the meeting?");
52 }
53 return _t("Do you want people to see you in the meeting?");
54 }
55
56 get permissionNote() {
57 return _t("You can still turn off your %s anytime.", this.props.media);
58 }
59 }