Skip to content

Commit

Permalink
Get enableServiceWorker value from iframe query params
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Jan 18, 2024
1 parent 6aaf0c6 commit e672c25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion frontend/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ChatProps {
instanceId: string,
defaultHomeserver?: string,
roomId?: string,
enableServiceWorker?: boolean,
}

export function Chat(props: ChatProps) {
Expand All @@ -15,14 +16,16 @@ export function Chat(props: ChatProps) {
iframeUrl,
instanceId,
defaultHomeserver,
roomId
roomId,
enableServiceWorker,
} = props;

const ref = focusable ? useFocusableIframe() : undefined;
const url = new IframeUrl(iframeUrl, {
instanceId,
defaultHomeserver,
roomId,
enableServiceWorker,
});

return (
Expand Down
7 changes: 5 additions & 2 deletions frontend/components/chat/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type IframeParams = {
instanceId: string,
defaultHomeserver?: string
roomId?: string,
enableServiceWorker?: boolean,
}

export class IframeUrl {
Expand All @@ -13,9 +14,11 @@ export class IframeUrl {
this.url = iframeUrl;

for (let key in params) {
if (!!params[key]) {
this.url.searchParams.append(key, params[key]);
let value = params[key];
if (typeof value === 'boolean') {
value = value ? "true" : "false";
}
this.url.searchParams.append(key, value);
}

this.applyLoginToken();
Expand Down

0 comments on commit e672c25

Please sign in to comment.