diff --git a/addons/mail/static/src/models/media_preview/media_preview.js b/addons/mail/static/src/models/media_preview/media_preview.js
index 19840346274..b95ae62d672 100644
--- a/addons/mail/static/src/models/media_preview/media_preview.js
+++ b/addons/mail/static/src/models/media_preview/media_preview.js
@@ -164,12 +164,22 @@ function factory(dependencies) {
audioStream: attr({
default: null,
}),
+ /**
+ * States whether the browser has the required APIs for
+ * microphone/camera recording.
+ */
doesBrowserSupportMediaDevices: attr({
compute: '_computeDoesBrowserSupportMediaDevices',
}),
+ /**
+ * States if the user's microphone is currently recording.
+ */
isMicrophoneEnabled: attr({
compute: '_computeIsMicrophoneEnabled',
}),
+ /**
+ * States if the user's camera is currently recording.
+ */
isVideoEnabled: attr({
compute: '_computeIsVideoEnabled',
}),
diff --git a/addons/mail/static/src/models/welcome_view/welcome_view.js b/addons/mail/static/src/models/welcome_view/welcome_view.js
index 1b1f4620c85..fc63651ee0b 100644
--- a/addons/mail/static/src/models/welcome_view/welcome_view.js
+++ b/addons/mail/static/src/models/welcome_view/welcome_view.js
@@ -78,7 +78,7 @@ function factory(dependencies) {
if (this.messaging.currentGuest) {
await this.messaging.models['mail.welcome_view'].updateGuestNameServerSide(this.pendingGuestName.trim());
}
- browser.location.href = `/discuss/channel/${this.channelId}`;
+ browser.location.href = `/discuss/channel/${this.channel.id}`;
}
//----------------------------------------------------------------------
@@ -119,27 +119,52 @@ function factory(dependencies) {
}
WelcomeView.fields = {
- channelId: attr({
+ /**
+ * The channel to redirect to once the user clicks on the 'joinButton'.
+ */
+ channel: one2one('mail.thread', {
required: true,
}),
/**
- * Used as value for `id`, `for`, and `name` attributes of the guest
+ * Used as a value for `id`, `for`, and `name` attributes of the guest
* name input and its label. Necessary to ensure the uniqueness.
*/
guestNameInputUniqueId: attr({
default: `o_WelcomeView_guestNameInput_${getNextGuestNameInputId()}`,
}),
+ /**
+ * Ref the to input element containing the 'pendingGuestName'.
+ */
guestNameInputRef: attr(),
+ /**
+ * Determines whether the 'guestNameInput' should be focused the next
+ * time the component is updated.
+ */
isDoFocusGuestNameInput: attr(),
+ /**
+ * Determines whether the 'joinButton' is disabled.
+ *
+ * Shall be disabled when 'pendingGuestName' is an empty string or when
+ * the current user is not a guest.
+ */
isJoinButtonDisabled: attr({
compute: '_computeIsJoinButtonDisabled'
}),
+ /**
+ * The MediaPreview linked to the current WelcomeView.
+ */
mediaPreview: one2one('mail.media_preview', {
default: create(),
isCausal: true,
readonly: true,
required: true,
}),
+ /**
+ * The value of the 'guestNameInput'.
+ *
+ * Will be used to update the current guest's name when joining the
+ * channel by clicking on the 'joinButton'.
+ */
pendingGuestName: attr(),
};
diff --git a/addons/mail/static/src/public/discuss_public_boot.js b/addons/mail/static/src/public/discuss_public_boot.js
index acd5cb1e73a..94afa283482 100644
--- a/addons/mail/static/src/public/discuss_public_boot.js
+++ b/addons/mail/static/src/public/discuss_public_boot.js
@@ -1,6 +1,6 @@
/** @odoo-module **/
-import { insert } from '@mail/model/model_field_command';
+import { insert, link } from '@mail/model/model_field_command';
import { MessagingService } from '@mail/services/messaging/messaging';
import { getMessagingComponent } from '@mail/utils/messaging_component';
@@ -85,11 +85,14 @@ export async function boot() {
}
}
- async function createWelcomeView(channelId) {
+ async function createWelcomeView(channelData) {
const messaging = await owl.Component.env.services.messaging.get();
+ const channel = messaging.models['mail.thread'].insert(
+ messaging.models['mail.thread'].convertData(channelData)
+ );
const WelcomeView = getMessagingComponent('WelcomeView');
const welcomeView = messaging.models['mail.welcome_view'].create({
- channelId,
+ channel: link(channel),
isDoFocusGuestNameInput: true,
pendingGuestName: messaging.currentGuest && messaging.currentGuest.name,
});
@@ -97,6 +100,10 @@ export async function boot() {
localId: welcomeView.localId,
});
await welcomeViewComponent.mount(document.body);
+ if (welcomeView.channel.defaultDisplayMode === 'video_full_screen') {
+ welcomeView.mediaPreview.enableMicrophone();
+ welcomeView.mediaPreview.enableVideo();
+ }
}
return { createThreadViewFromChannelData, createWelcomeView };
diff --git a/addons/mail/views/discuss_public_templates.xml b/addons/mail/views/discuss_public_templates.xml
index 290561b6f63..6f7af7ae92a 100644
--- a/addons/mail/views/discuss_public_templates.xml
+++ b/addons/mail/views/discuss_public_templates.xml
@@ -41,8 +41,7 @@
odoo.define('mail.discuss_public_boot_channel', async function(require) {
const { boot } = require('@mail/public/discuss_public_boot');
const { createThreadViewFromChannelData } = await boot();
- const channelData = ;
- createThreadViewFromChannelData(channelData);
+ createThreadViewFromChannelData();
});
@@ -56,8 +55,7 @@
odoo.define('mail.discuss_public_boot_welcome_view', async function(require) {
const { boot } = require('@mail/public/discuss_public_boot');
const { createWelcomeView } = await boot();
- const channelId = ;
- createWelcomeView(channelId);
+ createWelcomeView();
});