@@ -14,12 +14,14 @@ import ZulipButton from '../common/ZulipButton';
14
14
import { logout } from '../account/logoutActions' ;
15
15
import { tryStopNotifications } from '../notification/notifTokens' ;
16
16
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' ;
20
19
import { useNavigation } from '../react-navigation' ;
21
20
import { showConfirmationDialog } from '../utils/info' ;
22
21
import { OfflineNoticePlaceholder } from '../boot/OfflineNoticeProvider' ;
22
+ import { getUserStatus } from '../user-statuses/userStatusesModel' ;
23
+ import SwitchRow from '../common/SwitchRow' ;
24
+ import * as api from '../api' ;
23
25
24
26
const styles = createStyleSheet ( {
25
27
buttonRow : {
@@ -125,14 +127,23 @@ type Props = $ReadOnly<{|
125
127
* The profile/settings/account screen we offer among the main tabs of the app.
126
128
*/
127
129
export default function ProfileScreen ( props : Props ) : Node {
130
+ const auth = useSelector ( getAuth ) ;
128
131
const ownUser = useSelector ( getOwnUser ) ;
132
+ const ownUserId = useSelector ( getOwnUserId ) ;
133
+ const awayStatus = useSelector ( state => getUserStatus ( state , ownUserId ) . away ) ;
129
134
130
135
return (
131
136
< SafeAreaView mode = "padding" edges = { [ 'top' ] } style = { { flex : 1 } } >
132
137
< OfflineNoticePlaceholder />
133
138
< ScrollView >
134
139
< 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
+ />
136
147
< View style = { styles . buttonRow } >
137
148
< SetStatusButton />
138
149
</ View >
0 commit comments