mirror of
https://git.v0l.io/florian/bouquet.git
synced 2025-03-17 21:13:02 +01:00
fix: Fixed duration tag
This commit is contained in:
parent
e610548cd4
commit
1589907964
999
package-lock.json
generated
999
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@ export type FileEventData = {
|
||||
thumbnail?: string;
|
||||
blurHash?: string;
|
||||
tags: string[];
|
||||
duration?: string;
|
||||
|
||||
artist?: string;
|
||||
title?: string;
|
||||
|
@ -30,7 +30,7 @@ import dayjs from 'dayjs';
|
||||
|
||||
const NPUB_DVM_THUMBNAIL_CREATION = 'npub1q8cv87l47fql2xer2uyw509y5n5s9f53h76hvf9377efdptmsvusxf3n8s';
|
||||
|
||||
const ensureDecrypted = async (dvm: NDKUser, event: NDKEvent) => {
|
||||
const ensureDecrypted = async (dvm: NDKUser, event: NDKEvent): Promise<NDKEvent | undefined> => {
|
||||
if (!event) return undefined;
|
||||
|
||||
const encrypted = event.tags.some(t => t[0] == 'encrypted');
|
||||
@ -39,10 +39,8 @@ const ensureDecrypted = async (dvm: NDKUser, event: NDKEvent) => {
|
||||
const decryptedContent = await event.ndk?.signer?.decrypt(dvm, event.content);
|
||||
|
||||
if (decryptedContent) {
|
||||
return {
|
||||
...event,
|
||||
tags: event.tags.filter(t => t[0] !== 'encrypted').concat(JSON.parse(decryptedContent)),
|
||||
};
|
||||
event.tags = event.tags.filter(t => t[0] !== 'encrypted').concat(JSON.parse(decryptedContent));
|
||||
return event;
|
||||
}
|
||||
}
|
||||
return event;
|
||||
@ -66,9 +64,11 @@ const useVideoThumbnailDvm = (setFileEventData: React.Dispatch<React.SetStateAct
|
||||
const doASync = async () => {
|
||||
const firstEvent = await ensureDecrypted(dvm, thumbnailSubscription.events[0]);
|
||||
if (firstEvent) {
|
||||
console.log(firstEvent.rawEvent());
|
||||
const urls = firstEvent.tags.filter(t => t[0] === 'thumb').map(t => t[1]);
|
||||
const dim = firstEvent.tags.find(t => t[0] === 'dim')?.[1];
|
||||
setFileEventData(ed => ({ ...ed, thumbnails: urls, dim }));
|
||||
const duration = firstEvent.tags.find(t => t[0] === 'duration')?.[1];
|
||||
setFileEventData(ed => ({ ...ed, thumbnails: urls, dim, duration }));
|
||||
}
|
||||
};
|
||||
doASync();
|
||||
|
@ -9,7 +9,6 @@ export const usePublishing = () => {
|
||||
const { ndk, user } = useNDK();
|
||||
|
||||
const publishFileEvent = async (data: FileEventData): Promise<string> => {
|
||||
// TODO where to put video title?
|
||||
const e: NostrEvent = {
|
||||
created_at: dayjs().unix(),
|
||||
content: data.content,
|
||||
@ -113,16 +112,17 @@ export const usePublishing = () => {
|
||||
if (data.dim) {
|
||||
e.tags.push(['dim', data.dim]);
|
||||
}
|
||||
if (data.duration) {
|
||||
e.tags.push(['duration', data.duration]);
|
||||
}
|
||||
if (data.m) {
|
||||
e.tags.push(['m', data.m]);
|
||||
}
|
||||
if (data.thumbnail) {
|
||||
e.tags.push(['thumb', data.thumbnail]);
|
||||
e.tags.push(['preview', data.thumbnail]);
|
||||
e.tags.push(['image', data.thumbnail]);
|
||||
}
|
||||
|
||||
// TODO add tags ("t")
|
||||
|
||||
const ev = new NDKEvent(ndk, e);
|
||||
await ev.sign();
|
||||
console.log(ev.rawEvent());
|
||||
|
@ -16,7 +16,7 @@ export const KIND_AUDIO = 31337;
|
||||
const extractFromEvent = (ev: NDKEvent) => {
|
||||
const tags = ev.tags.filter(t => t[0] == 'x').map(t => t[1]);
|
||||
const hashesFromUrls = ev.tags
|
||||
.filter(t => t[0] == 'url' || t[0] == 'thumb' || t[0] == 'preview')
|
||||
.filter(t => t[0] == 'url' || t[0] == 'thumb' || t[0] == 'image')
|
||||
.flatMap(t => extractHashesFromContent(t[1]));
|
||||
const hashesFromContent = extractHashesFromContent(ev.content);
|
||||
const uniqueHashes = [...new Set([...tags, ...hashesFromUrls, ...hashesFromContent])];
|
||||
|
Loading…
x
Reference in New Issue
Block a user