mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-27 04:40:35 +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), 0 1px 10px var(--bg-color),
|
||||||
0 1px 10px var(--bg-color);
|
0 1px 10px var(--bg-color);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
|
strong {
|
||||||
|
color: var(--red-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#_compose-container .status-preview-legend.reply-to {
|
#_compose-container .status-preview-legend.reply-to {
|
||||||
color: var(--reply-to-color);
|
color: var(--reply-to-color);
|
||||||
|
|
|
@ -174,6 +174,8 @@ function highlightText(text, { maxCharacters = Infinity }) {
|
||||||
); // Emoji shortcodes
|
); // Emoji shortcodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rtf = new Intl.RelativeTimeFormat();
|
||||||
|
|
||||||
function Compose({
|
function Compose({
|
||||||
onClose,
|
onClose,
|
||||||
replyToStatus,
|
replyToStatus,
|
||||||
|
@ -637,6 +639,16 @@ function Compose({
|
||||||
return [topLanguages, restLanguages];
|
return [topLanguages, restLanguages];
|
||||||
}, [language]);
|
}, [language]);
|
||||||
|
|
||||||
|
const replyToStatusMonthsAgo = useMemo(
|
||||||
|
() =>
|
||||||
|
!!replyToStatus?.createdAt &&
|
||||||
|
Math.floor(
|
||||||
|
(Date.now() - new Date(replyToStatus.createdAt)) /
|
||||||
|
(1000 * 60 * 60 * 24 * 30),
|
||||||
|
),
|
||||||
|
[replyToStatus],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="compose-container-outer">
|
<div id="compose-container-outer">
|
||||||
<div id="compose-container" class={standalone ? 'standalone' : ''}>
|
<div id="compose-container" class={standalone ? 'standalone' : ''}>
|
||||||
|
@ -786,6 +798,16 @@ function Compose({
|
||||||
Replying to @
|
Replying to @
|
||||||
{replyToStatus.account.acct || replyToStatus.account.username}
|
{replyToStatus.account.acct || replyToStatus.account.username}
|
||||||
’s post
|
’s post
|
||||||
|
{replyToStatusMonthsAgo >= 3 && (
|
||||||
|
<>
|
||||||
|
{' '}
|
||||||
|
(
|
||||||
|
<strong>
|
||||||
|
{rtf.format(-replyToStatusMonthsAgo, 'month')}
|
||||||
|
</strong>
|
||||||
|
)
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Reference in a new issue