Skip to content

Commit 2ce27e5

Browse files
committed
UserStatusScreen [nfc]: Rename input-value state
We can drop "status" because it's implied (this is the UserStatusScreen). And it's good to be clear that we're working with the current value of the input, which could be different from the status text that's actually in effect, that the server knows about.
1 parent d99c077 commit 2ce27e5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/user-statuses/UserStatusScreen.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function UserStatusScreen(props: Props): Node {
4343
const ownUserId = useSelector(getOwnUserId);
4444
const userStatusText = useSelector(state => getUserStatus(state, ownUserId).status_text);
4545

46-
const [statusText, setStatusText] = useState<string>(userStatusText ?? '');
46+
const [textInputValue, setTextInputValue] = useState<string>(userStatusText ?? '');
4747
const _ = useContext(TranslationContext);
4848

4949
const sendToServer = useCallback(
@@ -55,11 +55,11 @@ export default function UserStatusScreen(props: Props): Node {
5555
);
5656

5757
const handlePressUpdate = useCallback(() => {
58-
sendToServer({ status_text: statusText });
59-
}, [statusText, sendToServer]);
58+
sendToServer({ status_text: textInputValue });
59+
}, [textInputValue, sendToServer]);
6060

6161
const handlePressClear = useCallback(() => {
62-
setStatusText('');
62+
setTextInputValue('');
6363
sendToServer({ status_text: null });
6464
}, [sendToServer]);
6565

@@ -70,8 +70,8 @@ export default function UserStatusScreen(props: Props): Node {
7070
maxLength={60}
7171
style={styles.statusTextInput}
7272
placeholder="What’s your status?"
73-
value={statusText}
74-
onChangeText={setStatusText}
73+
value={textInputValue}
74+
onChangeText={setTextInputValue}
7575
/>
7676
<FlatList
7777
data={statusSuggestions}
@@ -82,9 +82,9 @@ export default function UserStatusScreen(props: Props): Node {
8282
key={item}
8383
itemKey={item}
8484
title={item}
85-
selected={item === statusText}
85+
selected={item === textInputValue}
8686
onRequestSelectionChange={itemKey => {
87-
setStatusText(_(itemKey));
87+
setTextInputValue(_(itemKey));
8888
}}
8989
/>
9090
)}

0 commit comments

Comments
 (0)