mirror of
https://github.com/BlowaterNostr/blowater.git
synced 2024-10-18 07:33:22 +00:00
render marked "e" tags (#434)
This commit is contained in:
parent
1ab5e65191
commit
16d2a7f2c5
@ -81,8 +81,7 @@ export class MessageList extends Component<Props, MessageListState> {
|
|||||||
const sameAuthor = pre.event.pubkey == cur.event.pubkey;
|
const sameAuthor = pre.event.pubkey == cur.event.pubkey;
|
||||||
const _66sec = Math.abs(cur.created_at.getTime() - pre.created_at.getTime()) <
|
const _66sec = Math.abs(cur.created_at.getTime() - pre.created_at.getTime()) <
|
||||||
1000 * 60;
|
1000 * 60;
|
||||||
const is_not_reply = cur.event.parsedTags.e.length === 0; // todo: make a isReply(event) function
|
return sameAuthor && _66sec && !isReply(cur.event);
|
||||||
return sameAuthor && _66sec && is_not_reply;
|
|
||||||
});
|
});
|
||||||
const messageBoxGroups = [];
|
const messageBoxGroups = [];
|
||||||
for (const messages of groups) {
|
for (const messages of groups) {
|
||||||
@ -285,28 +284,6 @@ function MessageBoxGroup(props: {
|
|||||||
const first_message = props.messages[0];
|
const first_message = props.messages[0];
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
// check if the first message is a reply message
|
|
||||||
function isReply(event: Parsed_Event) {
|
|
||||||
if (event.parsedTags.e.length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const reply_to_event = props.getters.getEventByID(event.parsedTags.e[0]);
|
|
||||||
if (!reply_to_event) {
|
|
||||||
return <ReplyTo unknown noteId={NoteID.FromString(event.parsedTags.e[0])} />;
|
|
||||||
}
|
|
||||||
let author = reply_to_event.publicKey.bech32();
|
|
||||||
let picture = robohash(reply_to_event.publicKey.hex);
|
|
||||||
if (reply_to_event.pubkey) {
|
|
||||||
const profile = props.getters.profileGetter.getProfilesByPublicKey(reply_to_event.publicKey);
|
|
||||||
if (profile) {
|
|
||||||
author = profile.profile.name || profile.profile.display_name ||
|
|
||||||
reply_to_event?.publicKey.bech32();
|
|
||||||
picture = profile.profile.picture || robohash(reply_to_event.publicKey.hex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return <ReplyTo content={reply_to_event.content} replyName={author} replayPic={picture} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.push(
|
rows.push(
|
||||||
<li
|
<li
|
||||||
class={`px-4 hover:bg-[#32353B] w-full max-w-full flex flex-col pr-8 mobile:pr-4 group relative ${
|
class={`px-4 hover:bg-[#32353B] w-full max-w-full flex flex-col pr-8 mobile:pr-4 group relative ${
|
||||||
@ -314,7 +291,7 @@ function MessageBoxGroup(props: {
|
|||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{MessageActions(first_message, props.emit)}
|
{MessageActions(first_message, props.emit)}
|
||||||
{isReply(first_message.event)}
|
{renderRelply(first_message.event, props.getters)}
|
||||||
<div class="flex items-start">
|
<div class="flex items-start">
|
||||||
<Avatar
|
<Avatar
|
||||||
class={`h-8 w-8 mt-[0.45rem] mr-2`}
|
class={`h-8 w-8 mt-[0.45rem] mr-2`}
|
||||||
@ -428,6 +405,33 @@ function last<T>(array: Array<T>): T | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isReply(event: Parsed_Event) {
|
||||||
|
return event.parsedTags.reply || event.parsedTags.root || event.parsedTags.e.length != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderRelply(event: Parsed_Event, getters: {
|
||||||
|
getEventByID: func_GetEventByID;
|
||||||
|
profileGetter: ProfileGetter;
|
||||||
|
}) {
|
||||||
|
if (!isReply(event)) return;
|
||||||
|
const replyEventId = event.parsedTags.reply?.[0] || event.parsedTags.root?.[0] || event.parsedTags.e[0];
|
||||||
|
const reply_to_event = getters.getEventByID(replyEventId);
|
||||||
|
if (!reply_to_event) {
|
||||||
|
return <ReplyTo unknown noteId={NoteID.FromString(replyEventId)} />;
|
||||||
|
}
|
||||||
|
let author = reply_to_event.publicKey.bech32();
|
||||||
|
let picture = robohash(reply_to_event.publicKey.hex);
|
||||||
|
if (reply_to_event.pubkey) {
|
||||||
|
const profile = getters.profileGetter.getProfilesByPublicKey(reply_to_event.publicKey);
|
||||||
|
if (profile) {
|
||||||
|
author = profile.profile.name || profile.profile.display_name ||
|
||||||
|
reply_to_event?.publicKey.bech32();
|
||||||
|
picture = profile.profile.picture || robohash(reply_to_event.publicKey.hex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <ReplyTo content={reply_to_event.content} replyName={author} replayPic={picture} />;
|
||||||
|
}
|
||||||
|
|
||||||
function ReplyTo(
|
function ReplyTo(
|
||||||
props: { unknown?: false; content: string; replyName: string; replayPic: string } | {
|
props: { unknown?: false; content: string; replyName: string; replayPic: string } | {
|
||||||
unknown: true;
|
unknown: true;
|
||||||
|
Loading…
Reference in New Issue
Block a user