|
|
|
@ -2,7 +2,7 @@ import {Event} from 'nostr-tools';
|
|
|
|
|
import {elem, elemCanvas} from './utils/dom';
|
|
|
|
|
import {getHost, getNoxyUrl} from './utils/url';
|
|
|
|
|
import {getViewContent, getViewElem} from './view';
|
|
|
|
|
import {validatePow} from './events';
|
|
|
|
|
// import {validatePow} from './events';
|
|
|
|
|
import {parseContent} from './media';
|
|
|
|
|
|
|
|
|
|
type Metadata = {
|
|
|
|
@ -55,11 +55,11 @@ const setMetadata = (
|
|
|
|
|
user.picture = imgUrl.href;
|
|
|
|
|
|
|
|
|
|
// update profile images that used some nip-13 work
|
|
|
|
|
if (imgUrl.href && validatePow(evt)) {
|
|
|
|
|
document.body
|
|
|
|
|
.querySelectorAll(`canvas[data-pubkey="${evt.pubkey}"]`)
|
|
|
|
|
.forEach(canvas => canvas.parentNode?.replaceChild(elem('img', {src: imgUrl.href}), canvas));
|
|
|
|
|
}
|
|
|
|
|
// if (imgUrl.href && validatePow(evt)) {
|
|
|
|
|
// document.body
|
|
|
|
|
// .querySelectorAll(`canvas[data-pubkey="${evt.pubkey}"]`)
|
|
|
|
|
// .forEach(canvas => canvas.parentNode?.replaceChild(elem('img', {src: imgUrl.href}), canvas));
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -110,16 +110,16 @@ export const getProfile = (pubkey: string) => userList.find(user => user.pubkey
|
|
|
|
|
export const getMetadata = (evt: Event, relay: string) => {
|
|
|
|
|
const host = getHost(relay);
|
|
|
|
|
const user = getProfile(evt.pubkey);
|
|
|
|
|
const userImg = user?.picture;
|
|
|
|
|
// const userImg = user?.picture;
|
|
|
|
|
const name = user?.metadata[relay]?.name || user?.name;
|
|
|
|
|
const userName = name || evt.pubkey.slice(0, 8);
|
|
|
|
|
const userAbout = user?.metadata[relay]?.about || '';
|
|
|
|
|
const img = (userImg && validatePow(evt)) ? elem('img', {
|
|
|
|
|
const img = /* (userImg && validatePow(evt)) ? elem('img', {
|
|
|
|
|
alt: `${userName} ${host}`,
|
|
|
|
|
loading: 'lazy',
|
|
|
|
|
src: userImg,
|
|
|
|
|
title: `${userName} on ${host} ${userAbout}`,
|
|
|
|
|
}) : elemCanvas(evt.pubkey);
|
|
|
|
|
}) : */ elemCanvas(evt.pubkey);
|
|
|
|
|
const time = new Date(evt.created_at * 1000);
|
|
|
|
|
return {host, img, name, time, userName};
|
|
|
|
|
};
|
|
|
|
|