refactor: rename listed → discoverable on note
Pure rename — no behavioral change. "discoverable" more clearly communicates that the field controls whether a note can be found by others in public listings.
This commit is contained in:
@@ -47,9 +47,9 @@
|
|||||||
"description": "Display theme for the note.",
|
"description": "Display theme for the note.",
|
||||||
"knownValues": ["light", "dark"]
|
"knownValues": ["light", "dark"]
|
||||||
},
|
},
|
||||||
"listed": {
|
"discoverable": {
|
||||||
"type": "boolean",
|
"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."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ type NoteRow = {
|
|||||||
export const getNotes = (cursor?: string, limit = 20) => {
|
export const getNotes = (cursor?: string, limit = 20) => {
|
||||||
const notes = cursor
|
const notes = cursor
|
||||||
? db.prepare(
|
? 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<NoteRow>(cursor, limit)
|
).all<NoteRow>(cursor, limit)
|
||||||
: db.prepare(
|
: 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<NoteRow>(limit);
|
).all<NoteRow>(limit);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -37,10 +37,10 @@ export const getNotes = (cursor?: string, limit = 20) => {
|
|||||||
export const getNotesByDid = (did: string, cursor?: string, limit = 20) => {
|
export const getNotesByDid = (did: string, cursor?: string, limit = 20) => {
|
||||||
const notes = cursor
|
const notes = cursor
|
||||||
? db.prepare(
|
? 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<NoteRow>(did, cursor, limit)
|
).all<NoteRow>(did, cursor, limit)
|
||||||
: db.prepare(
|
: 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<NoteRow>(did, limit);
|
).all<NoteRow>(did, limit);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -108,20 +108,20 @@ export const upsertNote = (note: Note) => {
|
|||||||
createdAt,
|
createdAt,
|
||||||
did,
|
did,
|
||||||
rkey,
|
rkey,
|
||||||
listed
|
discoverable
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
ON CONFLICT(did, rkey)
|
ON CONFLICT(did, rkey)
|
||||||
DO UPDATE SET
|
DO UPDATE SET
|
||||||
title = excluded.title,
|
title = excluded.title,
|
||||||
publishedAt = excluded.publishedAt,
|
publishedAt = excluded.publishedAt,
|
||||||
listed = excluded.listed
|
discoverable = excluded.discoverable
|
||||||
`,
|
`,
|
||||||
note.title,
|
note.title,
|
||||||
note.publishedAt ? new Date(note.publishedAt).toISOString() : now,
|
note.publishedAt ? new Date(note.publishedAt).toISOString() : now,
|
||||||
note.createdAt ? new Date(note.createdAt).toISOString() : now,
|
note.createdAt ? new Date(note.createdAt).toISOString() : now,
|
||||||
note.did,
|
note.did,
|
||||||
note.rkey,
|
note.rkey,
|
||||||
note.listed !== false ? 1 : 0,
|
note.discoverable !== false ? 1 : 0,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ export type Note = {
|
|||||||
title: string;
|
title: string;
|
||||||
publishedAt: string;
|
publishedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
listed?: boolean;
|
discoverable?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ db.exec(`
|
|||||||
createdAt DATETIME NOT NULL,
|
createdAt DATETIME NOT NULL,
|
||||||
did TEXT NOT NULL,
|
did TEXT NOT NULL,
|
||||||
rkey TEXT NOT NULL,
|
rkey TEXT NOT NULL,
|
||||||
listed INTEGER NOT NULL DEFAULT 1,
|
discoverable INTEGER NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY (did, rkey)
|
PRIMARY KEY (did, rkey)
|
||||||
);
|
);
|
||||||
`);
|
`);
|
||||||
@@ -20,6 +20,12 @@ try {
|
|||||||
// Column already exists — no-op
|
// 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(`
|
db.exec(`
|
||||||
CREATE TABLE IF NOT EXISTS state (
|
CREATE TABLE IF NOT EXISTS state (
|
||||||
key TEXT PRIMARY KEY,
|
key TEXT PRIMARY KEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user