Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32622666
D3565.1767468570.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D3565.1767468570.diff
View Options
diff --git a/native/chat/settings/thread-settings-push-notifs.react.js b/native/chat/settings/thread-settings-push-notifs.react.js
--- a/native/chat/settings/thread-settings-push-notifs.react.js
+++ b/native/chat/settings/thread-settings-push-notifs.react.js
@@ -2,6 +2,8 @@
import * as React from 'react';
import { View, Switch } from 'react-native';
+import Alert from 'react-native/Libraries/Alert/Alert';
+import Linking from 'react-native/Libraries/Linking/Linking';
import {
updateSubscriptionActionTypes,
@@ -19,6 +21,7 @@
} from 'lib/utils/action-utils';
import { SingleLine } from '../../components/single-line.react';
+import { useSelector } from '../../redux/redux-utils';
import { useStyles } from '../../themes/colors';
type BaseProps = {
@@ -31,6 +34,7 @@
// Redux dispatch functions
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+ +deviceToken: ?string,
+updateSubscription: (
subscriptionUpdate: SubscriptionUpdateRequest,
) => Promise<SubscriptionUpdateResult>,
@@ -55,7 +59,7 @@
</SingleLine>
<View style={this.props.styles.currentValue}>
<Switch
- value={this.state.currentValue}
+ value={this.state.currentValue && this.hasPushPermissions()}
onValueChange={this.onValueChange}
/>
</View>
@@ -64,17 +68,39 @@
}
onValueChange = (value: boolean) => {
- this.setState({ currentValue: value });
- this.props.dispatchActionPromise(
- updateSubscriptionActionTypes,
- this.props.updateSubscription({
- threadID: this.props.threadInfo.id,
- updatedFields: {
- pushNotifs: value,
+ if (this.hasPushPermissions()) {
+ this.setState({ currentValue: value });
+ this.props.dispatchActionPromise(
+ updateSubscriptionActionTypes,
+ this.props.updateSubscription({
+ threadID: this.props.threadInfo.id,
+ updatedFields: {
+ pushNotifs: value,
+ },
+ }),
+ );
+ return;
+ }
+ Alert.alert(
+ 'Need notifications permissions',
+ 'Comm needs notification permissions to show notifications from the thread!' +
+ 'Please enable them in Settings App -> Notifications -> Comm.',
+ [
+ {
+ text: 'Go to application settings',
+ onPress: () => Linking.openURL('app-settings:{Comm}'),
},
- }),
+ {
+ text: 'Cancel',
+ style: 'cancel',
+ },
+ ],
);
};
+
+ hasPushPermissions(): boolean {
+ return this.props.deviceToken !== null;
+ }
}
const unboundStyles = {
@@ -104,12 +130,14 @@
const styles = useStyles(unboundStyles);
const dispatchActionPromise = useDispatchActionPromise();
const callUpdateSubscription = useServerCall(updateSubscription);
+ const deviceToken = useSelector(state => state.deviceToken);
return (
<ThreadSettingsPushNotifs
{...props}
styles={styles}
dispatchActionPromise={dispatchActionPromise}
updateSubscription={callUpdateSubscription}
+ deviceToken={deviceToken}
/>
);
},
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 3, 7:29 PM (10 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5890402
Default Alt Text
D3565.1767468570.diff (3 KB)
Attached To
Mode
D3565: Deep-link user to applications settings when they try to enable notifications for a thread without notifications enabled globally for Comm application.
Attached
Detach File
Event Timeline
Log In to Comment