From 29e8a63cb325cc3ede507dd3868f1d361ef4660b Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Wed, 25 Feb 2026 23:20:37 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20rename=20listed=20=E2=86=92=20disco?= =?UTF-8?q?verable=20on=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure rename — no behavioral change. "discoverable" more clearly communicates that the field controls whether a note can be found by others in public listings. --- lexicons/space/remanso/note.json | 4 ++-- src/data/db.ts | 14 +++++++------- src/data/note.ts | 2 +- src/migrations/init.ts | 8 +++++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lexicons/space/remanso/note.json b/lexicons/space/remanso/note.json index 2ffc297..4e7f2d8 100644 --- a/lexicons/space/remanso/note.json +++ b/lexicons/space/remanso/note.json @@ -47,9 +47,9 @@ "description": "Display theme for the note.", "knownValues": ["light", "dark"] }, - "listed": { + "discoverable": { "type": "boolean", - "description": "Whether the note appears in public listings. Defaults to true." + "description": "Whether the note can be discovered by others in public listings. Defaults to true." } } } diff --git a/src/data/db.ts b/src/data/db.ts index df622d1..66d80cf 100644 --- a/src/data/db.ts +++ b/src/data/db.ts @@ -22,10 +22,10 @@ type NoteRow = { export const getNotes = (cursor?: string, limit = 20) => { const notes = cursor ? db.prepare( - "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE listed = 1 AND rkey < ? ORDER BY rkey DESC LIMIT ?", + "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE discoverable = 1 AND rkey < ? ORDER BY rkey DESC LIMIT ?", ).all(cursor, limit) : db.prepare( - "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE listed = 1 ORDER BY rkey DESC LIMIT ?", + "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE discoverable = 1 ORDER BY rkey DESC LIMIT ?", ).all(limit); return { @@ -37,10 +37,10 @@ export const getNotes = (cursor?: string, limit = 20) => { export const getNotesByDid = (did: string, cursor?: string, limit = 20) => { const notes = cursor ? db.prepare( - "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE listed = 1 AND did = ? AND rkey < ? ORDER BY rkey DESC LIMIT ?", + "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE discoverable = 1 AND did = ? AND rkey < ? ORDER BY rkey DESC LIMIT ?", ).all(did, cursor, limit) : db.prepare( - "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE listed = 1 AND did = ? ORDER BY rkey DESC LIMIT ?", + "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE discoverable = 1 AND did = ? ORDER BY rkey DESC LIMIT ?", ).all(did, limit); return { @@ -108,20 +108,20 @@ export const upsertNote = (note: Note) => { createdAt, did, rkey, - listed + discoverable ) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(did, rkey) DO UPDATE SET title = excluded.title, publishedAt = excluded.publishedAt, - listed = excluded.listed + discoverable = excluded.discoverable `, note.title, note.publishedAt ? new Date(note.publishedAt).toISOString() : now, note.createdAt ? new Date(note.createdAt).toISOString() : now, note.did, note.rkey, - note.listed !== false ? 1 : 0, + note.discoverable !== false ? 1 : 0, ); }; diff --git a/src/data/note.ts b/src/data/note.ts index c9d80d6..a0fc354 100644 --- a/src/data/note.ts +++ b/src/data/note.ts @@ -4,5 +4,5 @@ export type Note = { title: string; publishedAt: string; createdAt: string; - listed?: boolean; + discoverable?: boolean; }; diff --git a/src/migrations/init.ts b/src/migrations/init.ts index d0fc238..494f2dd 100644 --- a/src/migrations/init.ts +++ b/src/migrations/init.ts @@ -7,7 +7,7 @@ db.exec(` createdAt DATETIME NOT NULL, did TEXT NOT NULL, rkey TEXT NOT NULL, - listed INTEGER NOT NULL DEFAULT 1, + discoverable INTEGER NOT NULL DEFAULT 1, PRIMARY KEY (did, rkey) ); `); @@ -20,6 +20,12 @@ try { // Column already exists — no-op } +try { + db.exec(`ALTER TABLE note RENAME COLUMN listed TO discoverable;`); +} catch { + // Column already renamed or doesn't exist — no-op +} + db.exec(` CREATE TABLE IF NOT EXISTS state ( key TEXT PRIMARY KEY,