mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 09:06:23 +01:00
Show relative time if boosting/quoting old post
This commit is contained in:
parent
2e28c147b9
commit
cd3ed64e48
1 changed files with 21 additions and 2 deletions
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue