This commit is contained in:
parent
d019544053
commit
e3f8d48ddb
@ -36,7 +36,6 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
|||||||
const [latest, setLatest] = useHistoryState(unixNow(), "TimelineFollowsLatest");
|
const [latest, setLatest] = useHistoryState(unixNow(), "TimelineFollowsLatest");
|
||||||
const [limit, setLimit] = useState(50);
|
const [limit, setLimit] = useState(50);
|
||||||
const feed = useFollowsTimelineView(limit);
|
const feed = useFollowsTimelineView(limit);
|
||||||
console.log("feed", feed);
|
|
||||||
const { muted, isEventMuted } = useModeration();
|
const { muted, isEventMuted } = useModeration();
|
||||||
|
|
||||||
const oldest = useMemo(() => feed.at(-1)?.created_at, [feed]);
|
const oldest = useMemo(() => feed.at(-1)?.created_at, [feed]);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ID, ReqFilter as Filter, STR, TaggedNostrEvent, UID } from ".";
|
import { ID, ReqFilter as Filter, STR, TaggedNostrEvent, UID } from ".";
|
||||||
import loki from "lokijs";
|
import loki from "lokijs";
|
||||||
|
import debug from "debug";
|
||||||
|
|
||||||
type PackedNostrEvent = {
|
type PackedNostrEvent = {
|
||||||
id: UID;
|
id: UID;
|
||||||
@ -38,6 +39,8 @@ class InMemoryDB {
|
|||||||
setTimeout(() => removeOldest(), 3000);
|
setTimeout(() => removeOldest(), 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#log = debug("InMemoryDB");
|
||||||
|
|
||||||
get(id: string): TaggedNostrEvent | undefined {
|
get(id: string): TaggedNostrEvent | undefined {
|
||||||
const event = this.eventsCollection.by("id", ID(id)); // throw if db not ready yet?
|
const event = this.eventsCollection.by("id", ID(id)); // throw if db not ready yet?
|
||||||
if (event) {
|
if (event) {
|
||||||
@ -120,9 +123,9 @@ class InMemoryDB {
|
|||||||
|
|
||||||
removeOldest(): void {
|
removeOldest(): void {
|
||||||
const count = this.eventsCollection.count();
|
const count = this.eventsCollection.count();
|
||||||
console.log("InMemoryDB: count", count, this.maxSize);
|
this.#log("InMemoryDB: count", count, this.maxSize);
|
||||||
if (count > this.maxSize) {
|
if (count > this.maxSize) {
|
||||||
console.log("InMemoryDB: removing oldest events", count - this.maxSize);
|
this.#log("InMemoryDB: removing oldest events", count - this.maxSize);
|
||||||
this.eventsCollection
|
this.eventsCollection
|
||||||
.chain()
|
.chain()
|
||||||
.simplesort("saved_at")
|
.simplesort("saved_at")
|
||||||
|
Loading…
Reference in New Issue
Block a user