feat: improve profile loading

This commit is contained in:
2023-02-20 23:14:15 +00:00
parent 5293991072
commit 3f406ec19e
19 changed files with 340 additions and 523 deletions

View File

@ -2,6 +2,7 @@ import * as secp from "@noble/secp256k1";
import { sha256 as hash } from "@noble/hashes/sha256";
import { bech32 } from "bech32";
import { HexKey, TaggedRawEvent, u256, EventKind, encodeTLV, NostrPrefix } from "@snort/nostr";
import { MetadataCache } from "State/Users";
export const sha256 = (str: string) => {
return secp.utils.bytesToHex(hash(str));
@ -144,7 +145,11 @@ export function extractLnAddress(lnurl: string) {
}
export function unixNow() {
return Math.floor(new Date().getTime() / 1000);
return Math.floor(unixNowMs() / 1000);
}
export function unixNowMs() {
return new Date().getTime();
}
/**
@ -196,3 +201,7 @@ export function tagFilterOfTextRepost(note: TaggedRawEvent, id?: u256): (tag: st
return (tag, i) =>
tag[0] === "e" && tag[3] === "mention" && note.content === `#[${i}]` && (id ? tag[1] === id : true);
}
export function groupByPubkey(acc: Record<HexKey, MetadataCache>, user: MetadataCache) {
return { ...acc, [user.pubkey]: user };
}