gubes mirror. how does this work
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

more history improvements

leah 08ad4a78 36310c14

+12 -17
+1 -1
core/history.ts
··· 40 40 } 41 41 42 42 const msgs = await conn.collect_batch("chathistory", { mask: true, params: [target] }); 43 - console.log(msgs); 43 + 44 44 return msgs; 45 45 }
+7 -10
neo/src/chat/history.ts
··· 3 3 import { IrcMessage } from "tubes_core/parser"; 4 4 import Storage from "./storage"; 5 5 6 + const fuzz = 1; 6 7 export default async function tubes_history( 7 8 conn: Connection, 8 9 ...[target, range, limit]: FetchHistoryParams ··· 32 33 33 34 if (res.length < limit) { 34 35 let more = await chathistory( 35 - conn, 36 - target, 37 - { before: res[0]?.timestamp ?? new Date(Date.now()) }, 36 + conn, 37 + target, 38 + { before: new Date((res[0]?.timestamp?.getTime() ?? Date.now()) - fuzz) }, 38 39 limit - res.length 39 40 ); 40 41 if (conn.debug) { ··· 45 46 } 46 47 res = more.concat(res); 47 48 // if you start seeing message duplication, this is the place to look 48 - // for (const msg of res) { 49 - // try { 50 - // await Storage.store_message(msg, conn); 51 - // } catch (e) { 52 - // console.error("failed to store chathistory message:", e); 53 - // } 54 - // } 49 + for (const msg of res) { 50 + await Storage.store_message(msg, conn); 51 + } 55 52 } 56 53 57 54 return res;
+4 -6
neo/src/chat/storage.ts
··· 26 26 27 27 static async init() { 28 28 const db = await idb.openDB(db_name, version, { 29 - upgrade(db, old, _, transaction) { 29 + upgrade(db, old) { 30 30 switch (old) { 31 31 case 0: { 32 32 const msgs = db.createObjectStore("messages", { 33 33 keyPath: ["id", "target", "connection_id", "adapter_id"], 34 34 }); 35 35 msgs.createIndex("timestamps", "timestamp"); 36 - break; 37 - } 38 - case 1: { 39 - const msgs = transaction.objectStore("messages"); 40 36 msgs.createIndex( 41 37 "everything_timestamp", 42 38 ["timestamp", "target", "connection_id", "adapter_id"], 43 39 { unique: true }, 44 40 ); 41 + 42 + break; 45 43 } 46 44 } 47 45 } ··· 57 55 const trans = this.db.transaction("messages", "readwrite"); 58 56 59 57 const store = trans.objectStore("messages"); 60 - const key = await store.add(stored); 58 + const key = await store.put(stored); 61 59 62 60 trans.commit(); 63 61