Skip to content

Commit b41ab72

Browse files
committed
actions [nfc]: Drop trivial API-wrapper setSubscriptionProperty
This is just a wrapper for api.setSubscriptionProperty, and one that doesn't add any meaningful semantics. That is, not only does it not add any significant behavior or logic, but there also isn't any way its semantics meaningfully differs from the underlying function. (Sometimes a function with a trivial implementation is nevertheless abstracting something away, so that the fact the implementation is trivial is itself a nonobvious fact. But this isn't one of those.) So, just inline it at its call sites. We already have a series of other sites that call `api.setSubscriptionProperty` directly. Originally noticed this here: zulip#4899 (review)
1 parent e8b054f commit b41ab72

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

src/actions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export * from './outbox/outboxActions';
1010
export * from './session/sessionActions';
1111
export * from './settings/settingsActions';
1212
export * from './streams/streamsActions';
13-
export * from './subscriptions/subscriptionsActions';
1413
export * from './topics/topicActions';
1514
export * from './typing/typingActions';
1615
export * from './users/usersActions';

src/streams/StreamSettingsScreen.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ import { View } from 'react-native';
66
import type { RouteProp } from '../react-navigation';
77
import type { AppNavigationProp } from '../nav/AppNavigator';
88
import * as NavigationService from '../nav/NavigationService';
9-
import { useDispatch, useSelector } from '../react-redux';
9+
import { useSelector } from '../react-redux';
1010
import { delay } from '../utils/async';
1111
import { SwitchRow, Screen, ZulipButton } from '../common';
1212
import { getSettings } from '../directSelectors';
1313
import { getAuth, getIsAdmin, getStreamForId } from '../selectors';
1414
import StreamCard from './StreamCard';
1515
import { IconPin, IconMute, IconNotifications, IconEdit, IconPlusSquare } from '../common/Icons';
16-
import {
17-
setSubscriptionProperty,
18-
navigateToEditStream,
19-
navigateToStreamSubscribers,
20-
} from '../actions';
16+
import { navigateToEditStream, navigateToStreamSubscribers } from '../actions';
2117
import styles from '../styles';
2218
import { getSubscriptionsById } from '../subscriptions/subscriptionSelectors';
2319
import * as api from '../api';
@@ -29,8 +25,6 @@ type Props = $ReadOnly<{|
2925
|}>;
3026

3127
export default function StreamSettingsScreen(props: Props): Node {
32-
const dispatch = useDispatch();
33-
3428
const auth = useSelector(getAuth);
3529
const isAdmin = useSelector(getIsAdmin);
3630
const stream = useSelector(state => getStreamForId(state, props.route.params.streamId));
@@ -41,16 +35,16 @@ export default function StreamSettingsScreen(props: Props): Node {
4135

4236
const handleTogglePinStream = useCallback(
4337
(newValue: boolean) => {
44-
dispatch(setSubscriptionProperty(stream.stream_id, 'pin_to_top', newValue));
38+
api.setSubscriptionProperty(auth, stream.stream_id, 'pin_to_top', newValue);
4539
},
46-
[dispatch, stream],
40+
[auth, stream],
4741
);
4842

4943
const handleToggleMuteStream = useCallback(
5044
(newValue: boolean) => {
51-
dispatch(setSubscriptionProperty(stream.stream_id, 'is_muted', newValue));
45+
api.setSubscriptionProperty(auth, stream.stream_id, 'is_muted', newValue);
5246
},
53-
[dispatch, stream],
47+
[auth, stream],
5448
);
5549

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

7266
const handleToggleStreamPushNotification = useCallback(() => {
7367
const currentValue = getIsNotificationEnabled(subscription, userSettingStreamNotification);
74-
dispatch(setSubscriptionProperty(stream.stream_id, 'push_notifications', !currentValue));
75-
}, [dispatch, stream, subscription, userSettingStreamNotification]);
68+
api.setSubscriptionProperty(auth, stream.stream_id, 'push_notifications', !currentValue);
69+
}, [auth, stream, subscription, userSettingStreamNotification]);
7670

7771
return (
7872
<Screen title="Stream">

src/subscriptions/subscriptionsActions.js

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

0 commit comments

Comments
 (0)