update replies

This commit is contained in:
Ren Amamiya
2023-07-17 13:37:01 +07:00
parent b3b790588a
commit 5606dcb32f
11 changed files with 193 additions and 56 deletions

View File

@@ -4,3 +4,17 @@ export function shortenKey(pubkey: string) {
const npub = nip19.npubEncode(pubkey);
return npub.substring(0, 16).concat('...');
}
export function displayNpub(pubkey: string, len: number, separator?: string) {
const npub = nip19.npubEncode(pubkey) as string;
if (npub.length <= len) return npub;
separator = separator || ' ... ';
const sepLen = separator.length,
charsToShow = len - sepLen,
frontChars = Math.ceil(charsToShow / 2),
backChars = Math.floor(charsToShow / 2);
return npub.substr(0, frontChars) + separator + npub.substr(npub.length - backChars);
}

View File

@@ -47,7 +47,7 @@ export function arrayObjToPureArr(arr: any) {
}
// get parent id from event tags
export function getParentID(arr: string[], fallback: string) {
export function getParentID(arr: string[][], fallback: string) {
const tags = destr(arr);
let parentID = fallback;