Skip to content

Commit 03042da

Browse files
committed
Do not disclose exact last online time for privacy reasons
1 parent 3df9d06 commit 03042da

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

web/components/profile-about.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function LastOnline(props: { lastOnlineTime?: string }) {
292292
return (
293293
<AboutRow
294294
icon={<ClockIcon className="h-5 w-5"/>}
295-
text={'Last online ' + fromNow(lastOnlineTime)}
295+
text={'Last online ' + fromNow(lastOnlineTime, true)}
296296
/>
297297
)
298298
}

web/components/profile/profile-header.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {Col} from 'web/components/layout/col'
99
import {Row} from 'web/components/layout/row'
1010
import {SendMessageButton} from 'web/components/messaging/send-message-button'
1111
import ProfilePrimaryInfo from './profile-primary-info'
12-
import {OnlineIcon} from '../online-icon'
1312
import {track} from 'web/lib/service/analytics'
1413
import DropdownMenu from 'web/components/comments/dropdown-menu'
1514
import {ShareProfileButton} from '../widgets/share-profile-button'
@@ -58,7 +57,7 @@ export default function ProfileHeader(props: {
5857
{currentUser && isCurrentUser && disabled &&
5958
<div className="text-red-500">You disabled your profile, so no one else can access it.</div>}
6059
<Row className="items-center gap-1 text-xl">
61-
{!isCurrentUser && <OnlineIcon last_online_time={userActivity?.last_online_time}/>}
60+
{/*{!isCurrentUser && <OnlineIcon last_online_time={userActivity?.last_online_time}/>}*/}
6261
<span>
6362
{simpleView ? (
6463
<Link className={linkClass} href={`/${user.username}`}>

web/lib/util/time.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import relativeTime from 'dayjs/plugin/relativeTime'
33

44
dayjs.extend(relativeTime)
55

6-
export function fromNow(time: number | string | Date) {
7-
return dayjs(time).fromNow()
6+
export function fromNow(time: number | string | Date, privacy: boolean = false) {
7+
const date = dayjs(time);
8+
if (privacy && dayjs().diff(date, 'hour') < 24) {
9+
return 'in the past day';
10+
}
11+
return date.fromNow();
812
}
913

1014
const FORMATTER = new Intl.DateTimeFormat('default', {

0 commit comments

Comments
 (0)