mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
Only show albums dropdown if there are albums created
This commit is contained in:
parent
d84cc450f1
commit
ec91762169
1 changed files with 29 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
import { recentAlbumsDropdown } from '$lib/stores/preferences.store';
|
import { recentAlbumsDropdown } from '$lib/stores/preferences.store';
|
||||||
import { featureFlags } from '$lib/stores/server-config.store';
|
import { featureFlags } from '$lib/stores/server-config.store';
|
||||||
import { preferences } from '$lib/stores/user.store';
|
import { preferences } from '$lib/stores/user.store';
|
||||||
|
import { getAllAlbums } from '@immich/sdk';
|
||||||
import {
|
import {
|
||||||
mdiAccount,
|
mdiAccount,
|
||||||
mdiAccountMultiple,
|
mdiAccountMultiple,
|
||||||
|
|
@ -31,6 +32,7 @@
|
||||||
mdiTrashCan,
|
mdiTrashCan,
|
||||||
mdiTrashCanOutline,
|
mdiTrashCanOutline,
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import { fly } from 'svelte/transition';
|
import { fly } from 'svelte/transition';
|
||||||
import SideBarLink from './side-bar-link.svelte';
|
import SideBarLink from './side-bar-link.svelte';
|
||||||
|
|
@ -44,6 +46,22 @@
|
||||||
let isTrashSelected: boolean = $state(false);
|
let isTrashSelected: boolean = $state(false);
|
||||||
let isUtilitiesSelected: boolean = $state(false);
|
let isUtilitiesSelected: boolean = $state(false);
|
||||||
let isLockedFolderSelected: boolean = $state(false);
|
let isLockedFolderSelected: boolean = $state(false);
|
||||||
|
let hasAlbums = $state(false);
|
||||||
|
let albumsBaseProps = $derived({
|
||||||
|
title: $t('albums'),
|
||||||
|
href: resolve('/(user)/albums'),
|
||||||
|
icon: mdiImageAlbum,
|
||||||
|
flippedLogo: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
try {
|
||||||
|
const albums = await getAllAlbums({});
|
||||||
|
hasAlbums = albums.length > 0;
|
||||||
|
} catch {
|
||||||
|
hasAlbums = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Sidebar ariaLabel={$t('primary')}>
|
<Sidebar ariaLabel={$t('primary')}>
|
||||||
|
|
@ -96,19 +114,17 @@
|
||||||
bind:isSelected={isFavoritesSelected}
|
bind:isSelected={isFavoritesSelected}
|
||||||
></SideBarLink>
|
></SideBarLink>
|
||||||
|
|
||||||
<SideBarLink
|
{#if hasAlbums}
|
||||||
title={$t('albums')}
|
<SideBarLink {...albumsBaseProps} bind:dropdownOpen={$recentAlbumsDropdown}>
|
||||||
href={resolve('/(user)/albums')}
|
|
||||||
icon={mdiImageAlbum}
|
|
||||||
flippedLogo
|
|
||||||
bind:dropdownOpen={$recentAlbumsDropdown}
|
|
||||||
>
|
|
||||||
{#snippet dropDownContent()}
|
{#snippet dropDownContent()}
|
||||||
<span in:fly={{ y: -20 }} class="hidden md:block">
|
<span in:fly={{ y: -20 }} class="hidden md:block">
|
||||||
<RecentAlbums />
|
<RecentAlbums />
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</SideBarLink>
|
</SideBarLink>
|
||||||
|
{:else}
|
||||||
|
<SideBarLink {...albumsBaseProps} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $preferences.tags.enabled && $preferences.tags.sidebarWeb}
|
{#if $preferences.tags.enabled && $preferences.tags.sidebarWeb}
|
||||||
<SideBarLink title={$t('tags')} href={resolve('/(user)/tags')} icon={mdiTagMultipleOutline} flippedLogo />
|
<SideBarLink title={$t('tags')} href={resolve('/(user)/tags')} icon={mdiTagMultipleOutline} flippedLogo />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue