Skip to content

Commit f8a638c

Browse files
committed
ProfileScreen [nfc]: Inline AwayStatusSwitch
1 parent 1a0d9c0 commit f8a638c

File tree

2 files changed

+15
-36
lines changed

2 files changed

+15
-36
lines changed

src/account-info/AwayStatusSwitch.js

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

src/account-info/ProfileScreen.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import ZulipButton from '../common/ZulipButton';
1414
import { logout } from '../account/logoutActions';
1515
import { tryStopNotifications } from '../notification/notifTokens';
1616
import AccountDetails from './AccountDetails';
17-
import AwayStatusSwitch from './AwayStatusSwitch';
18-
import { getOwnUser } from '../users/userSelectors';
19-
import { getIdentity } from '../account/accountsSelectors';
17+
import { getOwnUser, getOwnUserId } from '../users/userSelectors';
18+
import { getAuth, getIdentity } from '../account/accountsSelectors';
2019
import { useNavigation } from '../react-navigation';
2120
import { showConfirmationDialog } from '../utils/info';
2221
import { OfflineNoticePlaceholder } from '../boot/OfflineNoticeProvider';
22+
import { getUserStatus } from '../user-statuses/userStatusesModel';
23+
import SwitchRow from '../common/SwitchRow';
24+
import * as api from '../api';
2325

2426
const styles = createStyleSheet({
2527
buttonRow: {
@@ -125,14 +127,23 @@ type Props = $ReadOnly<{|
125127
* The profile/settings/account screen we offer among the main tabs of the app.
126128
*/
127129
export default function ProfileScreen(props: Props): Node {
130+
const auth = useSelector(getAuth);
128131
const ownUser = useSelector(getOwnUser);
132+
const ownUserId = useSelector(getOwnUserId);
133+
const awayStatus = useSelector(state => getUserStatus(state, ownUserId).away);
129134

130135
return (
131136
<SafeAreaView mode="padding" edges={['top']} style={{ flex: 1 }}>
132137
<OfflineNoticePlaceholder />
133138
<ScrollView>
134139
<AccountDetails user={ownUser} showEmail={false} />
135-
<AwayStatusSwitch />
140+
<SwitchRow
141+
label="Set yourself to away"
142+
value={awayStatus}
143+
onValueChange={(away: boolean) => {
144+
api.updateUserStatus(auth, { away });
145+
}}
146+
/>
136147
<View style={styles.buttonRow}>
137148
<SetStatusButton />
138149
</View>

0 commit comments

Comments
 (0)