feat: Requests / Add to Library Rework - Unmonitored album default + … (#25)
* feat: Requests / Add to Library Rework - Unmonitored album default + Resilience * checking for source + refresh album logic * artist monitoring + auto downloading + various request fixes * synchronous album requests * format
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import { appendAudioDBSizeSuffix } from '$lib/utils/imageSuffix';
|
||||
import { imageSettingsStore } from '$lib/stores/imageSettings';
|
||||
import ArtistLinks from './ArtistLinks.svelte';
|
||||
import ArtistMonitoringToggle from './ArtistMonitoringToggle.svelte';
|
||||
import BackButton from './BackButton.svelte';
|
||||
import HeroBackdrop from './HeroBackdrop.svelte';
|
||||
import { getApiUrl } from '$lib/utils/api';
|
||||
@@ -165,6 +166,20 @@
|
||||
{#if validLinks.length > 0}
|
||||
<ArtistLinks links={validLinks} />
|
||||
{/if}
|
||||
|
||||
{#if artist.in_lidarr}
|
||||
<div class="mt-3">
|
||||
<ArtistMonitoringToggle
|
||||
artistMbid={artist.musicbrainz_id}
|
||||
monitored={artist.monitored ?? false}
|
||||
autoDownload={artist.auto_download ?? false}
|
||||
on:change={(e) => {
|
||||
artist.monitored = e.detail.monitored;
|
||||
artist.auto_download = e.detail.autoDownload;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
import { Eye, Download } from 'lucide-svelte';
|
||||
import { api } from '$lib/api/client';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let artistMbid: string;
|
||||
export let monitored: boolean = false;
|
||||
export let autoDownload: boolean = false;
|
||||
export let disabled: boolean = false;
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
change: { monitored: boolean; autoDownload: boolean };
|
||||
}>();
|
||||
|
||||
let saving = false;
|
||||
|
||||
async function updateMonitoring(newMonitored: boolean, newAutoDownload: boolean) {
|
||||
if (saving) return;
|
||||
saving = true;
|
||||
try {
|
||||
await api.global.put(`/api/v1/artists/${artistMbid}/monitoring`, {
|
||||
monitored: newMonitored,
|
||||
auto_download: newAutoDownload
|
||||
});
|
||||
monitored = newMonitored;
|
||||
autoDownload = newAutoDownload;
|
||||
dispatch('change', { monitored, autoDownload });
|
||||
} catch {
|
||||
// revert is implicit: we only update state on success
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMonitorToggle() {
|
||||
const newMonitored = !monitored;
|
||||
const newAutoDownload = newMonitored ? autoDownload : false;
|
||||
await updateMonitoring(newMonitored, newAutoDownload);
|
||||
}
|
||||
|
||||
async function handleAutoDownloadToggle() {
|
||||
await updateMonitoring(monitored, !autoDownload);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex items-center gap-4 flex-wrap">
|
||||
<label class="label cursor-pointer gap-2" aria-label="Monitor this artist">
|
||||
<Eye class="h-4 w-4 text-base-content/70" />
|
||||
<span class="text-sm text-base-content/70">Monitor</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={monitored}
|
||||
on:change={handleMonitorToggle}
|
||||
disabled={disabled || saving}
|
||||
class="toggle toggle-sm toggle-accent"
|
||||
/>
|
||||
</label>
|
||||
<label
|
||||
class="label cursor-pointer gap-2 transition-opacity"
|
||||
class:opacity-40={!monitored}
|
||||
aria-label="Download new releases"
|
||||
>
|
||||
<Download class="h-4 w-4 text-base-content/70" />
|
||||
<span class="text-sm text-base-content/70">Download new releases</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={autoDownload}
|
||||
on:change={handleAutoDownloadToggle}
|
||||
disabled={disabled || saving || !monitored}
|
||||
class="toggle toggle-sm toggle-accent"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
@@ -147,6 +147,9 @@ export type ArtistInfo = {
|
||||
aliases: string[];
|
||||
external_links: ExternalLink[];
|
||||
in_library: boolean;
|
||||
in_lidarr?: boolean;
|
||||
monitored?: boolean;
|
||||
auto_download?: boolean;
|
||||
albums: ReleaseGroup[];
|
||||
singles: ReleaseGroup[];
|
||||
eps: ReleaseGroup[];
|
||||
|
||||
@@ -12,6 +12,9 @@ export type AlbumRequestContext = {
|
||||
artist?: string;
|
||||
album?: string;
|
||||
year?: number | null;
|
||||
artistMbid?: string;
|
||||
monitorArtist?: boolean;
|
||||
autoDownloadArtist?: boolean;
|
||||
};
|
||||
|
||||
export async function requestAlbum(
|
||||
@@ -23,7 +26,10 @@ export async function requestAlbum(
|
||||
musicbrainz_id: musicbrainzId,
|
||||
artist: context?.artist ?? undefined,
|
||||
album: context?.album ?? undefined,
|
||||
year: context?.year ?? undefined
|
||||
year: context?.year ?? undefined,
|
||||
artist_mbid: context?.artistMbid ?? undefined,
|
||||
monitor_artist: context?.monitorArtist ?? false,
|
||||
auto_download_artist: context?.autoDownloadArtist ?? false
|
||||
});
|
||||
|
||||
libraryStore.addRequested(musicbrainzId);
|
||||
|
||||
Reference in New Issue
Block a user