fix(watchlist): strip surrounding quotes from prev user fields (notion_url round-trip)

This commit is contained in:
afiqzudinhadi 2026-07-30 12:37:52 +08:00
parent eeaa37469c
commit e8cb9b93fe
3 changed files with 16 additions and 5 deletions

View file

@ -1,4 +1,5 @@
import type { WatchlistRecord } from 'packages/obsidian/src/watchlist/schema';
import { stripQuotes } from 'packages/obsidian/src/watchlist/parse';
export type TmdbDetail = Record<string, any>;
@ -136,10 +137,10 @@ export function buildRecord(details: TmdbDetail, isMovie: boolean, prev: Record<
}
// ---- preserve user-managed fields ----
let watchStatus = prev['watch_status'] || 'Unwatched';
const rating = prev['rating'] || '0';
const ratingStars = prev['rating_stars'] ?? '';
const rawNotionUrl = prev['notion_url'] || '';
let watchStatus = stripQuotes(prev['watch_status']) || 'Unwatched';
const rating = stripQuotes(prev['rating']) || '0';
const ratingStars = stripQuotes(prev['rating_stars']);
const rawNotionUrl = stripQuotes(prev['notion_url']);
const notionUrl = rawNotionUrl === 'null' ? '' : rawNotionUrl; // quotedOrNull renders empty as literal `null` — don't round-trip it as a value
// ---- TV watch-status rule: new episode aired since last sync ----

View file

@ -22,7 +22,7 @@ export function extractMyNotes(body: string): string {
return m ? m[1].trim() : '';
}
function stripQuotes(s: string | undefined): string {
export function stripQuotes(s: string | undefined): string {
return (s ?? '').trim().replace(/^"|"$/g, '');
}