Do not disclose exact last online time for privacy reasons

This commit is contained in:
MartinBraquet
2025-11-02 21:26:17 +01:00
parent 3df9d067d6
commit 03042dae96
3 changed files with 8 additions and 5 deletions

View File

@@ -292,7 +292,7 @@ function LastOnline(props: { lastOnlineTime?: string }) {
return (
<AboutRow
icon={<ClockIcon className="h-5 w-5"/>}
text={'Last online ' + fromNow(lastOnlineTime)}
text={'Last online ' + fromNow(lastOnlineTime, true)}
/>
)
}

View File

@@ -9,7 +9,6 @@ import {Col} from 'web/components/layout/col'
import {Row} from 'web/components/layout/row'
import {SendMessageButton} from 'web/components/messaging/send-message-button'
import ProfilePrimaryInfo from './profile-primary-info'
import {OnlineIcon} from '../online-icon'
import {track} from 'web/lib/service/analytics'
import DropdownMenu from 'web/components/comments/dropdown-menu'
import {ShareProfileButton} from '../widgets/share-profile-button'
@@ -58,7 +57,7 @@ export default function ProfileHeader(props: {
{currentUser && isCurrentUser && disabled &&
<div className="text-red-500">You disabled your profile, so no one else can access it.</div>}
<Row className="items-center gap-1 text-xl">
{!isCurrentUser && <OnlineIcon last_online_time={userActivity?.last_online_time}/>}
{/*{!isCurrentUser && <OnlineIcon last_online_time={userActivity?.last_online_time}/>}*/}
<span>
{simpleView ? (
<Link className={linkClass} href={`/${user.username}`}>

View File

@@ -3,8 +3,12 @@ import relativeTime from 'dayjs/plugin/relativeTime'
dayjs.extend(relativeTime)
export function fromNow(time: number | string | Date) {
return dayjs(time).fromNow()
export function fromNow(time: number | string | Date, privacy: boolean = false) {
const date = dayjs(time);
if (privacy && dayjs().diff(date, 'hour') < 24) {
return 'in the past day';
}
return date.fromNow();
}
const FORMATTER = new Intl.DateTimeFormat('default', {