diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-11-28 13:34:15 +0300 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-11-28 13:34:15 +0300 |
commit | b2c8850d058551e71fa672e7c0002ef4f02ca65c (patch) | |
tree | 429c33f60110879ae562c816cc6ca118d56aadc5 /src | |
parent | 623015aad68975b2ac6c00b0c5a407a43dca410a (diff) |
Favorites
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/File.vue | 2 | ||||
-rw-r--r-- | src/router/index.js | 5 | ||||
-rw-r--r-- | src/services/PhotoSearch.js | 34 | ||||
-rw-r--r-- | src/views/Timeline.vue | 18 |
4 files changed, 43 insertions, 16 deletions
diff --git a/src/components/File.vue b/src/components/File.vue index efb85602..60d18a41 100644 --- a/src/components/File.vue +++ b/src/components/File.vue @@ -105,7 +105,7 @@ export default { created() { // Allow us to cancel the img loading on destroy // use etag to force cache reload if file changed - this.img.src = generateUrl(`/core/preview?fileId=${this.fileid}&x=${1024}&y=${1024}&a=true&v=${this.etag}`) + this.img.src = generateUrl(`/core/preview?fileId=${this.fileid}&x=${256}&y=${256}&a=true&v=${this.etag}`) this.img.addEventListener('load', () => { this.src = this.img.src }) diff --git a/src/router/index.js b/src/router/index.js index 802aabac..a5372a59 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -67,8 +67,11 @@ export default new Router({ }, { path: '/favorites', - component: Tags, + component: Timeline, name: 'favorites', + props: { + onlyFavorites: true, + }, }, { path: '/tags/:path*', diff --git a/src/services/PhotoSearch.js b/src/services/PhotoSearch.js index bb4ee5b6..06d8dda3 100644 --- a/src/services/PhotoSearch.js +++ b/src/services/PhotoSearch.js @@ -28,11 +28,11 @@ import client from './DavClient' /** * List files from a folder and filter out unwanted mimes * - * @param {string} [path] not used + * @param {boolean} [onlyFavorites=false] not used * @param {Object} [options] used for the cancellable requests * @returns {Array} the file list */ -export default async function(path = '', options) { +export default async function(onlyFavorites = false, options = {}) { const prefixPath = `/files/${getCurrentUser().uid}` @@ -47,6 +47,15 @@ export default async function(path = '', options) { </d:eq> `, '') + const eqFavorites = onlyFavorites + ? `<d:eq> + <d:prop> + <oc:favorite/> + </d:prop> + <d:literal>1</d:literal> + </d:eq>` + : '' + options = Object.assign({ method: 'SEARCH', headers: { @@ -77,15 +86,18 @@ export default async function(path = '', options) { </d:scope> </d:from> <d:where> - <d:or> - ${orMime} - </d:or> - <d:eq> - <d:prop> - <oc:owner-id/> - </d:prop> - <d:literal>${getCurrentUser().uid}</d:literal> - </d:eq> + <d:and> + <d:or> + ${orMime} + </d:or> + ${eqFavorites} + <d:eq> + <d:prop> + <oc:owner-id/> + </d:prop> + <d:literal>${getCurrentUser().uid}</d:literal> + </d:eq> + </d:and> </d:where> <d:orderby> <d:order> diff --git a/src/views/Timeline.vue b/src/views/Timeline.vue index 61f85ac0..eadfe8e5 100644 --- a/src/views/Timeline.vue +++ b/src/views/Timeline.vue @@ -61,6 +61,10 @@ export default { type: Boolean, required: true, }, + onlyFavorites: { + type: Boolean, + default: false, + }, }, data() { @@ -89,8 +93,16 @@ export default { }, }, + watch: { + async onlyFavorites() { + // content is completely different + this.$emit('update:loading', true) + this.fetchContent() + }, + }, + async beforeMount() { - this.fetchFolderContent() + this.fetchContent() }, beforeDestroy() { @@ -98,7 +110,7 @@ export default { }, methods: { - async fetchFolderContent() { + async fetchContent() { // cancel any pending requests this.cancelRequest('Changed view') @@ -117,7 +129,7 @@ export default { try { // get content and current folder info - const files = await request() + const files = await request(this.onlyFavorites) this.$store.dispatch('updateTimeline', files) this.$store.dispatch('appendFiles', files) } catch (error) { |