albums: hide hidden from list

Signed-off-by: Varun Patil <radialapps@gmail.com>
pulsejet/aio-hw-docs
Varun Patil 2023-11-14 00:52:07 -08:00
parent 016991d40e
commit 27f8608d69
8 changed files with 25 additions and 7 deletions

View File

@ -116,6 +116,7 @@ class OtherController extends GenericApiController
// album settings // album settings
'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'), 'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'),
'show_hidden_albums' => 'true' === $getAppConfig('showHiddenAlbums', false),
], Http::STATUS_OK); ], Http::STATUS_OK);
}); });
} }

View File

@ -99,7 +99,7 @@ export default defineComponent({
await this.refs.dtm?.refresh?.(); await this.refs.dtm?.refresh?.();
if (this.routeIsAlbums) { if (this.routeIsAlbums) {
this.items = await dav.getAlbums(this.config.album_list_sort); this.items = await dav.getAlbums();
} else if (this.routeIsTags) { } else if (this.routeIsTags) {
this.items = await dav.getTags(); this.items = await dav.getTags();
} else if (this.routeIsRecognize) { } else if (this.routeIsRecognize) {

View File

@ -153,6 +153,14 @@
> >
{{ t('memories', 'Sort albums oldest-first') }} {{ t('memories', 'Sort albums oldest-first') }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch
:checked.sync="config.show_hidden_albums"
@update:checked="updateShowHidden"
type="switch"
>
{{ t('memories', 'Show hidden albums') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection> </NcAppSettingsSection>
</NcAppSettingsDialog> </NcAppSettingsDialog>
@ -315,6 +323,7 @@ export default defineComponent({
// Folders settings // Folders settings
async updateShowHidden() { async updateShowHidden() {
await this.updateSetting('show_hidden_folders', 'showHidden'); await this.updateSetting('show_hidden_folders', 'showHidden');
await this.updateSetting('show_hidden_albums', 'showHiddenAlbums');
}, },
async updateSortFolderMonth() { async updateSortFolderMonth() {

View File

@ -193,7 +193,7 @@ export default defineComponent({
// if only one photo is selected, get the albums of that photo // if only one photo is selected, get the albums of that photo
const fileid = this.photos.length === 1 ? this.photos[0].fileid : 0; const fileid = this.photos.length === 1 ? this.photos[0].fileid : 0;
if (fileid) { 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.initSelection = new Set(this.albums.filter((a) => selIds.has(a.album_id)));
this.selection = new Set(this.initSelection); this.selection = new Set(this.initSelection);
} }

View File

@ -76,7 +76,7 @@ export default defineComponent({
linkTarget(album: IAlbum) { linkTarget(album: IAlbum) {
return { return {
name: 'albums', name: _m.routes.Albums.name,
params: { params: {
name: album.name, name: album.name,
user: album.user, user: album.user,

View File

@ -7,6 +7,7 @@ import { getLanguage } from '@nextcloud/l10n';
import { translate as t } from '@services/l10n'; import { translate as t } from '@services/l10n';
import { API } from '@services/API'; import { API } from '@services/API';
import client from '@services/dav/client'; import client from '@services/dav/client';
import staticConfig from '@services/static-config';
import * as utils from '@services/utils'; import * as utils from '@services/utils';
import type { IAlbum, IFileInfo, IPhoto } from '@typings'; import type { IAlbum, IFileInfo, IPhoto } from '@typings';
@ -25,19 +26,24 @@ export function getAlbumPath(user: string, name: string) {
/** /**
* Get list of albums. * Get list of albums.
* @param sort Sort order; 1 = by date, 2 = by name
* @param fileid Optional file ID to get albums for * @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 url = API.Q(API.ALBUM_LIST(), { fileid });
const res = await axios.get<IAlbum[]>(url); const res = await axios.get<IAlbum[]>(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 // Sort the response
switch (sort) { switch (await staticConfig.get('album_list_sort')) {
case 2: case 2:
data.sort((a, b) => a.name.localeCompare(b.name, getLanguage(), { numeric: true })); data.sort((a, b) => a.name.localeCompare(b.name, getLanguage(), { numeric: true }));
break; break;
case 1:
default: default:
data.sort((a, b) => b.created - a.created); data.sort((a, b) => b.created - a.created);
} }

View File

@ -135,6 +135,7 @@ class StaticConfig {
// album settings // album settings
sort_album_month: true, sort_album_month: true,
show_hidden_albums: false,
// local settings // local settings
square_thumbs: false, square_thumbs: false,

View File

@ -34,6 +34,7 @@ declare module '@typings' {
// album settings // album settings
sort_album_month: boolean; sort_album_month: boolean;
show_hidden_albums: boolean;
// local settings // local settings
square_thumbs: boolean; square_thumbs: boolean;