Merge pull request #1425 from dermotduffy/no-download-in-live

Only show download button in media viewer
This commit is contained in:
Dermot Duffy
2024-04-02 21:07:23 +01:00
committed by GitHub
2 changed files with 31 additions and 2 deletions
+8 -2
View File
@@ -131,7 +131,9 @@ export class MenuButtonController {
.getAllDependentCameras(selectedCameraID, 'substream'); .getAllDependentCameras(selectedCameraID, 'substream');
if (selectedCameraID && substreamCameraIDs && view.is('live')) { if (selectedCameraID && substreamCameraIDs && view.is('live')) {
const substreams = [...substreamCameraIDs].filter((cameraID) => cameraID !== selectedCameraID); const substreams = [...substreamCameraIDs].filter(
(cameraID) => cameraID !== selectedCameraID,
);
const streams = [selectedCameraID, ...substreams]; const streams = [selectedCameraID, ...substreams];
if (streams.length === 2) { if (streams.length === 2) {
@@ -258,7 +260,11 @@ export class MenuButtonController {
}); });
} }
if (mediaCapabilities?.canDownload && !this._isBeingCasted()) { if (
view.isViewerView() &&
mediaCapabilities?.canDownload &&
!this._isBeingCasted()
) {
buttons.push({ buttons.push({
icon: 'mdi:download', icon: 'mdi:download',
...config.menu.buttons.download, ...config.menu.buttons.download,
@@ -726,6 +726,7 @@ describe('MenuButtonController', () => {
createMediaCapabilities({ canDownload: true }), createMediaCapabilities({ canDownload: true }),
); );
const view = createView({ const view = createView({
view: 'media',
queryResults: new MediaQueriesResults({ queryResults: new MediaQueriesResults({
results: [new ViewMedia('clip', 'camera-1')], results: [new ViewMedia('clip', 'camera-1')],
selectedIndex: 0, selectedIndex: 0,
@@ -772,6 +773,28 @@ describe('MenuButtonController', () => {
expect.arrayContaining([expect.objectContaining({ title: 'Download' })]), expect.arrayContaining([expect.objectContaining({ title: 'Download' })]),
); );
}); });
it('not in a non-media view', () => {
const cameraManager = createCameraManager();
vi.mocked(cameraManager.getMediaCapabilities).mockReturnValue(
createMediaCapabilities({ canDownload: true }),
);
const view = createView({
view: 'live',
queryResults: new MediaQueriesResults({
results: [new ViewMedia('clip', 'camera-1')],
selectedIndex: 0,
}),
});
const buttons = calculateButtons(controller, {
cameraManager: cameraManager,
view: view,
});
expect(buttons).not.toEqual(
expect.arrayContaining([expect.objectContaining({ title: 'Download' })]),
);
});
}); });
it('should have camera UI button', () => { it('should have camera UI button', () => {