feat: add basic search dialog
This commit is contained in:
@@ -266,6 +266,12 @@ export class Ark {
|
||||
return event;
|
||||
}
|
||||
|
||||
public async getEvents(filter: NDKFilter) {
|
||||
const events = await this.ndk.fetchEvents(filter);
|
||||
if (!events) return [];
|
||||
return [...events];
|
||||
}
|
||||
|
||||
public getEventThread({
|
||||
content,
|
||||
tags,
|
||||
|
||||
@@ -2,17 +2,21 @@ import { useStorage } from "@lume/storage";
|
||||
import { IColumn } from "@lume/types";
|
||||
import { COL_TYPES } from "@lume/utils";
|
||||
import {
|
||||
ReactNode,
|
||||
type MutableRefObject,
|
||||
type ReactNode,
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { toast } from "sonner";
|
||||
import { type VListHandle } from "virtua";
|
||||
|
||||
type ColumnContext = {
|
||||
columns: IColumn[];
|
||||
vlistRef: MutableRefObject<VListHandle>;
|
||||
addColumn: (column: IColumn) => Promise<void>;
|
||||
removeColumn: (id: number) => Promise<void>;
|
||||
moveColumn: (id: number, position: "left" | "right") => void;
|
||||
@@ -24,6 +28,8 @@ const ColumnContext = createContext<ColumnContext>(null);
|
||||
|
||||
export function ColumnProvider({ children }: { children: ReactNode }) {
|
||||
const storage = useStorage();
|
||||
const vlistRef = useRef<VListHandle>(null);
|
||||
|
||||
const [columns, setColumns] = useState<IColumn[]>([
|
||||
{
|
||||
id: 9999,
|
||||
@@ -112,6 +118,7 @@ export function ColumnProvider({ children }: { children: ReactNode }) {
|
||||
<ColumnContext.Provider
|
||||
value={{
|
||||
columns,
|
||||
vlistRef,
|
||||
addColumn,
|
||||
removeColumn,
|
||||
moveColumn,
|
||||
|
||||
@@ -109,7 +109,7 @@ export function NoteChild({
|
||||
<User.Root>
|
||||
<User.Avatar className="size-10 shrink-0 rounded-lg object-cover" />
|
||||
<div className="absolute left-2 top-2 inline-flex items-center gap-1.5 font-semibold leading-tight">
|
||||
<User.Name />
|
||||
<User.Name className="max-w-[10rem] truncate" />
|
||||
<div className="font-normal text-neutral-700 dark:text-neutral-300">
|
||||
{isRoot ? "posted:" : "replied:"}
|
||||
</div>
|
||||
|
||||
@@ -38,10 +38,12 @@ export function UserNip05({
|
||||
|
||||
return (
|
||||
<div className="inline-flex items-center gap-1">
|
||||
<p className={cn("text-sm font-medium", className)}>
|
||||
{user?.nip05?.startsWith("_@")
|
||||
? user?.nip05?.replace("_@", "")
|
||||
: displayNpub(pubkey, 16)}
|
||||
<p className={cn("text-sm", className)}>
|
||||
{!user?.nip05
|
||||
? displayNpub(pubkey, 16)
|
||||
: user?.nip05?.startsWith("_@")
|
||||
? user?.nip05?.replace("_@", "")
|
||||
: user?.nip05}
|
||||
</p>
|
||||
{!isLoading && verified ? (
|
||||
<VerifiedIcon className="size-4 text-teal-500" />
|
||||
|
||||
@@ -8,16 +8,20 @@ const UserContext = createContext<NDKUserProfile>(null);
|
||||
export function UserProvider({
|
||||
pubkey,
|
||||
children,
|
||||
}: { pubkey: string; children: ReactNode }) {
|
||||
embed,
|
||||
}: { pubkey: string; children: ReactNode; embed?: string }) {
|
||||
const ark = useArk();
|
||||
const { data: user } = useQuery({
|
||||
queryKey: ["user", pubkey],
|
||||
queryFn: async () => {
|
||||
if (embed) return JSON.parse(embed) as NDKUserProfile;
|
||||
|
||||
const profile = await ark.getUserProfile(pubkey);
|
||||
if (!profile)
|
||||
throw new Error(
|
||||
`Cannot get metadata for ${pubkey}, will be retry after 10 seconds`,
|
||||
);
|
||||
|
||||
return profile;
|
||||
},
|
||||
refetchOnMount: false,
|
||||
|
||||
@@ -88,7 +88,6 @@ export const LumeProvider = ({ children }: PropsWithChildren<object>) => {
|
||||
async function initNDK() {
|
||||
const explicitRelayUrls = normalizeRelayUrlSet([
|
||||
"wss://bostr.nokotaro.com/",
|
||||
"wss://nostr.mutinywallet.com/",
|
||||
]);
|
||||
|
||||
// #TODO: user should config outbox relays
|
||||
@@ -108,10 +107,10 @@ export const LumeProvider = ({ children }: PropsWithChildren<object>) => {
|
||||
explicitRelayUrls,
|
||||
outboxRelayUrls,
|
||||
blacklistRelayUrls,
|
||||
enableOutboxModel: !storage.settings.lowPower,
|
||||
enableOutboxModel: false,
|
||||
autoConnectUserRelays: !storage.settings.lowPower,
|
||||
autoFetchUserMutelist: !storage.settings.lowPower,
|
||||
clientName: "Lume",
|
||||
// clientName: "Lume",
|
||||
// clientNip89: '',
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user