diff --git a/src/components/web3/core.ts b/src/components/web3/core.ts index 2f6c7df9..d9a94b13 100644 --- a/src/components/web3/core.ts +++ b/src/components/web3/core.ts @@ -49,6 +49,7 @@ export function rememberAvatarUrl(url: string | undefined | null) { * Gets the currently set avatar url, if any * @returns {string|null} - The avatar url value or a null value */ -export function getAvatarUrl(): string | null { - return window.sessionStorage.getItem(AVATAR_URL_SESSION_KEY); +export function getAvatarUrl(jwt: string): string | null { + const sessionAvatar = window.sessionStorage.getItem(AVATAR_URL_SESSION_KEY); + return sessionAvatar || jwt_decode(jwt).avatar_url || null; } diff --git a/src/jitsi/conference-page.ts b/src/jitsi/conference-page.ts index 0d9599c4..dbbbae9a 100644 --- a/src/jitsi/conference-page.ts +++ b/src/jitsi/conference-page.ts @@ -17,6 +17,26 @@ import { * @param {JitsiOptions} options - Configuration options for the conference room * @returns {IJitsiMeetApi} The Jitsi API instance for the conference room */ + +function clearAvatarInfoFromLocalStorage() { + const jitsiLocalStorageSettings = + window.localStorage.getItem("jitsiLocalStorage"); + if (jitsiLocalStorageSettings) { + const jitsiLocalStorageSettingsObj = JSON.parse(jitsiLocalStorageSettings); + let baseSettings = jitsiLocalStorageSettingsObj["features/base/settings"]; + if (baseSettings) { + baseSettings = JSON.parse(baseSettings); + baseSettings["avatarURL"] = ""; + jitsiLocalStorageSettingsObj["features/base/settings"] = + JSON.stringify(baseSettings); + } + window.localStorage.setItem( + "jitsiLocalStorage", + JSON.stringify(jitsiLocalStorageSettingsObj) + ); + } +} + export const renderConferencePage = async ( jitsiEventHandlers: JitsiEventHandler[], options: JitsiOptions, @@ -26,7 +46,7 @@ export const renderConferencePage = async ( const { roomName, jwt } = options; reportMethod("renderConferencePage", { roomName, jwt }); reportMethod("JitsiMeetExternalAPI", options); - + clearAvatarInfoFromLocalStorage(); const JitsiMeetJS = new JitsiMeetExternalAPI(config.webrtc_domain, options); reportAction("JitsiMeetExternalAPI", { status: "activated!" }); updateSubject(JitsiMeetJS, options); @@ -37,12 +57,11 @@ export const renderConferencePage = async ( context.inactiveInterval ); } - - const avatarUrl = getAvatarUrl(); + const avatarUrl = getAvatarUrl(jwt); if (avatarUrl) { JitsiMeetJS.executeCommand("avatarUrl", avatarUrl); } - + window.sessionStorage.removeItem("avatar_url"); jitsiEventHandlers.forEach(({ name, fn }: JitsiEventHandler) => { JitsiMeetJS.on(name, fn(JitsiMeetJS, context, options)); });