blob: 21c4f6caf468a23f54780da2434d9a19c6058ce2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import { date_diff } from "@/logic/utils";
import type { PostProps } from "./Post";
import { useLocation } from "wouter";
function Header(props: PostProps) {
const [_, navigate] = useLocation();
const { profile } = props;
// console.log("profile", profile);
// console.log(props.poast.author.length, "length");
function go(e: React.MouseEvent) {
e.stopPropagation();
navigate(`/u/${poast.host}`);
}
function openThread(e: React.MouseEvent) {
e.stopPropagation();
const sel = window.getSelection()?.toString();
const id = "urbit" in props.user ? poast.id : poast.hash;
if (!sel) navigate(`/t/${poast.host}/${id}`);
}
const { poast } = props;
const name = profile ? (
profile.name
) : "urbit" in props.user ? (
<p className="p-only">{props.user.urbit}</p>
) : (
<p className="p-only">{props.user.nostr}</p>
);
return (
<header>
<div className="cp author flex-align name" role="link" onMouseUp={go}>
{name}
</div>
<div role="link" onMouseUp={openThread} className="date">
<p title={new Date(poast.time).toLocaleString()}>
{date_diff(poast.time, "short")}
</p>
</div>
</header>
);
}
export default Header;
|