diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index da6e783..0499235 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-utils/schema.json", + "$schema": "https://schema.tauri.app/config/2", "productName": "Discord Presence", "version": "0.1.0", "identifier": "org.racooncity.discord-presence", @@ -19,7 +19,22 @@ } ], "security": { - "csp": "null" + "csp": null } + }, + "bundle": { + "active": true, + "targets": [ + "nsis", + "deb", + "appimage" + ], + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] } } \ No newline at end of file diff --git a/ui/main.js b/ui/main.js index f57fc54..17d4a4f 100644 --- a/ui/main.js +++ b/ui/main.js @@ -1,9 +1,11 @@ const { invoke } = window.__TAURI__.core; +// ── State ────────────────────────────────────────────── let connected = false; let timerStart = null; let timerInterval = null; +// ── Elements ─────────────────────────────────────────── const appIdInput = document.getElementById("appId"); const statusInput = document.getElementById("statusInput"); const detailsInput = document.getElementById("detailsInput"); @@ -18,6 +20,7 @@ const previewStatus = document.getElementById("previewStatus"); const previewDetails = document.getElementById("previewDetails"); const previewTime = document.getElementById("previewTime"); +// ── Connection ───────────────────────────────────────── async function toggleConnection() { if (connected) { try { @@ -66,6 +69,7 @@ function setConnected(state) { } } +// ── Activity ─────────────────────────────────────────── async function setActivity() { const status = statusInput.value.trim(); const details = detailsInput.value.trim(); @@ -76,6 +80,7 @@ async function setActivity() { try { await invoke("set_activity", { status, details, showTime, elapsedSeconds }); + // Update preview timer to reflect the spoofed offset if (elapsedSeconds > 0) { timerStart = Date.now() - (elapsedSeconds * 1000); } @@ -96,6 +101,7 @@ async function clearActivity() { } } +// ── Preview ──────────────────────────────────────────── function updatePreview(status, details, showTime) { previewTitle.textContent = appIdInput.value ? "Your App Name" : "—"; @@ -127,6 +133,7 @@ function resetPreview() { previewTime.classList.add("hidden"); } +// Live-update the preview as you type statusInput.addEventListener("input", () => { if (previewStatus.textContent || statusInput.value) { previewStatus.textContent = statusInput.value || ""; @@ -140,10 +147,12 @@ detailsInput.addEventListener("input", () => { } }); +// Submit on Enter from either input statusInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); }); detailsInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); }); appIdInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && !connected) toggleConnection(); }); +// ── Timer ────────────────────────────────────────────── function startTimer() { stopTimer(); timerInterval = setInterval(() => { @@ -167,6 +176,7 @@ function stopTimer() { } } +// ── Help Modal ───────────────────────────────────────── function openHelp() { document.getElementById("helpModal").classList.remove("hidden"); } @@ -175,10 +185,12 @@ function closeHelp() { document.getElementById("helpModal").classList.add("hidden"); } +// Close help on Escape document.addEventListener("keydown", (e) => { if (e.key === "Escape") closeHelp(); }); +// ── Toast ────────────────────────────────────────────── function toast(msg, type = "neutral") { const container = document.getElementById("toastContainer"); const colors = {