Show relative time if boosting/quoting old post

pull/461/head
Lim Chee Aun 2024-03-15 16:02:33 +08:00
rodzic 2e28c147b9
commit cd3ed64e48
1 zmienionych plików z 21 dodań i 2 usunięć

Wyświetl plik

@ -85,6 +85,8 @@ const isIOS =
window.ontouchstart !== undefined &&
/iPad|iPhone|iPod/.test(navigator.userAgent);
const rtf = new Intl.RelativeTimeFormat();
const REACTIONS_LIMIT = 80;
function getPollText(poll) {
@ -508,6 +510,13 @@ function Status({
(attachment) => !attachment.description?.trim?.(),
);
}, [mediaAttachments]);
const statusMonthsAgo = useMemo(() => {
return Math.floor(
(new Date() - createdAtDate) / (1000 * 60 * 60 * 24 * 30),
);
}, [createdAtDate]);
const boostStatus = async () => {
if (!sameInstance || !authenticated) {
alert(unauthInteractionErrorMessage);
@ -767,12 +776,22 @@ function Status({
</MenuItem>
}
menuFooter={
mediaNoDesc &&
!reblogged && (
mediaNoDesc && !reblogged ? (
<div class="footer">
<Icon icon="alert" />
Some media have no descriptions.
</div>
) : (
statusMonthsAgo >= 3 && (
<div class="footer">
<Icon icon="info" />
<span>
Old post (
<strong>{rtf.format(-statusMonthsAgo, 'month')}</strong>
)
</span>
</div>
)
)
}
disabled={!canBoost}