Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overlay on live photo #2127

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/Sabre/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use OCA\Photos\Sabre\Place\PlaceRoot;
use OCP\Files\DavUtil;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IPreview;
use Sabre\DAV\INode;
use Sabre\DAV\PropFind;
Expand All @@ -52,17 +52,15 @@ class PropFindPlugin extends ServerPlugin {
public const COLLABORATORS_PROPERTYNAME = '{http://nextcloud.org/ns}collaborators';
public const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions';

private IConfig $config;
private IPreview $previewManager;
private ?Tree $tree;
private AlbumMapper $albumMapper;

public function __construct(
IConfig $config,
IPreview $previewManager,
AlbumMapper $albumMapper
AlbumMapper $albumMapper,
private IFilesMetadataManager $filesMetadataManager,
) {
$this->config = $config;
$this->previewManager = $previewManager;
$this->albumMapper = $albumMapper;
}
Expand Down Expand Up @@ -119,6 +117,13 @@ public function propFind(PropFind $propFind, INode $node): void {
foreach ($node->getFileInfo()->getMetadata() as $metadataKey => $metadataValue) {
$propFind->handle(FilesPlugin::FILE_METADATA_PREFIX.$metadataKey, $metadataValue);
}


$propFind->handle(FilesPlugin::HIDDEN_PROPERTYNAME, function () use ($node) {
$metadata = $this->filesMetadataManager->getMetadata((int)$node->getFileInfo()->getId(), true);
return $metadata->hasKey('files-live-photo') && $node->getFileInfo()->getMimetype() === 'video/quicktime' ? 'true' : 'false';
});

}

if ($node instanceof AlbumRoot) {
Expand Down
7 changes: 5 additions & 2 deletions src/components/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

<!-- image and loading placeholder -->
<div class="file__images">
<VideoIcon v-if="file.mime.includes('video')" class="video-icon" :size="64" />
<VideoIcon v-if="file.mime.includes('video')" class="icon-overlay" :size="64" />
<PlayCircleIcon v-else-if="file.metadataFilesLivePhoto !== undefined" class="icon-overlay" :size="64" />

<!-- We have two img elements to load the small and large preview -->
<!-- Do not show the small preview if the larger one is loaded -->
Expand Down Expand Up @@ -84,6 +85,7 @@
<script>
import Star from 'vue-material-design-icons/Star.vue'
import VideoIcon from 'vue-material-design-icons/Video.vue'
import PlayCircleIcon from 'vue-material-design-icons/PlayCircle.vue'

import { generateUrl } from '@nextcloud/router'
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
Expand All @@ -96,6 +98,7 @@ export default {
NcCheckboxRadioSwitch,
Star,
VideoIcon,
PlayCircleIcon,
},
inheritAttrs: false,
props: {
Expand Down Expand Up @@ -253,7 +256,7 @@ export default {
&__images {
display: contents;

.video-icon {
.icon-overlay {
position: absolute;
top: 0px;
right: 0px;
Expand Down
2 changes: 2 additions & 0 deletions src/services/DavRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ const props = `
<nc:face-preview-image />
<nc:metadata-photos-size />
<nc:metadata-photos-original_date_time />
<nc:metadata-files-live-photo />
<nc:has-preview />
<nc:realpath />
<nc:hidden />
<oc:favorite />
<oc:fileid />
<oc:permissions />
Expand Down
2 changes: 2 additions & 0 deletions src/services/collectionFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ function getCollectionFilesDavRequest(extraProps = []) {
<d:resourcetype />
<nc:metadata-photos-size />
<nc:metadata-photos-original_date_time />
<nc:metadata-files-live-photo />
<nc:has-preview />
<nc:hidden />
<oc:favorite />
<oc:fileid />
<oc:permissions />
Expand Down
2 changes: 2 additions & 0 deletions src/services/fileFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function getCollectionFilesDavRequest(extraProps = []) {
<d:resourcetype />
<nc:metadata-photos-size />
<nc:metadata-photos-original_date_time />
<nc:metadata-files-live-photo />
<nc:has-preview />
<nc:hidden />
<oc:favorite />
<oc:fileid />
<oc:permissions />
Expand Down
48 changes: 25 additions & 23 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,31 @@ const mutations = {
*/
updateFiles(state, newFiles) {
const files = {}
newFiles.forEach(file => {
// Ignore the file if the path is excluded
if (state.nomediaPaths.some(nomediaPath => file.filename.startsWith(nomediaPath)
|| file.filename.startsWith(prefixPath + nomediaPath))) {
return
}

if (file.fileid >= 0) {
file.metadataPhotosSize ??= { width: 256, height: 256 }
}

// Make the fileId a string once and for all.
file.fileid = file.fileid.toString()

// Precalculate dates as it is expensive.
const date = moment((file.metadataPhotosOriginalDateTime * 1000) || file.lastmod)
file.timestamp = date.unix() // For sorting
file.month = date.format('YYYYMM') // For grouping by month
file.day = date.format('MMDD') // For On this day

// Schedule the file to add
files[file.fileid] = file
})
newFiles
.filter(file => !file.hidden)
.forEach(file => {
// Ignore the file if the path is excluded
if (state.nomediaPaths.some(nomediaPath => file.filename.startsWith(nomediaPath)
|| file.filename.startsWith(prefixPath + nomediaPath))) {
return
}

if (file.fileid >= 0) {
file.metadataPhotosSize ??= { width: 256, height: 256 }
}

// Make the fileId a string once and for all.
file.fileid = file.fileid.toString()

// Precalculate dates as it is expensive.
const date = moment((file.metadataPhotosOriginalDateTime * 1000) || file.lastmod)
file.timestamp = date.unix() // For sorting
file.month = date.format('YYYYMM') // For grouping by month
file.day = date.format('MMDD') // For On this day

// Schedule the file to add
files[file.fileid] = file
})

state.files = {
...state.files,
Expand Down
Loading