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