fix #14740: re-check retention eligibility and validate retention_days
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -266,20 +266,23 @@
|
||||
settings ? delayError(settings.start_after_secs, 1, 30, 'Start nach') : '',
|
||||
)
|
||||
let endError = $derived(settings ? delayError(settings.end_after_secs, 3, 120, 'Ende nach') : '')
|
||||
/** The range the backend accepts (`RETENTION_DAYS`). */
|
||||
function retentionValid(days: number | null | undefined): days is number {
|
||||
return typeof days === 'number' && Number.isInteger(days) && days >= 1 && days <= 3650
|
||||
}
|
||||
|
||||
/** The retention period in the hint ("7 Tage", "1 Tag"; "N Tage" while
|
||||
* the field holds no valid value). */
|
||||
let retentionShown = $derived.by(() => {
|
||||
const days = settings?.retention_days
|
||||
if (days === undefined || !Number.isInteger(days) || days < 1) return 'N Tage'
|
||||
if (!retentionValid(days)) return 'N Tage'
|
||||
return days === 1 ? '1 Tag' : `${days} Tage`
|
||||
})
|
||||
|
||||
async function persist() {
|
||||
if (!settings) return
|
||||
if (startError || endError) throw startError || endError
|
||||
if (!Number.isInteger(settings.retention_days) || settings.retention_days < 1) {
|
||||
throw 'Aufbewahrung: bitte eine ganze Zahl ab 1 eingeben'
|
||||
}
|
||||
if (!retentionValid(settings.retention_days)) throw 'Aufbewahrung: 1–3650 Tage'
|
||||
settings.vocabulary = vocabularyText.split('\n')
|
||||
await saveSettings($state.snapshot(settings))
|
||||
// Re-read: the backend trims/dedupes the vocabulary, so the textarea
|
||||
@@ -485,7 +488,7 @@
|
||||
<option value="en">Englisch</option>
|
||||
</select>
|
||||
<label for="retention">Aufbewahrung der Audiodateien</label>
|
||||
<span><input id="retention" type="number" min="1" bind:value={settings.retention_days} /> Tage</span>
|
||||
<span><input id="retention" type="number" min="1" max="3650" bind:value={settings.retention_days} /> Tage</span>
|
||||
<span></span>
|
||||
<span class="muted">
|
||||
Audio wird {retentionShown} nach der Transkription gelöscht, nicht transkribierte
|
||||
|
||||
Reference in New Issue
Block a user