Skip to content

Commit

Permalink
fix: Go to normal fullscreen mode if detached window is not supported…
Browse files Browse the repository at this point in the history
… on desktop (#17871)
  • Loading branch information
thisisamir98 authored Aug 5, 2024
1 parent 358f26d commit a418508
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/script/calling/CallState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {REASON as CALL_REASON, STATE as CALL_STATE} from '@wireapp/avs';
import {Runtime} from '@wireapp/commons';
import {WebAppEvents} from '@wireapp/webapp-events';

import {useDetachedCallingFeatureState} from 'Components/calling/DetachedCallingCell/DetachedCallingFeature.state';
import {calculateChildWindowPosition} from 'Util/DOM/caculateChildWindowPosition';
import {matchQualifiedIds} from 'Util/QualifiedId';
import {copyStyles} from 'Util/renderElement';
Expand All @@ -44,6 +45,7 @@ export enum MuteState {
}

export enum CallingViewMode {
FULL_SCREEN = 'fullscreen',
DETACHED_WINDOW = 'detached_window',
MINIMIZED = 'minimized',
}
Expand Down Expand Up @@ -141,17 +143,35 @@ export class CallState {
};

setViewModeMinimized = () => {
const isDetachedWindowSupported = useDetachedCallingFeatureState.getState().isSupported();

if (!isDetachedWindowSupported) {
this.viewMode(CallingViewMode.MINIMIZED);
return;
}

this.detachedWindow()?.close();
this.closeDetachedWindow();
};

setViewModeFullScreen = () => {
this.viewMode(CallingViewMode.FULL_SCREEN);
};

async setViewModeDetached(
detachedViewModeOptions: {name: string; height: number; width: number} = {
name: 'WIRE_PICTURE_IN_PICTURE_CALL',
width: 1026,
height: 829,
},
) {
const isDetachedWindowSupported = useDetachedCallingFeatureState.getState().isSupported();

if (!isDetachedWindowSupported) {
this.setViewModeFullScreen();
return;
}

const isDesktop = Runtime.isDesktopApp();
const {name, width, height} = detachedViewModeOptions;
if ('documentPictureInPicture' in window && window.documentPictureInPicture && !isDesktop) {
Expand Down
4 changes: 2 additions & 2 deletions src/script/components/calling/CallingOverlayContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const CallingContainer: React.FC<CallingContainerProps> = ({
}) => {
const {devicesHandler: mediaDevicesHandler} = mediaRepository;
const {viewMode} = useKoSubscribableChildren(callState, ['viewMode']);
const isDetachedWindow = viewMode === CallingViewMode.DETACHED_WINDOW;
const isFullScreenOrDetached = [CallingViewMode.DETACHED_WINDOW, CallingViewMode.FULL_SCREEN].includes(viewMode);

const {activeCallViewTab, joinedCall, hasAvailableScreensToShare, desktopScreenShareMenu} = useKoSubscribableChildren(
callState,
Expand Down Expand Up @@ -139,7 +139,7 @@ const CallingContainer: React.FC<CallingContainerProps> = ({

return (
<Fragment>
{isDetachedWindow && !!videoGrid?.grid.length && (
{isFullScreenOrDetached && !!videoGrid?.grid.length && (
<FullscreenVideoCall
key={conversation.id}
videoGrid={videoGrid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ type DetachedCallingFeatureState = {
isSupported: () => boolean;
};

export const useDetachedCallingFeatureState = create<DetachedCallingFeatureState>((set, get) => ({
isSupported: () => !Runtime.isDesktopApp() || Config.getDesktopConfig()?.supportsCallingPopoutWindow === true,
export const useDetachedCallingFeatureState = create<DetachedCallingFeatureState>(() => ({
isSupported: () => {
if (Runtime.isDesktopApp()) {
return Config.getDesktopConfig()?.supportsCallingPopoutWindow === true;
}

return true;
},
}));

0 comments on commit a418508

Please sign in to comment.