MLE: Try to ensure db exists

This commit is contained in:
thororen1234 2026-04-12 20:25:03 -04:00
parent 6e1ef5efa3
commit b59f42cd18
No known key found for this signature in database

View file

@ -68,6 +68,7 @@ async function cacheRecord(record?: DBMessageRecord | null) {
}
export async function initIDB() {
if (db) return;
db = await openDB<MLIDB>(DB_NAME, DB_VERSION, {
upgrade(db) {
const messageStore = db.createObjectStore("messages", { keyPath: "message_id" });
@ -211,6 +212,7 @@ export async function getMessagesByChannelAndAfterTimestampIDB(channel_id: strin
export async function addMessageIDB(message: LoggedMessageJSON, status: DBMessageStatus) {
stripTransientRenderState(message);
if (!db) await initIDB();
await db.put("messages", {
channel_id: message.channel_id,
message_id: message.id,