Skip to content

Commit 32052e6

Browse files
committed
presence [nfc]: Clarify a name, userLastActiveAsRelativeTimeString
This is one of many, many "human" ways of describing a time. And on its own it's really not a representation of "presence" at all.
1 parent b945442 commit 32052e6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/presence/__tests__/presenceModel-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PRESENCE_RESPONSE, EVENT_PRESENCE } from '../../actionConstants';
77
import {
88
reducer as presenceReducer,
99
getAggregatedPresence,
10-
presenceToHumanTime,
10+
userLastActiveAsRelativeTimeString,
1111
statusFromPresence,
1212
statusFromPresenceAndUserStatus,
1313
} from '../presenceModel';
@@ -85,10 +85,10 @@ describe('getAggregatedPresence', () => {
8585
});
8686
});
8787

88-
describe('presenceToHumanTime', () => {
89-
test('given a presence return human readable time', () => {
88+
describe('userLastActiveAsRelativeTimeString', () => {
89+
test('given a presence return a relative time', () => {
9090
expect(
91-
presenceToHumanTime(
91+
userLastActiveAsRelativeTimeString(
9292
{
9393
aggregated: { client: 'website', status: 'active', timestamp: currentTimestamp - 240 },
9494
},
@@ -100,7 +100,7 @@ describe('presenceToHumanTime', () => {
100100

101101
test('if less than a threshold, the user is currently active', () => {
102102
expect(
103-
presenceToHumanTime(
103+
userLastActiveAsRelativeTimeString(
104104
{
105105
aggregated: { client: 'website', status: 'active', timestamp: currentTimestamp - 100 },
106106
},
@@ -113,7 +113,7 @@ describe('presenceToHumanTime', () => {
113113
// TODO(server-6.0): Remove
114114
test('Pre-FL 148: if less than a day and user is "away", use imprecise "today"', () => {
115115
expect(
116-
presenceToHumanTime(
116+
userLastActiveAsRelativeTimeString(
117117
{ aggregated: { client: 'website', status: 'active', timestamp: currentTimestamp - 100 } },
118118
{ away: true, status_text: null, status_emoji: null },
119119
147,
@@ -125,7 +125,7 @@ describe('presenceToHumanTime', () => {
125125
// above after the status parameter is gone.
126126
test('FL 148: if less than a day and user is "away", *don\'t* use imprecise "today"', () => {
127127
expect(
128-
presenceToHumanTime(
128+
userLastActiveAsRelativeTimeString(
129129
{ aggregated: { client: 'website', status: 'active', timestamp: currentTimestamp - 100 } },
130130
{ away: true, status_text: null, status_emoji: null },
131131
148,

src/presence/presenceModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const getAggregatedPresence = (presence: UserPresence): ClientPresence =>
111111
return { client, status, timestamp };
112112
};
113113

114-
export const presenceToHumanTime = (
114+
export const userLastActiveAsRelativeTimeString = (
115115
presence: UserPresence,
116116
status: UserStatus,
117117
zulipFeatureLevel: number,

src/title/ActivityText.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getZulipFeatureLevel } from '../selectors';
1010
import {
1111
getPresence,
1212
getUserPresenceByEmail,
13-
presenceToHumanTime,
13+
userLastActiveAsRelativeTimeString,
1414
} from '../presence/presenceModel';
1515
import { getUserStatus } from '../user-statuses/userStatusesModel';
1616
import ZulipText from '../common/ZulipText';
@@ -33,7 +33,7 @@ export default function ActivityText(props: Props): Node {
3333
return null;
3434
}
3535

36-
const activity = presenceToHumanTime(presence, userStatus, zulipFeatureLevel);
36+
const activeTime = userLastActiveAsRelativeTimeString(presence, userStatus, zulipFeatureLevel);
3737

38-
return <ZulipText style={style} text={`Active ${activity}`} />;
38+
return <ZulipText style={style} text={`Active ${activeTime}`} />;
3939
}

0 commit comments

Comments
 (0)