mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-26 23:54:46 +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 &&
|
window.ontouchstart !== undefined &&
|
||||||
/iPad|iPhone|iPod/.test(navigator.userAgent);
|
/iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||||
|
|
||||||
|
const rtf = new Intl.RelativeTimeFormat();
|
||||||
|
|
||||||
const REACTIONS_LIMIT = 80;
|
const REACTIONS_LIMIT = 80;
|
||||||
|
|
||||||
function getPollText(poll) {
|
function getPollText(poll) {
|
||||||
|
@ -508,6 +510,13 @@ function Status({
|
||||||
(attachment) => !attachment.description?.trim?.(),
|
(attachment) => !attachment.description?.trim?.(),
|
||||||
);
|
);
|
||||||
}, [mediaAttachments]);
|
}, [mediaAttachments]);
|
||||||
|
|
||||||
|
const statusMonthsAgo = useMemo(() => {
|
||||||
|
return Math.floor(
|
||||||
|
(new Date() - createdAtDate) / (1000 * 60 * 60 * 24 * 30),
|
||||||
|
);
|
||||||
|
}, [createdAtDate]);
|
||||||
|
|
||||||
const boostStatus = async () => {
|
const boostStatus = async () => {
|
||||||
if (!sameInstance || !authenticated) {
|
if (!sameInstance || !authenticated) {
|
||||||
alert(unauthInteractionErrorMessage);
|
alert(unauthInteractionErrorMessage);
|
||||||
|
@ -767,12 +776,22 @@ function Status({
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
}
|
}
|
||||||
menuFooter={
|
menuFooter={
|
||||||
mediaNoDesc &&
|
mediaNoDesc && !reblogged ? (
|
||||||
!reblogged && (
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<Icon icon="alert" />
|
<Icon icon="alert" />
|
||||||
Some media have no descriptions.
|
Some media have no descriptions.
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
statusMonthsAgo >= 3 && (
|
||||||
|
<div class="footer">
|
||||||
|
<Icon icon="info" />
|
||||||
|
<span>
|
||||||
|
Old post (
|
||||||
|
<strong>{rtf.format(-statusMonthsAgo, 'month')}</strong>
|
||||||
|
)
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
disabled={!canBoost}
|
disabled={!canBoost}
|
||||||
|
|
Loading…
Add table
Reference in a new issue