Skip to content

Commit

Permalink
feat(ff-screenshare): add feature flag screenshare on call
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Jun 17, 2024
1 parent 6be037d commit ee25d30
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 7 deletions.
7 changes: 6 additions & 1 deletion config.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@
"dev02.tchap.incubateur.net",
"ext01.tchap.incubateur.net"
],
"feature_video_call": ["dev01.tchap.incubateur.net", "dev02.tchap.incubateur.net", "ext01.tchap.incubateur.net"]
"feature_video_call": [
"dev01.tchap.incubateur.net",
"dev02.tchap.incubateur.net",
"ext01.tchap.incubateur.net"
],
"feature_screenshare_call": ["*"]
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
3 changes: 2 additions & 1 deletion config.preprod.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"feature_thread": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_space": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_audio_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_video_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"]
"feature_video_call": ["i.tchap.gouv.fr", "e.tchap.gouv.fr"],
"feature_screenshare_call": ["*"]
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
3 changes: 2 additions & 1 deletion config.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"feature_thread": ["agent.dinum.tchap.gouv.fr"],
"feature_space": [],
"feature_audio_call": ["*"],
"feature_video_call": []
"feature_video_call": [],
"feature_screenshare_call": ["*"]
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
3 changes: 2 additions & 1 deletion config.prod_rie.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"feature_thread": [],
"feature_space": [],
"feature_audio_call": ["*"],
"feature_video_call": []
"feature_video_call": [],
"feature_screenshare_call": ["*"]
},
"map_style_url": "https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,18 @@ export default class LegacyCallView extends React.Component<IProps, IState> {
// identify it using SDPStreamMetadata or if we can replace the already
// existing usermedia track by a screensharing track. We also need to be
// connected to know the state of the other side
const screensharingButtonShown =
(call.opponentSupportsSDPStreamMetadata() || call.hasLocalUserMediaVideoTrack) &&
call.state === CallState.Connected;
/** :TCHAP: hide-screensharing-button */
// const screensharingButtonShown =
// (call.opponentSupportsSDPStreamMetadata() || call.hasLocalUserMediaVideoTrack) &&
// call.state === CallState.Connected;
// const vidMuteButtonShown = call.opponentSupportsSDPStreamMetadata() || call.hasLocalUserMediaVideoTrack;
let screensharingButtonShown = false // hide by default
if (TchapUIFeature.isFeatureActiveForHomeserver("feature_screenshare_call")) {
screensharingButtonShown =
(call.opponentSupportsSDPStreamMetadata() || call.hasLocalUserMediaVideoTrack) &&
call.state === CallState.Connected;
};
/** end :TCHAP: */
// Show the sidebar button only if there is something to hide/show
const sidebarButtonShown = (secondaryFeed && !secondaryFeed.isVideoMuted()) || sidebarFeeds.length > 0;
// The dial pad & 'more' button actions are only relevant in a connected call
Expand Down
6 changes: 6 additions & 0 deletions patches/subtree-modifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
"files": [
"src/components/views/spaces/SpacePanel.tsx"
]
},
"hide-screensharing-button": {
"issue": "https://github.com/tchapgouv/tchap-web-v4/issues/1042",
"files": [
"src/components/views/voip/LegacyCallView.tsx"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe("LegacyCallView", () => {
// mock SdkConfig.get("tchap_features")
const config: ConfigOptions = { tchap_features: {} };
config.tchap_features[featureName] = homeservers;
config.tchap_features["feature_screenshare_call"] = homeservers;
SdkConfig.put(config);
};

Expand Down Expand Up @@ -139,4 +140,30 @@ describe("LegacyCallView", () => {

expect(container.getElementsByClassName("mx_LegacyCallViewButtons_button_vid").length).toBe(1);
});

it("should display screenshare button when the the homeserver include feature_screenshare_call feature", () => {
jest.spyOn(fakeCall, "opponentSupportsSDPStreamMetadata").mockReturnValue(true);

mockFeatureConfig([homeserverName]);
const { container } = renderCallView();

// needs to hover on the component to make the control button appears
fireEvent.mouseEnter(container);
waitFor(() => container.getElementsByClassName("mx_LegacyCallViewButtons").length);

expect(container.getElementsByClassName("mx_LegacyCallViewButtons_button_screensharing").length).toBe(1);
});

it("should not display screenshare button when the the homeserver doesnt include feature_screenshare_call feature", async () => {
jest.spyOn(fakeCall, "opponentSupportsSDPStreamMetadata").mockReturnValue(true);

mockFeatureConfig(["other.homeserver"]);
const { container } = renderCallView();

// needs to hover on the component to make the control button appears
fireEvent.mouseEnter(container);
waitFor(() => container.getElementsByClassName("mx_LegacyCallViewButtons").length);

expect(container.getElementsByClassName("mx_LegacyCallViewButtons_button_screensharing").length).toBe(0);
});
});

0 comments on commit ee25d30

Please sign in to comment.