Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat: add legal acknowledgment and recovery dialogs with functionality
Tonho925f10f8d9a9
diff --git a/.weblate b/.weblatenew file mode 100644index 00000000..c67a9434--- /dev/null+++ b/.weblate@@ -0,0 +1,9 @@+[weblate]+url = https://hosted.weblate.org/api/+translation = omniget/frontend-json++[component "omniget/frontend-json"]+slug = omniget/frontend-json+file_format = json-nested+filemask = src/lib/i18n/*.json+template = src/lib/i18n/en.jsondiff --git a/src/components/dialog/LegalDialog.svelte b/src/components/dialog/LegalDialog.sveltenew file mode 100644index 00000000..efb85442--- /dev/null+++ b/src/components/dialog/LegalDialog.svelte@@ -0,0 +1,118 @@+<script lang="ts">+ import { invoke } from "@tauri-apps/api/core";+ import { t } from "$lib/i18n";+ import { getSettings, loadSettings } from "$lib/stores/settings-store.svelte";+ import DialogContainer from "./DialogContainer.svelte";++ const settings = $derived(getSettings());+ let isOpen = $state(false);+ let busy = $state(false);++ $effect(() => {+ if (!settings) return;+ if (settings.onboarding_completed && !settings.legal_acknowledged) {+ isOpen = true;+ }+ });++ async function acknowledge() {+ if (busy) return;+ busy = true;+ try {+ await invoke("mark_legal_acknowledged");+ await loadSettings();+ isOpen = false;+ } catch (_) {+ isOpen = false;+ } finally {+ busy = false;+ }+ }+</script>++<DialogContainer bind:isOpen onClose={() => { if (!settings?.legal_acknowledged) acknowledge(); }} titleId="legal-dialog-title">+ <div class="legal-header">+ <h2 id="legal-dialog-title">{$t("legal.title")}</h2>+ </div>++ <div class="legal-body">+ <p>{$t("legal.body_paragraph_1")}</p>+ <p>{$t("legal.body_paragraph_2")}</p>+ <ul>+ <li>{$t("legal.rule_copyright")}</li>+ <li>{$t("legal.rule_tos")}</li>+ <li>{$t("legal.rule_personal_use")}</li>+ </ul>+ </div>++ <div class="legal-footer">+ <button class="button primary" onclick={acknowledge} disabled={busy}>+ {$t("legal.acknowledge")}+ </button>+ </div>+</DialogContainer>++<style>+ .legal-header {+ padding: 20px 24px 4px;+ }++ .legal-header h2 {+ margin: 0;+ font-size: 17px;+ font-weight: 600;+ color: var(--foreground);+ }++ .legal-body {+ padding: 8px 24px 16px;+ color: var(--foreground);+ font-size: 13px;+ line-height: 1.55;+ max-height: 50vh;+ overflow-y: auto;+ }++ .legal-body p {+ margin: 0 0 10px 0;+ }++ .legal-body ul {+ margin: 4px 0 0 0;+ padding-left: 18px;+ display: flex;+ flex-direction: column;+ gap: 4px;+ }++ .legal-body li {+ color: var(--foreground-secondary);+ font-size: 12.5px;+ }++ .legal-footer {+ display: flex;+ justify-content: flex-end;+ padding: 8px 20px 20px;+ }++ .button.primary {+ background: var(--blue);+ color: var(--on-accent);+ border: none;+ padding: 8px 18px;+ border-radius: var(--border-radius);+ font-size: 13px;+ font-weight: 600;+ cursor: pointer;+ }++ .button.primary:disabled {+ opacity: 0.6;+ cursor: wait;+ }++ .button.primary:hover:not(:disabled) {+ filter: brightness(1.08);+ }+</style>diff --git a/src/components/dialog/RecoveryDialog.svelte b/src/components/dialog/RecoveryDialog.sveltenew file mode 100644index 00000000..9bd18b53--- /dev/null+++ b/src/components/dialog/RecoveryDialog.svelte@@ -0,0 +1,211 @@+<script lang="ts">+ import { onMount } from "svelte";+ import { listen } from "@tauri-apps/api/event";+ import { invoke } from "@tauri-apps/api/core";+ import DialogContainer from "./DialogContainer.svelte";+ import { showToast } from "$lib/stores/toast-store.svelte";+ import { t } from "$lib/i18n";++ type RecoveryItem = {+ id: number;+ url: string;+ title: string;+ platform: string;+ output_dir: string;+ download_mode: string | null;+ quality: string | null;+ format_id: string | null;+ referer: string | null;+ };++ let isOpen = $state(false);+ let items = $state<RecoveryItem[]>([]);+ let busy = $state(false);++ async function loadItems() {+ try {+ const fetched = await invoke<RecoveryItem[]>("get_recovery_items");+ if (fetched.length > 0) {+ items = fetched;+ isOpen = true;+ }+ } catch {}+ }++ onMount(() => {+ let unlisten: (() => void) | undefined;+ listen<{ count: number }>("recovery-available", () => {+ loadItems();+ }).then((fn) => {+ unlisten = fn;+ });+ loadItems();+ return () => {+ unlisten?.();+ };+ });++ async function discard() {+ if (busy) return;+ busy = true;+ try {+ await invoke("discard_recovery");+ items = [];+ isOpen = false;+ } finally {+ busy = false;+ }+ }++ async function restore() {+ if (busy) return;+ busy = true;+ try {+ const restored = await invoke<number>("restore_recovery");+ showToast("info", $t("recovery.restored", { values: { count: restored } }));+ items = [];+ isOpen = false;+ } catch (e: any) {+ const msg = typeof e === "string" ? e : e.message ?? "";+ if (msg) showToast("error", msg);+ } finally {+ busy = false;+ }+ }+</script>++<DialogContainer bind:isOpen titleId="recovery-title" onClose={discard}>+ <h3 id="recovery-title" class="dialog-title">+ {$t("recovery.title")}+ </h3>+ <p class="dialog-body">+ {$t("recovery.message", { values: { count: items.length } })}+ </p>+ {#if items.length > 0}+ <ul class="dialog-items">+ {#each items.slice(0, 5) as item (item.id)}+ <li class="dialog-item">+ <span class="item-platform">{item.platform}</span>+ <span class="item-title">{item.title}</span>+ </li>+ {/each}+ {#if items.length > 5}+ <li class="dialog-item dialog-item-more">+ {$t("recovery.more", { values: { count: items.length - 5 } })}+ </li>+ {/if}+ </ul>+ {/if}+ <div class="dialog-actions">+ <button type="button" class="button button-secondary" onclick={discard} disabled={busy}>+ {$t("recovery.discard")}+ </button>+ <button type="button" class="button button-primary" onclick={restore} disabled={busy}>+ {$t("recovery.restore")}+ </button>+ </div>+</DialogContainer>++<style>+ .dialog-title {+ margin: 0;+ padding: calc(var(--padding) * 1.25) calc(var(--padding) * 1.5) calc(var(--padding) * 0.75);+ font-size: 15px;+ font-weight: 600;+ color: var(--secondary);+ }++ .dialog-body {+ margin: 0;+ padding: 0 calc(var(--padding) * 1.5) calc(var(--padding) * 0.75);+ font-size: 13px;+ line-height: 1.5;+ color: var(--secondary);+ opacity: 0.85;+ }++ .dialog-items {+ list-style: none;+ margin: 0;+ padding: 0 calc(var(--padding) * 1.5) calc(var(--padding) * 1);+ display: flex;+ flex-direction: column;+ gap: 4px;+ max-height: 200px;+ overflow-y: auto;+ }++ .dialog-item {+ display: flex;+ gap: 8px;+ align-items: baseline;+ font-size: 12px;+ color: var(--gray);+ }++ .item-platform {+ font-weight: 600;+ color: var(--secondary);+ min-width: 70px;+ }++ .item-title {+ flex: 1;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .dialog-item-more {+ font-style: italic;+ opacity: 0.6;+ }++ .dialog-actions {+ display: flex;+ justify-content: flex-end;+ gap: calc(var(--padding) * 0.5);+ padding: calc(var(--padding) * 0.75) calc(var(--padding) * 1.5) calc(var(--padding) * 1.25);+ border-top: 1px solid var(--content-border);+ }++ .button {+ padding: 8px 16px;+ font-size: 12.5px;+ font-weight: 500;+ border-radius: var(--border-radius);+ border: none;+ cursor: pointer;+ transition: background 0.15s, color 0.15s;+ }++ .button-secondary {+ background: transparent;+ color: var(--secondary);+ border: 1px solid var(--content-border);+ }++ .button-secondary:hover {+ background: var(--sidebar-highlight);+ }++ .button-primary {+ background: var(--cta);+ color: var(--on-cta);+ }++ .button-primary:hover {+ background: var(--cta-hover);+ }++ .button:disabled {+ opacity: 0.5;+ cursor: default;+ }++ .button:focus-visible {+ outline: var(--focus-ring);+ outline-offset: var(--focus-ring-offset);+ }+</style>diff --git a/src/components/dialog/ShortcutsDialog.svelte b/src/components/dialog/ShortcutsDialog.svelteindex e16ae010..160cbc5c 100644--- a/src/components/dialog/ShortcutsDialog.svelte+++ b/src/components/dialog/ShortcutsDialog.svelte@@ -7,7 +7,7 @@let isOpen = $state(false);const settings = $derived(getSettings());- const globalHotkey = $derived(settings?.download.hotkey || "Ctrl+Shift+V");+ const globalHotkey = $derived(settings?.download.hotkey_binding || "Ctrl+Shift+V");type Shortcut = { keysKey?: string; keys?: string; labelKey: string };type Section = { titleKey: string; items: Shortcut[] };