summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/app.js25
-rw-r--r--static/styles.css11
2 files changed, 32 insertions, 4 deletions
diff --git a/static/app.js b/static/app.js
index 938cf70..04997a0 100644
--- a/static/app.js
+++ b/static/app.js
@@ -111,15 +111,17 @@ const applyResult = async (film) => {
setValue("#tmdb_id", film.tmdb_id || "");
setPoster(film.poster_url);
- // Check if this is the add form (not edit)
+ const duplicateNotice = document.getElementById("duplicate-notice");
+ if (duplicateNotice) duplicateNotice.hidden = true;
+
const isAddForm = window.location.pathname.endsWith("/films/new");
if (film.tmdb_id) {
try {
- // Fetch full detail for genre and check for rewatches in parallel
- const [detailResponse, rewatchResponse] = await Promise.all([
+ const [detailResponse, rewatchResponse, findResponse] = await Promise.all([
fetch(`/tmdb/detail/${film.tmdb_id}`),
isAddForm ? fetch(`/films/check-rewatch?tmdb_id=${film.tmdb_id}`) : Promise.resolve(null),
+ isAddForm ? fetch(`/films/find?tmdb_id=${film.tmdb_id}`) : Promise.resolve(null),
]);
if (detailResponse.ok) {
@@ -137,8 +139,23 @@ const applyResult = async (film) => {
}
}
}
+
+ if (findResponse && findResponse.ok && duplicateNotice) {
+ const found = await findResponse.json();
+ if (found.matches && found.matches.length > 0) {
+ const shelfLabel = { diary: "Diary", queue: "Queue", abandoned: "Abandoned" };
+ const parts = found.matches.map((m) => {
+ const label = shelfLabel[m.shelf] || m.shelf;
+ const date = m.date_watched
+ ? ` · ${new Date(m.date_watched + "T00:00:00").toLocaleDateString(undefined, { month: "short", year: "numeric" })}`
+ : "";
+ return `<a href="/films/${m.id}" class="inline-link">${label}${date}</a>`;
+ });
+ duplicateNotice.innerHTML = `Already logged — ${parts.join(", ")}`;
+ duplicateNotice.hidden = false;
+ }
+ }
} catch (error) {
- // Fail silently if detail/rewatch fetch fails
console.error("Failed to fetch details", error);
}
}
diff --git a/static/styles.css b/static/styles.css
index 9f8619b..2a6cd04 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -687,6 +687,11 @@ textarea:focus {
margin-top: 12px;
}
+#duplicate-notice {
+ margin-top: 12px;
+ margin-bottom: 0;
+}
+
.tmdb-result {
display: grid;
grid-template-columns: 38px minmax(0, 1fr);
@@ -927,6 +932,12 @@ textarea:focus {
background: linear-gradient(90deg, rgba(240, 184, 77, 0.4), var(--accent));
}
+.stats-overview-row {
+ display: flex;
+ gap: 40px;
+ flex-wrap: wrap;
+}
+
.stats-metric {
display: grid;
gap: 8px;