This commit is contained in:
parent
897bb46706
commit
0901e54ab6
@ -36,9 +36,12 @@ class ToasterSlots extends ExternalStore<Array<ToastNotification>> {
|
||||
|
||||
#eatToast() {
|
||||
const now = unixNow();
|
||||
this.#stack = this.#stack.filter(a => (a.expire ?? 0) > now);
|
||||
const newStack = this.#stack.filter(a => (a.expire ?? 0) > now);
|
||||
if (newStack.length !== this.#stack.length) {
|
||||
this.#stack = newStack;
|
||||
this.notifyChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const Toastore = new ToasterSlots();
|
||||
|
@ -13,7 +13,7 @@ export function useNotificationsView() {
|
||||
leaveOpen: true,
|
||||
});
|
||||
if (publicKey) {
|
||||
rb.withFilter().kinds(kinds).tag("p", [publicKey]);
|
||||
rb.withFilter().kinds(kinds).tag("p", [publicKey]).limit(100);
|
||||
}
|
||||
return rb;
|
||||
}, [publicKey]);
|
||||
|
@ -1,43 +1,15 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import fuzzySearch from "@/Db/FuzzySearch";
|
||||
import useTimelineFeed, { TimelineFeedOptions, TimelineSubject } from "@/Feed/TimelineFeed";
|
||||
import { debounce } from "@/Utils";
|
||||
|
||||
import useWoT from "./useWoT";
|
||||
|
||||
const options: TimelineFeedOptions = { method: "LIMIT_UNTIL" };
|
||||
|
||||
export default function useProfileSearch(search: string) {
|
||||
const [debouncedSearch, setDebouncedSearch] = useState(search);
|
||||
|
||||
useEffect(() => {
|
||||
return debounce(500, () => {
|
||||
setDebouncedSearch(search);
|
||||
});
|
||||
}, [search]);
|
||||
|
||||
const subject = useMemo(
|
||||
() =>
|
||||
({
|
||||
type: "profile_keyword",
|
||||
items: debouncedSearch ? [debouncedSearch] : [],
|
||||
discriminator: debouncedSearch,
|
||||
}) as TimelineSubject,
|
||||
[debouncedSearch],
|
||||
);
|
||||
const feed = useTimelineFeed(subject, options);
|
||||
const results = useMemo(() => {
|
||||
export default function useProfileSearch(search: string | undefined) {
|
||||
return userSearch(search);
|
||||
}, [search, feed]);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
export function userSearch(search: string) {
|
||||
export function userSearch(search: string | undefined) {
|
||||
const wot = useWoT();
|
||||
const searchString = search.trim();
|
||||
const fuseResults = fuzzySearch.search(searchString);
|
||||
const searchString = search?.trim() ?? "";
|
||||
const fuseResults = (searchString?.length ?? 0) > 0 ? fuzzySearch.search(searchString) : [];
|
||||
|
||||
const followDistanceNormalizationFactor = 3;
|
||||
const seenIds = new Set();
|
||||
|
@ -1,19 +1,11 @@
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useNotificationsView } from "@/Feed/WorkerRelayView";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
|
||||
export function HasNotificationsMarker() {
|
||||
const readNotifications = useLogin(s => s.readNotifications);
|
||||
const notifications = useNotificationsView();
|
||||
const latestNotification = useMemo(
|
||||
() => notifications.reduce((acc, v) => (v.created_at > acc ? v.created_at : acc), 0),
|
||||
[notifications],
|
||||
);
|
||||
const hasNotifications = useMemo(
|
||||
() => latestNotification * 1000 > readNotifications,
|
||||
[notifications, readNotifications],
|
||||
);
|
||||
const latestNotification = 0; // TODO: get latest timestamp
|
||||
const hasNotifications = useMemo(() => latestNotification * 1000 > readNotifications, [readNotifications]);
|
||||
|
||||
if (hasNotifications) {
|
||||
return (
|
||||
|
@ -20,7 +20,7 @@ const getExtra = () => {
|
||||
};
|
||||
|
||||
export function LogoHeader({ showText = false }: { showText: boolean }) {
|
||||
const { subscriptions } = useLogin();
|
||||
const subscriptions = useLogin(s => s.subscriptions);
|
||||
const currentSubscription = getCurrentSubscription(subscriptions);
|
||||
|
||||
const appName = CONFIG.appName === "iris" && isStPatricksDay() ? "Irish" : CONFIG.appName;
|
||||
|
@ -96,6 +96,11 @@ export class QueryManager extends EventEmitter<QueryManagerEvents> {
|
||||
// check for empty filters
|
||||
filters = trimFilters(filters);
|
||||
|
||||
if (filters.length === 0) {
|
||||
this.#log("Dropping %s %o", q.id);
|
||||
return;
|
||||
}
|
||||
|
||||
// automated outbox model, load relays for queried authors
|
||||
for (const f of filters) {
|
||||
if (f.authors) {
|
||||
|
@ -49,10 +49,6 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
|
||||
this.#pool = await this.#sqlite.installOpfsSAHPoolVfs({});
|
||||
this.db = new this.#pool.OpfsSAHPoolDb(path);
|
||||
this.#log(`Opened ${this.db.filename}`);
|
||||
/*this.db.exec(
|
||||
`PRAGMA cache_size=${32 * 1024
|
||||
}; PRAGMA page_size=8192; PRAGMA journal_mode=MEMORY; PRAGMA temp_store=MEMORY;`,
|
||||
);*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +233,7 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
|
||||
};
|
||||
}) ?? [];
|
||||
const time = unixNowMs() - start;
|
||||
this.#log(`Query ${id} results took ${time.toLocaleString()}ms`);
|
||||
this.#log(`Query ${id} results took ${time.toLocaleString()}ms`, req);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
import { SqliteRelay } from "./sqlite/sqlite-relay";
|
||||
import { InMemoryRelay } from "./memory-relay";
|
||||
import { setLogging } from "./debug";
|
||||
import { WorkQueueItem, barrierQueue, processWorkQueue } from "./queue";
|
||||
import {
|
||||
NostrEvent,
|
||||
RelayHandler,
|
||||
@ -42,7 +41,6 @@ async function insertBatch() {
|
||||
setTimeout(() => insertBatch(), 100);
|
||||
}
|
||||
|
||||
const cmdQueue: Array<WorkQueueItem> = [];
|
||||
try {
|
||||
setTimeout(() => insertBatch(), 100);
|
||||
} catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user