From 1c84139fa6d2803d7b555dbedfda8bba8067a5ed Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 8 Nov 2023 14:52:50 +0100 Subject: Hide .mov for live photos Signed-off-by: Louis Chemineau --- apps/files/src/init.ts | 8 +++++++- apps/files/src/services/LivePhotos.ts | 33 +++++++++++++++++++++++++++++++++ apps/files/src/views/FilesList.vue | 5 ++++- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 apps/files/src/services/LivePhotos.ts (limited to 'apps/files') diff --git a/apps/files/src/init.ts b/apps/files/src/init.ts index 430b17ae7ae..aa855ed69b2 100644 --- a/apps/files/src/init.ts +++ b/apps/files/src/init.ts @@ -20,7 +20,7 @@ * */ import MenuIcon from '@mdi/svg/svg/sun-compass.svg?raw' -import { FileAction, addNewFileMenuEntry, registerFileAction } from '@nextcloud/files' +import { FileAction, addNewFileMenuEntry, registerDavProperty, registerFileAction } from '@nextcloud/files' import { action as deleteAction } from './actions/deleteAction' import { action as downloadAction } from './actions/downloadAction' @@ -41,6 +41,8 @@ import registerPreviewServiceWorker from './services/ServiceWorker.js' import './init-templates' +import { initLivePhotos } from './services/LivePhotos' + // Register file actions registerFileAction(deleteAction) registerFileAction(downloadAction) @@ -63,3 +65,7 @@ registerRecentView() // Register preview service worker registerPreviewServiceWorker() + +registerDavProperty('nc:hidden', { nc: 'http://nextcloud.org/ns' }) + +initLivePhotos() diff --git a/apps/files/src/services/LivePhotos.ts b/apps/files/src/services/LivePhotos.ts new file mode 100644 index 00000000000..df6c9decd4a --- /dev/null +++ b/apps/files/src/services/LivePhotos.ts @@ -0,0 +1,33 @@ +/** + * @copyright Copyright (c) 2023 Louis Chmn + * + * @author Louis Chmn + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +import { Node, registerDavProperty } from '@nextcloud/files' + +export function initLivePhotos(): void { + registerDavProperty('nc:metadata-files-live-photo', { nc: 'http://nextcloud.org/ns' }) +} + +/** + * @param {Node} node - The node + */ +export function isLivePhoto(node: Node): boolean { + return node.attributes['metadata-files-live-photo'] !== null +} diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index 89ce6aeb7b0..3bc4f27c2a2 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -256,7 +256,10 @@ export default Vue.extend({ }, dirContents(): Node[] { - return (this.currentFolder?._children || []).map(this.getNode).filter(file => file) + return (this.currentFolder?._children || []) + .map(this.getNode) + .filter(file => file) + .filter(file => file?.attributes?.hidden !== true) }, /** -- cgit v1.2.3