mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
respecting allowUnsealed setting in mobile app
This commit is contained in:
parent
61d2660f88
commit
f5e9b5de61
@ -7,6 +7,7 @@ const Strings = [
|
||||
visibleRegistry: 'Visible in Registry',
|
||||
edit: 'Edit',
|
||||
enableNotifications: 'Push Notifications',
|
||||
allowUnsealed: 'Allow Unsealed',
|
||||
sealedTopics: 'Sealed Topics',
|
||||
colorMode: 'Color Mode',
|
||||
hourMode: 'Hour',
|
||||
@ -205,6 +206,7 @@ const Strings = [
|
||||
visibleRegistry: 'Visible dans le Registre',
|
||||
edit: 'Modifier',
|
||||
enableNotifications: 'Notifications Push',
|
||||
allowUnsealed: 'Sujets non Sécurisés',
|
||||
sealedTopics: 'Sujets Sécurisés',
|
||||
colorMode: 'Mode de Couleur',
|
||||
hourMode: 'Heure',
|
||||
@ -400,6 +402,7 @@ const Strings = [
|
||||
visibleRegistry: 'Visible en el Registro',
|
||||
edit: 'Editar',
|
||||
enableNotifications: 'Notificaciones Push',
|
||||
allowUnsealed: 'Sujetos Inseguros',
|
||||
sealedTopics: 'Temas Protegidos',
|
||||
colorMode: 'Modo de Color',
|
||||
hourMode: 'Hora',
|
||||
@ -595,6 +598,7 @@ const Strings = [
|
||||
visibleRegistry: 'Sichtbar in der Registrierung',
|
||||
edit: 'Bearbeiten',
|
||||
enableNotifications: 'Mitteilungen',
|
||||
allowUnsealed: 'Unsichere Themen',
|
||||
sealedTopics: 'Gesicherte Themen',
|
||||
colorMode: 'Farmodus',
|
||||
hourMode: 'Stunde',
|
||||
@ -790,6 +794,7 @@ const Strings = [
|
||||
visibleRegistry: 'Visível no Registro',
|
||||
edit: 'Editar',
|
||||
enableNotifications: 'Notificações Push',
|
||||
allowUnsealed: 'Assuntos Inseguros',
|
||||
sealedTopics: 'Tópicos Selados',
|
||||
colorMode: 'Modo de Cor',
|
||||
hourMode: 'Hora',
|
||||
@ -970,6 +975,7 @@ const Strings = [
|
||||
visibleRegistry: 'Видимый в реестре',
|
||||
edit: 'Редактировать',
|
||||
enableNotifications: 'Уведомления',
|
||||
allowUnsealed: 'Небезопасные субъекты',
|
||||
sealedTopics: 'Запечатанные темы',
|
||||
colorMode: 'Цветовая схема',
|
||||
hourMode: 'Часы',
|
||||
|
@ -191,6 +191,13 @@ export function Dashboard(props) {
|
||||
onValueChange={actions.setPushSupported} trackColor={styles.track}/>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity style={styles.media} activeOpacity={1}
|
||||
onPress={() => actions.setPushSupported(!state.pushSupported)}>
|
||||
<Text style={styles.modalLabel}>{ state.strings.allowUnsealed }</Text>
|
||||
<Switch style={styles.switch} value={state.pushSupported}
|
||||
onValueChange={actions.setPushSupported} trackColor={styles.track}/>
|
||||
</TouchableOpacity>
|
||||
|
||||
<View style={styles.label}></View>
|
||||
|
||||
<TouchableOpacity style={styles.media} activeOpacity={1}
|
||||
|
@ -28,6 +28,8 @@ export function useDashboard(config, server, token) {
|
||||
domain: null,
|
||||
storage: null,
|
||||
keyType: null,
|
||||
pushSupported: true,
|
||||
allowUnsealed: false,
|
||||
enableImage: true,
|
||||
enableAudio: true,
|
||||
enableVideo: true,
|
||||
@ -64,8 +66,8 @@ export function useDashboard(config, server, token) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
|
||||
updateState({ keyType, storage: accountStorage.toString(), domain, enableImage, enableAudio, enableVideo, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
|
||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
|
||||
updateState({ keyType, storage: accountStorage.toString(), domain, enableImage, enableAudio, enableVideo, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
|
||||
}, [config]);
|
||||
|
||||
useEffect(() => {
|
||||
@ -108,6 +110,9 @@ export function useDashboard(config, server, token) {
|
||||
setPushSupported: (pushSupported) => {
|
||||
updateState({ pushSupported });
|
||||
},
|
||||
setAllowUnsealed: (allowUnsealed) => {
|
||||
updateState({ allowUnsealed });
|
||||
},
|
||||
setEnableImage: (enableImage) => {
|
||||
updateState({ enableImage });
|
||||
},
|
||||
@ -133,8 +138,8 @@ export function useDashboard(config, server, token) {
|
||||
updateState({ icePassword });
|
||||
},
|
||||
saveConfig: async () => {
|
||||
const { storage, domain, keyType, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
|
||||
const config = { accountStorage: Number(storage), domain, keyType, enableImage, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword };
|
||||
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
|
||||
const config = { accountStorage: Number(storage), domain, keyType, enableImage, pushSupported, allowUnsealed, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword };
|
||||
await setNodeConfig(server, token, config);
|
||||
},
|
||||
enableUser: async (accountId, enabled) => {
|
||||
|
@ -50,15 +50,17 @@ export function Channels({ cardId, channelId, navigation, openConversation, dmCh
|
||||
<TextInput style={styles.inputfield} value={state.filter} onChangeText={actions.setFilter}
|
||||
autoCapitalize="none" placeholderTextColor={Colors.inputPlaceholder} placeholder={ state.strings.topics} />
|
||||
</View>
|
||||
<TouchableOpacity style={styles.addtop} onPress={actions.showAdding}>
|
||||
<Ionicons name={'message1'} size={16} color={Colors.primaryButtonText} style={[styles.box, { transform: [ { rotateY: "180deg" }, ]} ]}/>
|
||||
<Text style={styles.addtext}>{ state.strings.new }</Text>
|
||||
</TouchableOpacity>
|
||||
{ (state.sealable || state.allowUnsealed) && (
|
||||
<TouchableOpacity style={styles.addtop} onPress={actions.showAdding}>
|
||||
<Ionicons name={'message1'} size={16} color={Colors.primaryButtonText} style={[styles.box, { transform: [ { rotateY: "180deg" }, ]} ]}/>
|
||||
<Text style={styles.addtext}>{ state.strings.new }</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
),
|
||||
});
|
||||
}
|
||||
}, [navigation]);
|
||||
}, [navigation, state.allowUnsealed]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
@ -85,7 +87,7 @@ export function Channels({ cardId, channelId, navigation, openConversation, dmCh
|
||||
keyExtractor={item => (`${item.cardId}:${item.channelId}`)}
|
||||
/>
|
||||
)}
|
||||
{ !navigation && (
|
||||
{ !navigation && (state.sealable || state.allowUnsealed) && (
|
||||
<View style={styles.columnbottom}>
|
||||
<TouchableOpacity style={styles.addbottom} onPress={actions.showAdding}>
|
||||
<Ionicons name={'message1'} size={16} color={Colors.white} />
|
||||
@ -131,7 +133,7 @@ export function Channels({ cardId, channelId, navigation, openConversation, dmCh
|
||||
)}
|
||||
<View style={styles.addControls}>
|
||||
<View style={styles.sealed}>
|
||||
{ state.sealable && (
|
||||
{ state.sealable && state.allowUnsealed && (
|
||||
<>
|
||||
<Switch style={styles.switch} trackColor={styles.track}
|
||||
value={state.sealed} onValueChange={actions.setSealed} />
|
||||
|
@ -20,6 +20,7 @@ export function useChannels() {
|
||||
addSubject: null,
|
||||
sealed: false,
|
||||
sealable: false,
|
||||
allowUnsealed: false,
|
||||
busy: false,
|
||||
});
|
||||
|
||||
@ -117,12 +118,13 @@ export function useChannels() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const allowUnsealed = account.state.status?.allowUnsealed;
|
||||
const { status, sealKey } = account.state;
|
||||
if (status?.seal?.publicKey && sealKey?.public && sealKey?.private && sealKey?.public === status.seal.publicKey) {
|
||||
updateState({ sealable: true });
|
||||
updateState({ sealable: true, allowUnsealed });
|
||||
}
|
||||
else {
|
||||
updateState({ sealed: false, sealable: false });
|
||||
updateState({ sealed: false, sealable: false, allowUnsealed });
|
||||
}
|
||||
}, [account.state]);
|
||||
|
||||
@ -138,7 +140,7 @@ export function useChannels() {
|
||||
if (contact.detail.status !== 'connected') {
|
||||
return false;
|
||||
}
|
||||
if (state.sealed && !contact.profile.seal) {
|
||||
if ((!state.allowUnsealed || state.sealed) && !contact.profile.seal) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -156,7 +158,7 @@ export function useChannels() {
|
||||
});
|
||||
const addMembers = state.addMembers.filter(item => sorted.some(contact => contact.cardId === item));
|
||||
updateState({ contacts: sorted, addMembers });
|
||||
}, [card.state, state.sealed]);
|
||||
}, [card.state, state.sealed, state.allowUnsealed]);
|
||||
|
||||
useEffect(() => {
|
||||
syncChannels();
|
||||
@ -244,7 +246,7 @@ export function useChannels() {
|
||||
if (!state.busy) {
|
||||
try {
|
||||
updateState({ busy: true });
|
||||
if (state.sealed) {
|
||||
if (state.sealed || !state.allowUnsealed) {
|
||||
const keys = [ account.state.sealKey.public ];
|
||||
state.addMembers.forEach(id => {
|
||||
const contact = card.state.cards.get(id);
|
||||
|
Loading…
Reference in New Issue
Block a user