forked from Kieran/snort
fix: add fallback to note time
This commit is contained in:
parent
6ce852e888
commit
cd8d4cf2ea
@ -38,7 +38,7 @@ export default function DM(props: DMProps) {
|
||||
|
||||
return (
|
||||
<div className={`flex dm f-col${props.data.pubkey === pubKey ? " me" : ""}`} ref={ref}>
|
||||
<div><NoteTime from={props.data.created_at * 1000} /></div>
|
||||
<div><NoteTime from={props.data.created_at * 1000} fallback={'Just now'} /></div>
|
||||
<div className="w-max">
|
||||
<Text content={content} />
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@ const MinuteInMs = 1_000 * 60;
|
||||
const HourInMs = MinuteInMs * 60;
|
||||
const DayInMs = HourInMs * 24;
|
||||
|
||||
export default function NoteTime({ from }) {
|
||||
export default function NoteTime({ from, fallback = '' }) {
|
||||
const [time, setTime] = useState("");
|
||||
|
||||
function calcTime() {
|
||||
@ -16,7 +16,7 @@ export default function NoteTime({ from }) {
|
||||
} else if (absAgo > HourInMs) {
|
||||
return `${fromDate.getHours().toString().padStart(2, '0')}:${fromDate.getMinutes().toString().padStart(2, '0')}`;
|
||||
} else if (absAgo < MinuteInMs) {
|
||||
return ''
|
||||
return fallback
|
||||
} else {
|
||||
let mins = parseInt(absAgo / MinuteInMs);
|
||||
let minutes = mins === 1 ? 'min' : 'mins'
|
||||
|
Loading…
Reference in New Issue
Block a user