From d5fa2f420b8d087a1325bb115c5068b207081271 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Sat, 12 Nov 2022 11:54:49 +0100 Subject: [PATCH] feed: add formatted absolute time Useful to see when a text note was written. --- src/main.css | 3 ++- src/main.js | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main.css b/src/main.css index c90e3e9..dc8ae5a 100644 --- a/src/main.css +++ b/src/main.css @@ -58,7 +58,8 @@ body { line-height: 1.5; } -small { +small, +time { font-size: var(--font-small); } diff --git a/src/main.js b/src/main.js index 1a02c0d..e4fc8b7 100644 --- a/src/main.js +++ b/src/main.js @@ -11,10 +11,9 @@ pool.addRelay('wss://nostr.x1ddos.ch', {read: true, write: true}); // pool.addRelay('wss://nostr.rocks', {read: true, write: false}); // pool.addRelay('wss://nostr-relay.wlvs.space', {read: true, write: false}); - const dateTime = new Intl.DateTimeFormat(navigator.language, { - dateStyle: 'full', - timeStyle: 'long', + dateStyle: 'short', + timeStyle: 'short', }); const userList = []; let max = 0; @@ -56,25 +55,28 @@ const subscription = pool.sub({ // '52155da703585f25053830ac39863c80ea6adc57b360472c16c566a412d2bc38', // quark // 'a6057742e73ff93b89587c27a74edf2cdab86904291416e90dc98af1c5f70cfa', // mosc '3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d', // fiatjaf - pubkey, // me + '52155da703585f25053830ac39863c80ea6adc57b360472c16c566a412d2bc38' // x1ddos + // pubkey, // me // '32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245' // jb55 - ] + ], + limit: 100, } }); +// feed const hasEventTag = tag => tag[0] === 'e'; const getShortTagId = tag => `${tag[1].slice(0, 7)}${tag[2] ? '@' + tag[2] : ''}`; function renderTextNote(evt, relay) { - if (evt.tags.length) { - console.log('has tags', evt) - } const [host, img, time, userName] = getMetadata(evt, relay); const isReply = evt.tags.some(hasEventTag); - const body = elem('div', {className: 'mbox-body', title: dateTime.format(time)}, [ + const body = elem('div', {className: 'mbox-body'}, [ renderProfile(userName, host), - elem('div', {}, isReply ? `reply to ${evt.tags.filter(hasEventTag).map(getShortTagId).join(' and ')}` : evt.id), - evt.content // text + elem('div', {}, [ + elem('small', {}, isReply ? `reply to ${evt.tags.filter(hasEventTag).map(getShortTagId).join(' and ')}` : evt.id), + elem('time', {dateTime: time, title: time}, ` on ${dateTime.format(time)}`), + ]), + evt.content, // text ]); rendernArticle([img, body], isReply && {className: 'mbox-reply'}); }