From 27f8608d69aecfe6d83768331bce6b37a1086254 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 14 Nov 2023 00:52:07 -0800 Subject: [PATCH] albums: hide hidden from list Signed-off-by: Varun Patil --- lib/Controller/OtherController.php | 1 + src/components/ClusterView.vue | 2 +- src/components/Settings.vue | 9 +++++++++ src/components/modal/AlbumPicker.vue | 2 +- src/components/modal/AlbumsList.vue | 2 +- src/services/dav/albums.ts | 14 ++++++++++---- src/services/static-config.ts | 1 + src/typings/config.d.ts | 1 + 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index f8315781..8e7d40d4 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -116,6 +116,7 @@ class OtherController extends GenericApiController // album settings 'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'), + 'show_hidden_albums' => 'true' === $getAppConfig('showHiddenAlbums', false), ], Http::STATUS_OK); }); } diff --git a/src/components/ClusterView.vue b/src/components/ClusterView.vue index fe2d89c9..eda1cefc 100644 --- a/src/components/ClusterView.vue +++ b/src/components/ClusterView.vue @@ -99,7 +99,7 @@ export default defineComponent({ await this.refs.dtm?.refresh?.(); if (this.routeIsAlbums) { - this.items = await dav.getAlbums(this.config.album_list_sort); + this.items = await dav.getAlbums(); } else if (this.routeIsTags) { this.items = await dav.getTags(); } else if (this.routeIsRecognize) { diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 31b0c2ee..b87adbf5 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -153,6 +153,14 @@ > {{ t('memories', 'Sort albums oldest-first') }} + + + {{ t('memories', 'Show hidden albums') }} + @@ -315,6 +323,7 @@ export default defineComponent({ // Folders settings async updateShowHidden() { await this.updateSetting('show_hidden_folders', 'showHidden'); + await this.updateSetting('show_hidden_albums', 'showHiddenAlbums'); }, async updateSortFolderMonth() { diff --git a/src/components/modal/AlbumPicker.vue b/src/components/modal/AlbumPicker.vue index 4ee7fa8a..0cbde89c 100644 --- a/src/components/modal/AlbumPicker.vue +++ b/src/components/modal/AlbumPicker.vue @@ -193,7 +193,7 @@ export default defineComponent({ // if only one photo is selected, get the albums of that photo const fileid = this.photos.length === 1 ? this.photos[0].fileid : 0; if (fileid) { - const selIds = new Set((await dav.getAlbums(1, fileid)).map((a) => a.album_id)); + const selIds = new Set((await dav.getAlbums(fileid)).map((a) => a.album_id)); this.initSelection = new Set(this.albums.filter((a) => selIds.has(a.album_id))); this.selection = new Set(this.initSelection); } diff --git a/src/components/modal/AlbumsList.vue b/src/components/modal/AlbumsList.vue index 2c30e1c0..e7bd650a 100644 --- a/src/components/modal/AlbumsList.vue +++ b/src/components/modal/AlbumsList.vue @@ -76,7 +76,7 @@ export default defineComponent({ linkTarget(album: IAlbum) { return { - name: 'albums', + name: _m.routes.Albums.name, params: { name: album.name, user: album.user, diff --git a/src/services/dav/albums.ts b/src/services/dav/albums.ts index 39763216..d0374526 100644 --- a/src/services/dav/albums.ts +++ b/src/services/dav/albums.ts @@ -7,6 +7,7 @@ import { getLanguage } from '@nextcloud/l10n'; import { translate as t } from '@services/l10n'; import { API } from '@services/API'; import client from '@services/dav/client'; +import staticConfig from '@services/static-config'; import * as utils from '@services/utils'; import type { IAlbum, IFileInfo, IPhoto } from '@typings'; @@ -25,19 +26,24 @@ export function getAlbumPath(user: string, name: string) { /** * Get list of albums. - * @param sort Sort order; 1 = by date, 2 = by name * @param fileid Optional file ID to get albums for */ -export async function getAlbums(sort: 1 | 2 = 1, fileid?: number) { +export async function getAlbums(fileid?: number) { const url = API.Q(API.ALBUM_LIST(), { fileid }); const res = await axios.get(url); - const data = res.data; + let data = res.data; + + // Remove hidden albums unless specified + if (!(await staticConfig.get('show_hidden_albums'))) { + data = data.filter((a) => !a.name.startsWith('.')); + } // Sort the response - switch (sort) { + switch (await staticConfig.get('album_list_sort')) { case 2: data.sort((a, b) => a.name.localeCompare(b.name, getLanguage(), { numeric: true })); break; + case 1: default: data.sort((a, b) => b.created - a.created); } diff --git a/src/services/static-config.ts b/src/services/static-config.ts index bd2c1f2f..db613966 100644 --- a/src/services/static-config.ts +++ b/src/services/static-config.ts @@ -135,6 +135,7 @@ class StaticConfig { // album settings sort_album_month: true, + show_hidden_albums: false, // local settings square_thumbs: false, diff --git a/src/typings/config.d.ts b/src/typings/config.d.ts index 3c5fc762..b432653d 100644 --- a/src/typings/config.d.ts +++ b/src/typings/config.d.ts @@ -34,6 +34,7 @@ declare module '@typings' { // album settings sort_album_month: boolean; + show_hidden_albums: boolean; // local settings square_thumbs: boolean;