A platform for community discussion. Free, open, simple.
UX: show user tip to join zoom audio in livestream (#42220)
Krisf591f3936487
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjsindex 42c32e2d699..147557314a6 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/livestream/zoom-entry.gjs@@ -3,8 +3,10 @@ import { array } from "@ember/helper";import { action } from "@ember/object";import { getOwner } from "@ember/owner";import { service } from "@ember/service";+import { trustHTML } from "@ember/template";import { isEmpty } from "@ember/utils";import { bind } from "discourse/lib/decorators";+import { iconHTML } from "discourse/lib/icon-library";import DButton from "discourse/ui-kit/d-button";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import { i18n } from "discourse-i18n";@@ -57,6 +59,18 @@ export default class LivestreamZoomEntry extends Component {return !isEmpty(this.session.errorMessage);}+ get showAudioHint() {+ return this.session.isJoined && !this.session.hasJoinedAudio;+ }++ get joinAudioHint() {+ return trustHTML(+ i18n("discourse_calendar.livestream.zoom.join_audio_hint", {+ icon: iconHTML("zoom-join-audio"),+ })+ );+ }+get joinDisabled() {return (this.session.isJoining ||@@ -160,6 +174,12 @@ export default class LivestreamZoomEntry extends Component {}}{{zoomComponentViewLayout this.session this.isDesktop}}></div>++ {{#if this.showAudioHint}}+ <p class="discourse-calendar-livestream-zoom-entry__audio-hint">+ {{this.joinAudioHint}}+ </p>+ {{/if}}{{else}}<div class="discourse-calendar-livestream-zoom-entry__actions"><DButtondiff --git a/plugins/discourse-calendar/assets/javascripts/discourse/lib/zoom-meeting-session.js b/plugins/discourse-calendar/assets/javascripts/discourse/lib/zoom-meeting-session.jsindex a273fe3f34b..ca9b4859afa 100644--- a/plugins/discourse-calendar/assets/javascripts/discourse/lib/zoom-meeting-session.js+++ b/plugins/discourse-calendar/assets/javascripts/discourse/lib/zoom-meeting-session.js@@ -1,5 +1,6 @@import { tracked } from "@glimmer/tracking";import { setOwner } from "@ember/owner";+import { isEmpty } from "@ember/utils";import { i18n } from "discourse-i18n";import fetchZoomJoinPayload from "./fetch-zoom-join-payload";import { loadZoomMeetingSdkEmbedded } from "./load-zoom-meeting-sdk";@@ -19,6 +20,7 @@ export default class ZoomMeetingSession {@tracked errorMessage;@tracked isJoining = false;@tracked isJoined = false;+ @tracked hasJoinedAudio = false;@tracked showZoomFrame = false;@tracked retryCountdown = null;@tracked isRetryingNow = false;@@ -169,6 +171,8 @@ export default class ZoomMeetingSession {}});+ this.zoomClient.on("user-updated", () => this.syncAudioState());+this.zoomClientInitialized = true;}@@ -180,6 +184,16 @@ export default class ZoomMeetingSession {userName: zoomJoinPayload.user_name,userEmail: zoomJoinPayload.user_email,});++ this.syncAudioState();+ }++ // Joining the meeting does not connect audio: `audio` stays "" until the user+ // picks computer or phone audio in Zoom's own controls. `user-updated` carries+ // only the properties that changed, so the value is re-read from the client+ // rather than taken from the payload.+ syncAudioState() {+ this.hasJoinedAudio = !isEmpty(this.zoomClient?.getCurrentUser?.()?.audio);}syncVideoSize() {@@ -196,6 +210,7 @@ export default class ZoomMeetingSession {leaveZoom() {this.isJoined = false;+ this.hasJoinedAudio = false;this.showZoomFrame = false;// Deletes inline styles that Zoom applies which leaves a big empty box ondiff --git a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scssindex b8f42a08e3e..c33ff5431cc 100644--- a/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss+++ b/plugins/discourse-calendar/assets/stylesheets/common/livestream.scss@@ -64,6 +64,21 @@ body.chat-enabled.livestream-topic.confirmed-event-assistance {width: 100%;}+ &__audio-hint {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: var(--space-1);+ margin: 0;+ padding: var(--space-2);++ // intentionally hardcoded zoom values+ border-radius: 9px;+ background: rgb(36, 36, 36);+ color: rgb(255, 255, 255);+ border: 1px solid rgb(0, 255, 145);+ }+&__frame {// Zoom sets `display` inline on this element when it mounts, which beats// anything declared here. Only `justify-content` and `padding-top` apply.diff --git a/plugins/discourse-calendar/config/locales/client.en.yml b/plugins/discourse-calendar/config/locales/client.en.ymlindex b13c610065e..70f19839b18 100644--- a/plugins/discourse-calendar/config/locales/client.en.yml+++ b/plugins/discourse-calendar/config/locales/client.en.yml@@ -39,6 +39,7 @@ en:one: "The webinar hasn't started yet. Retrying join in %{count} second..."other: "The webinar hasn't started yet. Retrying join in %{count} seconds..."not_started_trying_again: "Trying to join the webinar again now..."+ join_audio_hint: "Click %{icon} above to join audio"chat:rsvp_to_event: "RSVP to the event to start chatting"rsvp_to_event_with_link: "RSVP to <a href='%{url}'>the event</a> to start chatting"diff --git a/plugins/discourse-calendar/plugin.rb b/plugins/discourse-calendar/plugin.rbindex c964409fd2b..29bf67cf7e2 100644--- a/plugins/discourse-calendar/plugin.rb+++ b/plugins/discourse-calendar/plugin.rb@@ -44,6 +44,7 @@ register_svg_icon "star"register_svg_icon "file-arrow-up"register_svg_icon "location-pin"register_svg_icon "arrows-up-to-line"+register_svg_icon "zoom-join-audio"extend_content_security_policy(worker_src: %w[https://source.zoom.us blob:])module ::DiscourseCalendardiff --git a/plugins/discourse-calendar/svg-icons/plugin-icons.svg b/plugins/discourse-calendar/svg-icons/plugin-icons.svgnew file mode 100644index 00000000000..3907c5cf3b4--- /dev/null+++ b/plugins/discourse-calendar/svg-icons/plugin-icons.svg@@ -0,0 +1,4 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">+ <symbol id="zoom-join-audio" viewBox="0 0 16 16"><path d="M12 7C12 4.79086 10.2091 3 8 3C5.79086 3 4 4.79086 4 7V11.5C4 11.7761 3.77614 12 3.5 12H2.5C1.94772 12 1.5 11.5523 1.5 11V9.5C1.5 8.94772 1.94772 8.5 2.5 8.5H3V7C3 4.23858 5.23858 2 8 2C10.7614 2 13 4.23858 13 7V8.5H13.5C14.0523 8.5 14.5 8.94772 14.5 9.5V11C14.5 11.5523 14.0523 12 13.5 12H12.5C12.2239 12 12 11.7761 12 11.5V7Z" fill="currentColor"/><path d="M8.17678 7.21971C8.07915 7.12208 7.92085 7.12208 7.82322 7.21971L6.07322 8.96971C5.97559 9.06734 5.97559 9.22563 6.07322 9.32326L6.42678 9.67681C6.52441 9.77445 6.6827 9.77445 6.78033 9.67681L7.5 8.95714V11.75C7.5 11.8881 7.61193 12 7.75 12H8.25C8.38807 12 8.5 11.8881 8.5 11.75V8.95714L9.21967 9.67681C9.3173 9.77445 9.47559 9.77445 9.57322 9.67681L9.92678 9.32326C10.0244 9.22563 10.0244 9.06734 9.92678 8.96971L8.17678 7.21971Z" fill="#00FF91"/></symbol>+</svg>diff --git a/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs b/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjsindex e5afb7c89d7..90a551296c0 100644--- a/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs+++ b/plugins/discourse-calendar/test/javascripts/integration/components/zoom-entry-test.gjs@@ -20,6 +20,8 @@ const FRAME_SELECTOR = ".discourse-calendar-livestream-zoom-entry__frame";const JOIN_BUTTON_SELECTOR =".discourse-calendar-livestream-zoom-entry .btn-primary";const LEAVE_BUTTON_SELECTOR = ".zoom-MuiButton-root";+const AUDIO_HINT_SELECTOR =+ ".discourse-calendar-livestream-zoom-entry__audio-hint";const COUNTDOWN_TEXT = `The webinar hasn't started yet. Retrying join in ${RETRY_DELAY_SECONDS} seconds...`;const ERROR_TEXT =@@ -225,6 +227,62 @@ module("Integration | Component | LivestreamZoomEntry", function (hooks) {assert.dom(".discourse-calendar-livestream-zoom-entry").exists();});+ test("shows the audio hint only once the meeting is joined", async function (assert) {+ stubCapabilities(getOwner(this), { lg: true });+ const performJoin = sinon.stub(ZoomMeetingSession.prototype, "performJoin");+ const join = deferred();+ performJoin.returns(join.promise);++ await render(+ <template><LivestreamZoomEntry @event={{this.event}} /></template>+ );++ assert.dom(AUDIO_HINT_SELECTOR).doesNotExist("hidden before joining");++ click(JOIN_BUTTON_SELECTOR);+ await settled();++ assert.dom(AUDIO_HINT_SELECTOR).doesNotExist("hidden while joining");++ join.resolve();+ await settled();++ assert.dom(AUDIO_HINT_SELECTOR).hasText("Click above to join audio");+ assert.dom(`${AUDIO_HINT_SELECTOR} .d-icon-zoom-join-audio`).exists();+ });++ test("hides the audio hint once the user connects audio", async function (assert) {+ stubCapabilities(getOwner(this), { lg: true });+ const captured = captureSession();+ sinon.stub(ZoomMeetingSession.prototype, "performJoin").resolves();++ await render(+ <template><LivestreamZoomEntry @event={{this.event}} /></template>+ );++ await click(JOIN_BUTTON_SELECTOR);++ const { session } = captured;+ session.zoomClient = {+ getCurrentUser: () => ({ userId: 1, audio: "" }),+ updateVideoOptions: () => {},+ };++ session.syncAudioState();+ await settled();++ assert.dom(AUDIO_HINT_SELECTOR).exists("audio is not connected yet");++ session.zoomClient.getCurrentUser = () => ({+ userId: 1,+ audio: "computer",+ });+ session.syncAudioState();+ await settled();++ assert.dom(AUDIO_HINT_SELECTOR).doesNotExist();+ });+module("when marking attendance", function (innerHooks) {let appEvents, performJoin;