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