Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/account-info/AwayStatusSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import React from 'react';
import type { Node } from 'react';

import { useSelector, useDispatch } from '../react-redux';
import { useSelector } from '../react-redux';
import { SwitchRow } from '../common';
import { getSelfUserAwayStatus } from '../selectors';
import { updateUserAwayStatus } from '../user-status/userStatusActions';
import { getAuth, getSelfUserAwayStatus } from '../selectors';
import * as api from '../api';

type Props = $ReadOnly<{||}>;

Expand All @@ -15,15 +15,15 @@ type Props = $ReadOnly<{||}>;
* * allows by switching it to control the `away` status
*/
export default function AwayStatusSwitch(props: Props): Node {
const auth = useSelector(getAuth);
const awayStatus = useSelector(getSelfUserAwayStatus);
const dispatch = useDispatch();

return (
<SwitchRow
label="Set yourself to away"
value={awayStatus}
onValueChange={(away: boolean) => {
dispatch(updateUserAwayStatus(away));
api.updateUserStatus(auth, { away });
}}
/>
);
Expand Down
2 changes: 0 additions & 2 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export * from './outbox/outboxActions';
export * from './session/sessionActions';
export * from './settings/settingsActions';
export * from './streams/streamsActions';
export * from './subscriptions/subscriptionsActions';
export * from './topics/topicActions';
export * from './typing/typingActions';
export * from './users/usersActions';
export * from './user-status/userStatusActions';
13 changes: 7 additions & 6 deletions src/streams/CreateStreamScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ import type { Node } from 'react';
import type { RouteProp } from '../react-navigation';
import type { AppNavigationProp } from '../nav/AppNavigator';
import * as NavigationService from '../nav/NavigationService';
import { useSelector, useDispatch } from '../react-redux';
import { createNewStream, navigateBack } from '../actions';
import { getOwnEmail } from '../selectors';
import { useSelector } from '../react-redux';
import { navigateBack } from '../actions';
import { getAuth, getOwnEmail } from '../selectors';
import { Screen } from '../common';
import EditStreamCard from './EditStreamCard';
import * as api from '../api';

type Props = $ReadOnly<{|
navigation: AppNavigationProp<'create-stream'>,
route: RouteProp<'create-stream', void>,
|}>;

export default function CreateStreamScreen(props: Props): Node {
const dispatch = useDispatch();
const auth = useSelector(getAuth);
const ownEmail = useSelector(getOwnEmail);

const handleComplete = useCallback(
(name: string, description: string, isPrivate: boolean) => {
dispatch(createNewStream(name, description, [ownEmail], isPrivate));
api.createStream(auth, name, description, [ownEmail], isPrivate);
NavigationService.dispatch(navigateBack());
},
[ownEmail, dispatch],
[auth, ownEmail],
);

return (
Expand Down
22 changes: 8 additions & 14 deletions src/streams/StreamSettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ import { View } from 'react-native';
import type { RouteProp } from '../react-navigation';
import type { AppNavigationProp } from '../nav/AppNavigator';
import * as NavigationService from '../nav/NavigationService';
import { useDispatch, useSelector } from '../react-redux';
import { useSelector } from '../react-redux';
import { delay } from '../utils/async';
import { SwitchRow, Screen, ZulipButton } from '../common';
import { getSettings } from '../directSelectors';
import { getAuth, getIsAdmin, getStreamForId } from '../selectors';
import StreamCard from './StreamCard';
import { IconPin, IconMute, IconNotifications, IconEdit, IconPlusSquare } from '../common/Icons';
import {
setSubscriptionProperty,
navigateToEditStream,
navigateToStreamSubscribers,
} from '../actions';
import { navigateToEditStream, navigateToStreamSubscribers } from '../actions';
import styles from '../styles';
import { getSubscriptionsById } from '../subscriptions/subscriptionSelectors';
import * as api from '../api';
Expand All @@ -29,8 +25,6 @@ type Props = $ReadOnly<{|
|}>;

export default function StreamSettingsScreen(props: Props): Node {
const dispatch = useDispatch();

const auth = useSelector(getAuth);
const isAdmin = useSelector(getIsAdmin);
const stream = useSelector(state => getStreamForId(state, props.route.params.streamId));
Expand All @@ -41,16 +35,16 @@ export default function StreamSettingsScreen(props: Props): Node {

const handleTogglePinStream = useCallback(
(newValue: boolean) => {
dispatch(setSubscriptionProperty(stream.stream_id, 'pin_to_top', newValue));
api.setSubscriptionProperty(auth, stream.stream_id, 'pin_to_top', newValue);
},
[dispatch, stream],
[auth, stream],
);

const handleToggleMuteStream = useCallback(
(newValue: boolean) => {
dispatch(setSubscriptionProperty(stream.stream_id, 'is_muted', newValue));
api.setSubscriptionProperty(auth, stream.stream_id, 'is_muted', newValue);
},
[dispatch, stream],
[auth, stream],
);

const handlePressEdit = useCallback(() => {
Expand All @@ -71,8 +65,8 @@ export default function StreamSettingsScreen(props: Props): Node {

const handleToggleStreamPushNotification = useCallback(() => {
const currentValue = getIsNotificationEnabled(subscription, userSettingStreamNotification);
dispatch(setSubscriptionProperty(stream.stream_id, 'push_notifications', !currentValue));
}, [dispatch, stream, subscription, userSettingStreamNotification]);
api.setSubscriptionProperty(auth, stream.stream_id, 'push_notifications', !currentValue);
}, [auth, stream, subscription, userSettingStreamNotification]);

return (
<Screen title="Stream">
Expand Down
9 changes: 0 additions & 9 deletions src/streams/streamsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ import type { Stream, ThunkAction } from '../types';
import * as api from '../api';
import { getAuth, getZulipFeatureLevel } from '../selectors';

export const createNewStream = (
name: string,
description: string,
principals: string[],
isPrivate: boolean,
): ThunkAction<Promise<void>> => async (dispatch, getState) => {
await api.createStream(getAuth(getState()), name, description, principals, isPrivate);
};

export const updateExistingStream = (
id: number,
initialValues: Stream,
Expand Down
13 changes: 0 additions & 13 deletions src/subscriptions/subscriptionsActions.js

This file was deleted.

12 changes: 6 additions & 6 deletions src/user-status/UserStatusScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { createStyleSheet } from '../styles';
import type { RouteProp } from '../react-navigation';
import type { AppNavigationProp } from '../nav/AppNavigator';
import * as NavigationService from '../nav/NavigationService';
import { useSelector, useDispatch } from '../react-redux';
import { useSelector } from '../react-redux';
import { Input, SelectableOptionRow, Screen, ZulipButton } from '../common';
import { getSelfUserStatusText } from '../selectors';
import { getAuth, getSelfUserStatusText } from '../selectors';
import { IconCancel, IconDone } from '../common/Icons';
import statusSuggestions from './userStatusTextSuggestions';
import { updateUserStatusText } from './userStatusActions';
import { navigateBack } from '../nav/navActions';
import * as api from '../api';

const styles = createStyleSheet({
statusTextInput: {
Expand All @@ -35,18 +35,18 @@ type Props = $ReadOnly<{|
|}>;

export default function UserStatusScreen(props: Props): Node {
const dispatch = useDispatch();
const auth = useSelector(getAuth);
const userStatusText = useSelector(getSelfUserStatusText);

const [statusText, setStatusText] = useState<string>(userStatusText);
const _ = useContext(TranslationContext);

const sendToServer = useCallback(
(_statusText: string) => {
dispatch(updateUserStatusText(_statusText));
api.updateUserStatus(auth, { status_text: _statusText });
NavigationService.dispatch(navigateBack());
},
[dispatch],
[auth],
);

const handlePressUpdate = useCallback(() => {
Expand Down
20 changes: 0 additions & 20 deletions src/user-status/userStatusActions.js

This file was deleted.