Skip to content

Commit ed6e6e1

Browse files
committed
UserStatusScreen: Make status suggestions use new emoji-status feature!
When available, that is. Support was added in FL 86. If emoji statuses are supported, we use the suggested emoji for the emoji status, and the suggested text for the text status. If emoji statuses aren't supported…we do end up just cutting the emoji out of the status suggestion, which I guess is a small downside. For these older servers, we could have kept up what we do now: stick the status emoji at the start of the suggested text. But I think achieving that has a higher complexity cost than it's worth. I've never really used this UI, I'm not sure how common it is to do so, and people are still free to depart from the suggested text, including by adding emojis, by using the text input.
1 parent 977d59f commit ed6e6e1

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

src/user-statuses/UserStatusScreen.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,37 @@ import { useSelector } from '../react-redux';
1313
import Input from '../common/Input';
1414
import EmojiInput from './EmojiInput';
1515
import type { Value as EmojiInputValue } from './EmojiInput';
16-
import { emojiTypeFromReactionType, reactionTypeFromEmojiType } from '../emoji/data';
16+
import { unicodeCodeByName } from '../emoji/codePointMap';
17+
import {
18+
emojiTypeFromReactionType,
19+
reactionTypeFromEmojiType,
20+
parseUnicodeEmojiCode,
21+
} from '../emoji/data';
1722
import SelectableOptionRow from '../common/SelectableOptionRow';
1823
import Screen from '../common/Screen';
1924
import ZulipButton from '../common/ZulipButton';
2025
import { getZulipFeatureLevel, getAuth, getOwnUserId } from '../selectors';
2126
import { getUserStatus } from './userStatusesModel';
2227
import type { UserStatus } from '../api/modelTypes';
2328
import { Icon } from '../common/Icons';
24-
import statusSuggestions from './userStatusTextSuggestions';
2529
import * as api from '../api';
2630

31+
type StatusSuggestion = [
32+
$ReadOnly<{| emoji_name: string, emoji_code: string, reaction_type: 'unicode_emoji' |}>,
33+
string,
34+
];
35+
36+
const statusSuggestions: $ReadOnlyArray<StatusSuggestion> = [
37+
['calendar', 'In a meeting'],
38+
['bus', 'Commuting'],
39+
['sick', 'Out sick'],
40+
['palm_tree', 'Vacationing'],
41+
['house', 'Working remotely'],
42+
].map(([emoji_name, status_text]) => [
43+
{ emoji_name, emoji_code: unicodeCodeByName[emoji_name], reaction_type: 'unicode_emoji' },
44+
status_text,
45+
]);
46+
2747
const styles = createStyleSheet({
2848
inputRow: {
2949
flexDirection: 'row',
@@ -152,16 +172,24 @@ export default function UserStatusScreen(props: Props): Node {
152172
<FlatList
153173
data={statusSuggestions}
154174
keyboardShouldPersistTaps="always"
155-
keyExtractor={item => item}
156-
renderItem={({ item: text, index }) => {
175+
keyExtractor={(item, index) => index.toString() /* list is constant; index OK */}
176+
renderItem={({ item: [emoji, text], index }) => {
157177
const translatedText = _(text);
158178
return (
159179
<SelectableOptionRow
160-
itemKey={text}
161-
title={translatedText}
162-
selected={translatedText === statusTextFromInputValue(textInputValue)}
180+
itemKey={index}
181+
title={
182+
serverSupportsEmojiStatus
183+
? `${parseUnicodeEmojiCode(emoji.emoji_code)} ${translatedText}`
184+
: translatedText
185+
}
186+
selected={
187+
translatedText === statusTextFromInputValue(textInputValue)
188+
&& isEqual(emoji, statusEmojiFromInputValue(emojiInputValue))
189+
}
163190
onRequestSelectionChange={() => {
164191
setTextInputValue(translatedText);
192+
setEmojiInputValue(inputValueFromStatusEmoji(emoji));
165193
}}
166194
/>
167195
);

src/user-statuses/userStatusTextSuggestions.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

static/translations/messages_en.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@
274274
"Couldn’t load information about {fullName}": "Couldn’t load information about {fullName}",
275275
"What’s your status?": "What’s your status?",
276276
"Click to join video call": "Click to join video call",
277-
"📅 In a meeting": "📅 In a meeting",
278-
"🚌 Commuting": "🚌 Commuting",
279-
"🤒 Out sick": "🤒 Out sick",
280-
"🌴 Vacationing": "🌴 Vacationing",
281-
"🏠 Working remotely": "🏠 Working remotely",
277+
"In a meeting": "In a meeting",
278+
"Commuting": "Commuting",
279+
"Out sick": "Out sick",
280+
"Vacationing": "Vacationing",
281+
"Working remotely": "Working remotely",
282282
"This message was hidden because it is from a user you have muted. Long-press to view.": "This message was hidden because it is from a user you have muted. Long-press to view.",
283283
"Signed out": "Signed out",
284284
"Remove account?": "Remove account?",

0 commit comments

Comments
 (0)