-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use native html logic to prioritize loading
Signed-off-by: Louis Chemineau <louis@chmn.me>
- Loading branch information
Showing
5 changed files
with
176 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2019 Louis Chmn <louis@chmn.me> | ||
- | ||
- @author Louis Chemineau <louis@chmn.me> | ||
- | ||
- @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 <http://www.gnu.org/licenses/>. | ||
- | ||
--> | ||
|
||
<template> | ||
<h3 v-if="file.sectionHeader" | ||
:id="`file-picker-section-header-${file.id}`" | ||
class="section-header"> | ||
<b>{{ dateMonth }}</b> | ||
{{ dateYear }} | ||
</h3> | ||
<File v-else | ||
:file="actualFile" | ||
:allow-selection="true" | ||
:selected="isSelected" | ||
:distance="distance" | ||
@click="openViewer" | ||
@select-toggled="onFileSelectToggle" /> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex' | ||
import { isMobile } from '@nextcloud/vue' | ||
import moment from '@nextcloud/moment' | ||
import FilesSelectionMixin from '../mixins/FilesSelectionMixin.js' | ||
import File from './File.vue' | ||
export default { | ||
name: 'TimelineFile', | ||
components: { | ||
File, | ||
}, | ||
filters: { | ||
}, | ||
mixins: [ | ||
FilesSelectionMixin, | ||
isMobile, | ||
], | ||
props: { | ||
file: { | ||
type: Object, | ||
required: true, | ||
}, | ||
distance: { | ||
type: Number, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
...mapGetters([ | ||
'files', | ||
]), | ||
/** @return {boolean} */ | ||
isSelected() { | ||
return this.selection[this.file.id] === true | ||
}, | ||
/** @return {object} */ | ||
actualFile() { | ||
return this.files[this.file.id] | ||
}, | ||
/** @return {string} */ | ||
dateMonth() { | ||
return moment(this.file.id, 'YYYYMM').format('MMMM') | ||
}, | ||
/** @return {string} */ | ||
dateYear() { | ||
return moment(this.file.id, 'YYYYMM').format('YYYY') | ||
}, | ||
}, | ||
methods: { | ||
openViewer(fileId) { | ||
const file = this.files[fileId] | ||
OCA.Viewer.open({ | ||
fileInfo: file, | ||
list: Object.values(this.fileIdsByMonth).flat().map(fileId => this.files[fileId]), | ||
loadMore: file.loadMore ? async () => await file.loadMore(true) : () => [], | ||
canLoop: file.canLoop, | ||
}) | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @copyright Copyright (c) 2023 Louis Chmn <louis@chmn.me> | ||
* | ||
* @author Louis Chmn <louis@chmn.me> | ||
* | ||
* @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 <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
// The preview service worker cache name (see webpack config) | ||
const SWCacheName = 'images' | ||
|
||
/** | ||
* Check if the preview is already cached by the service worker | ||
* @param {string} previewUrl | ||
*/ | ||
export const isCachedPreview = async function (previewUrl) { | ||
const cache = await caches.open(SWCacheName) | ||
const response = await cache.match(previewUrl) | ||
return response !== undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters