Skip to content

Commit d76f6de

Browse files
committed
presence [nfc]: Simplify getUserLastActiveAsRelativeTimeString after combining
This cuts a dead codepath (for falsy presence), and defers some data lookups until we actually know we'll need them.
1 parent e349ffa commit d76f6de

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/presence/presenceModel.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ export function getUserLastActiveAsRelativeTimeString(
121121
if (!presence) {
122122
return null;
123123
}
124-
const userStatus = getUserStatus(state, user.user_id);
125-
const zulipFeatureLevel = getZulipFeatureLevel(state);
126-
127-
if (!presence || !presence.aggregated) {
124+
if (!presence.aggregated) {
128125
return 'never';
129126
}
130-
131127
const lastTimeActive = new Date(presence.aggregated.timestamp * 1000);
132128

133129
// "Invisible mode", new in FL 148, doesn't involve UserStatus['away']:
134130
// https://chat.zulip.org/#narrow/stream/2-general/topic/.22unavailable.22.20status/near/1454779
135131
// TODO(server-6.0): Simplify this away.
136-
if (zulipFeatureLevel < 148 && userStatus.away && differenceInDays(dateNow, lastTimeActive) < 1) {
132+
if (
133+
getZulipFeatureLevel(state) < 148
134+
&& getUserStatus(state, user.user_id).away
135+
&& differenceInDays(dateNow, lastTimeActive) < 1
136+
) {
137137
// Be vague when an unavailable user is recently online.
138138
// TODO: This phrasing doesn't really match the logic and can be misleading.
139139
return 'today';

0 commit comments

Comments
 (0)