Skip to content

Commit 977d59f

Browse files
committed
UserStatusScreen: Disable "Save" button when status unchanged
This is another place where it's nice to use our status <-> input-value conversion functions. The logic is not complicated -- "Has the emoji or text been touched?" -- so it's nice to see this code doesn't have ||, ??, and () ? () : () all over the place.
1 parent 5100d57 commit 977d59f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/user-statuses/UserStatusScreen.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* @flow strict-local */
2+
// $FlowFixMe[untyped-import]
3+
import isEqual from 'lodash.isequal';
24
import React, { useState, useContext, useCallback } from 'react';
35
import type { Node } from 'react';
46
import { FlatList, View, Pressable } from 'react-native';
@@ -165,7 +167,15 @@ export default function UserStatusScreen(props: Props): Node {
165167
);
166168
}}
167169
/>
168-
<ZulipButton style={styles.button} text="Save" onPress={handlePressSave} />
170+
<ZulipButton
171+
disabled={
172+
statusTextFromInputValue(textInputValue) === userStatusText
173+
&& isEqual(statusEmojiFromInputValue(emojiInputValue), userStatusEmoji)
174+
}
175+
style={styles.button}
176+
text="Save"
177+
onPress={handlePressSave}
178+
/>
169179
</Screen>
170180
);
171181
}

0 commit comments

Comments
 (0)