Prettier
This commit is contained in:
@ -116,7 +116,7 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
||||
type: TLVEntryType.Author,
|
||||
length: params[0].length,
|
||||
value: params[0],
|
||||
} as TLVEntry
|
||||
} as TLVEntry,
|
||||
)}`;
|
||||
}
|
||||
case ChatType.PrivateDirectMessage: {
|
||||
@ -127,7 +127,7 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
||||
type: TLVEntryType.Author,
|
||||
length: params[0].length,
|
||||
value: params[0],
|
||||
} as TLVEntry
|
||||
} as TLVEntry,
|
||||
)}`;
|
||||
}
|
||||
case ChatType.PrivateGroupChat: {
|
||||
@ -139,8 +139,8 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
||||
type: TLVEntryType.Author,
|
||||
length: a.length,
|
||||
value: a,
|
||||
} as TLVEntry)
|
||||
)
|
||||
}) as TLVEntry,
|
||||
),
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
@ -161,14 +161,14 @@ export function useNip4Chat() {
|
||||
const { publicKey } = useLogin();
|
||||
return useSyncExternalStore(
|
||||
c => Nip4Chats.hook(c),
|
||||
() => Nip4Chats.snapshot(publicKey)
|
||||
() => Nip4Chats.snapshot(publicKey),
|
||||
);
|
||||
}
|
||||
|
||||
export function useNip29Chat() {
|
||||
return useSyncExternalStore(
|
||||
c => Nip29Chats.hook(c),
|
||||
() => Nip29Chats.snapshot()
|
||||
() => Nip29Chats.snapshot(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ export function useNip24Chat() {
|
||||
const { publicKey } = useLogin();
|
||||
return useSyncExternalStore(
|
||||
c => Nip24Chats.hook(c),
|
||||
() => Nip24Chats.snapshot(publicKey)
|
||||
() => Nip24Chats.snapshot(publicKey),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
||||
value: v,
|
||||
type: TLVEntryType.Author,
|
||||
length: v.length,
|
||||
} as TLVEntry)
|
||||
)
|
||||
}) as TLVEntry,
|
||||
),
|
||||
);
|
||||
};
|
||||
return dedupe(messages.map(a => chatId(a))).map(a => {
|
||||
@ -72,7 +72,7 @@ export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
||||
} as {
|
||||
t: number;
|
||||
title: string | undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
return {
|
||||
type: ChatType.PrivateDirectMessage,
|
||||
|
@ -46,12 +46,12 @@ export class Nip29ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
||||
.map(a => a.tags.find(b => b[0] === "g"))
|
||||
.filter(a => a !== undefined)
|
||||
.map(a => unwrap(a))
|
||||
.map(a => `${a[2]}${a[1]}`)
|
||||
.map(a => `${a[2]}${a[1]}`),
|
||||
);
|
||||
return groups.map(g => {
|
||||
const [relay, channel] = g.split("/", 2);
|
||||
const messages = allMessages.filter(
|
||||
a => `${a.tags.find(b => b[0] === "g")?.[2]}${a.tags.find(b => b[0] === "g")?.[1]}` === g
|
||||
a => `${a.tags.find(b => b[0] === "g")?.[2]}${a.tags.find(b => b[0] === "g")?.[1]}` === g,
|
||||
);
|
||||
const lastRead = lastReadInChat(g);
|
||||
return {
|
||||
|
@ -34,7 +34,7 @@ export class Nip4ChatSystem extends ExternalStore<Array<Chat>> implements ChatSy
|
||||
const dms = this.#cache.snapshot();
|
||||
const dmSince = dms.reduce(
|
||||
(acc, v) => (v.created_at > acc && v.kind === EventKind.DirectMessage ? (acc = v.created_at) : acc),
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
this.#log("Loading DMS since %s", new Date(dmSince * 1000));
|
||||
@ -49,12 +49,15 @@ export class Nip4ChatSystem extends ExternalStore<Array<Chat>> implements ChatSy
|
||||
|
||||
listChats(pk: string): Chat[] {
|
||||
const myDms = this.#nip4Events();
|
||||
const chats = myDms.reduce((acc, v) => {
|
||||
const chatId = inChatWith(v, pk);
|
||||
acc[chatId] ??= [];
|
||||
acc[chatId].push(v);
|
||||
return acc;
|
||||
}, {} as Record<string, Array<NostrEvent>>);
|
||||
const chats = myDms.reduce(
|
||||
(acc, v) => {
|
||||
const chatId = inChatWith(v, pk);
|
||||
acc[chatId] ??= [];
|
||||
acc[chatId].push(v);
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, Array<NostrEvent>>,
|
||||
);
|
||||
|
||||
return [...Object.entries(chats)].map(([k, v]) => Nip4ChatSystem.createChatObj(k, v));
|
||||
}
|
||||
|
Reference in New Issue
Block a user