mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 10:45:41 +03:00
Show relative time if replying to old post
Ref: https://blog.joinmastodon.org/2023/11/improving-the-quality-of-conversations-on-mastodon/
This commit is contained in:
parent
3dbbba0be2
commit
fef033b282
2 changed files with 26 additions and 0 deletions
|
@ -95,6 +95,10 @@
|
|||
0 1px 10px var(--bg-color), 0 1px 10px var(--bg-color),
|
||||
0 1px 10px var(--bg-color);
|
||||
z-index: 2;
|
||||
|
||||
strong {
|
||||
color: var(--red-color);
|
||||
}
|
||||
}
|
||||
#_compose-container .status-preview-legend.reply-to {
|
||||
color: var(--reply-to-color);
|
||||
|
|
|
@ -174,6 +174,8 @@ function highlightText(text, { maxCharacters = Infinity }) {
|
|||
); // Emoji shortcodes
|
||||
}
|
||||
|
||||
const rtf = new Intl.RelativeTimeFormat();
|
||||
|
||||
function Compose({
|
||||
onClose,
|
||||
replyToStatus,
|
||||
|
@ -637,6 +639,16 @@ function Compose({
|
|||
return [topLanguages, restLanguages];
|
||||
}, [language]);
|
||||
|
||||
const replyToStatusMonthsAgo = useMemo(
|
||||
() =>
|
||||
!!replyToStatus?.createdAt &&
|
||||
Math.floor(
|
||||
(Date.now() - new Date(replyToStatus.createdAt)) /
|
||||
(1000 * 60 * 60 * 24 * 30),
|
||||
),
|
||||
[replyToStatus],
|
||||
);
|
||||
|
||||
return (
|
||||
<div id="compose-container-outer">
|
||||
<div id="compose-container" class={standalone ? 'standalone' : ''}>
|
||||
|
@ -786,6 +798,16 @@ function Compose({
|
|||
Replying to @
|
||||
{replyToStatus.account.acct || replyToStatus.account.username}
|
||||
’s post
|
||||
{replyToStatusMonthsAgo >= 3 && (
|
||||
<>
|
||||
{' '}
|
||||
(
|
||||
<strong>
|
||||
{rtf.format(-replyToStatusMonthsAgo, 'month')}
|
||||
</strong>
|
||||
)
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
Loading…
Reference in a new issue