rename some files and add nip 94 widget

This commit is contained in:
Ren Amamiya
2023-08-23 15:18:59 +07:00
parent c97c685149
commit 3455eb701f
34 changed files with 145 additions and 35 deletions

26
src/utils/transform.ts Normal file
View File

@@ -0,0 +1,26 @@
import { NDKTag } from '@nostr-dev-kit/ndk';
// convert array to NIP-02 tag list
export function arrayToNIP02(arr: string[]) {
const nip02_arr = [];
arr.forEach((item) => {
nip02_arr.push(['p', item]);
});
return nip02_arr;
}
// get repost id from event tags
export function getRepostID(tags: NDKTag[]) {
let quoteID = null;
if (tags.length > 0) {
if (tags[0][0] === 'e') {
quoteID = tags[0][1];
} else {
quoteID = tags.find((t) => t[0] === 'e')?.[1];
}
}
return quoteID;
}