mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
tying in notifications to updated settings
This commit is contained in:
parent
04ec4f5959
commit
894ac14a10
@ -27,7 +27,7 @@ const Strings = [
|
|||||||
monthEnd: 'dd/mm',
|
monthEnd: 'dd/mm',
|
||||||
|
|
||||||
sealUnset: 'Generate a key to enable end-to-end encrypted topics.',
|
sealUnset: 'Generate a key to enable end-to-end encrypted topics.',
|
||||||
sealUnlocked: 'Disabling the sealing key will prevent access to all end-to-end encrypted topics from this device until the key is unlocked again.',
|
sealUnlocked: 'Disabling the sealing key will block access to all end-to-end encrypted topics from this device until the key is unlocked again.',
|
||||||
sealLocked: 'Unlock the sealing key to support end-to-end encrypted topics on this device.',
|
sealLocked: 'Unlock the sealing key to support end-to-end encrypted topics on this device.',
|
||||||
sealDelete: 'Deleting the sealing key will premanently remove access to any existing end-to-end encrypted topics for ALL of your devices.',
|
sealDelete: 'Deleting the sealing key will premanently remove access to any existing end-to-end encrypted topics for ALL of your devices.',
|
||||||
password: 'Password',
|
password: 'Password',
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { ActivityIndicator, KeyboardAvoidingView, Modal, ScrollView, View, Switch, Text, TextInput, TouchableOpacity, Alert } from 'react-native';
|
import { Linking, ActivityIndicator, KeyboardAvoidingView, Modal, ScrollView, View, Switch, Text, TextInput, TouchableOpacity, Alert } from 'react-native';
|
||||||
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { styles } from './Settings.styled';
|
import { styles } from './Settings.styled';
|
||||||
import { useSettings } from './useSettings.hook';
|
import { useSettings } from './useSettings.hook';
|
||||||
@ -29,6 +29,19 @@ export function Settings() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setNotifications = async (notify) => {
|
||||||
|
try {
|
||||||
|
await actions.setNotifications(notify);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
Alert.alert(
|
||||||
|
'Failed to update account notifications',
|
||||||
|
'Please try again.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.content}>
|
<ScrollView style={styles.content}>
|
||||||
<SafeAreaView edges={['top']}>
|
<SafeAreaView edges={['top']}>
|
||||||
@ -41,7 +54,8 @@ export function Settings() {
|
|||||||
</View>
|
</View>
|
||||||
<View style={styles.optionControl}>
|
<View style={styles.optionControl}>
|
||||||
<Text style={styles.optionLink}>{ state.strings.enableNotifications }</Text>
|
<Text style={styles.optionLink}>{ state.strings.enableNotifications }</Text>
|
||||||
<Switch value={true} style={styles.notifications} thumbColor={Colors.sliderGrip} ios_backgroundColor={Colors.disabledIndicator} trackColor={styles.track}/>
|
<Switch value={state.pushEnabled} style={styles.notifications} thumbColor={Colors.sliderGrip} ios_backgroundColor={Colors.disabledIndicator}
|
||||||
|
trackColor={styles.track} onValueChange={setNotifications} />
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<View style={styles.divider} />
|
<View style={styles.divider} />
|
||||||
@ -183,7 +197,7 @@ export function Settings() {
|
|||||||
|
|
||||||
<Text style={styles.label}>{ state.strings.support }</Text>
|
<Text style={styles.label}>{ state.strings.support }</Text>
|
||||||
<View style={styles.group}>
|
<View style={styles.group}>
|
||||||
<TouchableOpacity style={styles.entry} activeOpacity={1}>
|
<TouchableOpacity style={styles.entry} activeOpacity={1} onPress={() => Linking.openURL('https://github.com/balzack/databag/discussions')}>
|
||||||
<View style={styles.icon}>
|
<View style={styles.icon}>
|
||||||
<MatIcons name="help-network-outline" size={20} color={Colors.linkText} />
|
<MatIcons name="help-network-outline" size={20} color={Colors.linkText} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -13,6 +13,7 @@ export function useSettings() {
|
|||||||
strings: getLanguageStrings(),
|
strings: getLanguageStrings(),
|
||||||
timeFull: false,
|
timeFull: false,
|
||||||
monthLast: false,
|
monthLast: false,
|
||||||
|
pushEnabled: null,
|
||||||
|
|
||||||
editSeal: false,
|
editSeal: false,
|
||||||
sealEnabled: false,
|
sealEnabled: false,
|
||||||
@ -36,11 +37,12 @@ export function useSettings() {
|
|||||||
}, [profile.state.timeFull, profile.state.monthLast]);
|
}, [profile.state.timeFull, profile.state.monthLast]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { seal, sealable } = account.state.status;
|
const { seal, sealable, pushEnabled } = account.state.status;
|
||||||
const sealKey = account.state.sealKey;
|
const sealKey = account.state.sealKey;
|
||||||
const sealEnabled = seal?.publicKey != null;
|
const sealEnabled = seal?.publicKey != null;
|
||||||
const sealUnlocked = seal?.publicKey === sealKey?.public && sealKey?.private && sealKey?.public;
|
const sealUnlocked = seal?.publicKey === sealKey?.public && sealKey?.private && sealKey?.public;
|
||||||
updateState({ sealable, seal, sealKey, sealEnabled, sealUnlocked });
|
updateState({ sealable, seal, sealKey, sealEnabled, sealUnlocked, pushEnabled });
|
||||||
|
|
||||||
}, [account.state]);
|
}, [account.state]);
|
||||||
|
|
||||||
const unlockKey = async () => {
|
const unlockKey = async () => {
|
||||||
@ -75,6 +77,9 @@ export function useSettings() {
|
|||||||
updateState({ monthLast: flag });
|
updateState({ monthLast: flag });
|
||||||
await profile.actions.setMonthLast(flag);
|
await profile.actions.setMonthLast(flag);
|
||||||
},
|
},
|
||||||
|
setNotifications: async (flag) => {
|
||||||
|
await account.actions.setNotifications(flag);
|
||||||
|
},
|
||||||
showEditSeal: () => {
|
showEditSeal: () => {
|
||||||
updateState({ editSeal: true, sealPassword: null, sealConfirm: null, hidePassword: true, hideConfirm: true,
|
updateState({ editSeal: true, sealPassword: null, sealConfirm: null, hidePassword: true, hideConfirm: true,
|
||||||
sealDelete: null, sealRemove: false, sealUpdate: false });
|
sealDelete: null, sealRemove: false, sealUpdate: false });
|
||||||
|
Loading…
Reference in New Issue
Block a user