allow disabling of binary attachments in mobile app

This commit is contained in:
Roland Osborne 2024-05-02 17:20:20 -07:00
parent 3b7de54be8
commit 0bcb289833
5 changed files with 34 additions and 15 deletions

View File

@ -158,6 +158,7 @@ const Strings = [
enableImage: 'Enable Image Queue',
enableAudio: 'Enable Audio Queue',
enableVideo: 'Enable Video Queue',
enableBinary: 'Enable Binary Files',
enableCalls: 'Enable WebRTC Calls',
relayUrl: 'Relay URL',
relayUsername: 'Relay Username',
@ -356,6 +357,7 @@ const Strings = [
enableImage: 'Activer les Fichiers Image',
enableAudio: 'Activer les Fichiers Audio',
enableVideo: 'Activer les Fichiers Vidéo',
enableBinary: 'Activer les Fichiers Binaires',
enableCalls: 'Activer les Appels',
relayUrl: 'URL de Relais',
relayUsername: 'Nom d\'Utilisateur du Relais',
@ -554,6 +556,7 @@ const Strings = [
enableImage: 'Permitir Archivos de Imagen',
enableAudio: 'Permitir Archivos de Audio',
enableVideo: 'Permitir Archivos de Vídeo',
enableBinary: 'Permitir Archivos Binarios',
enableCalls: 'Permitier Llamadas',
relayUrl: 'URL para Llamadas',
relayUsername: 'Nombre de Usuario para Llamadas',
@ -753,6 +756,7 @@ const Strings = [
enableImage: 'Bilddateien Aktivieren',
enableAudio: 'Audiodateien Aktivieren',
enableVideo: 'Videodateien aktivieren',
enableBinary: 'Binärdateien aktivieren',
enableCalls: 'Anrufe Ermöglichen',
relayUrl: 'URL für Anrufe',
relayUsername: 'Benutzername für Anrufe',
@ -940,6 +944,7 @@ const Strings = [
enableImage: 'Habilitar Fila de Imagens',
enableAudio: 'Habilitar Fila de Áudio',
enableVideo: 'Habilitar Fila de Vídeo',
enableBinary: 'Habilitar Fila Binários',
enableCalls: 'Habilitar Chamadas WebRTC',
relayUrl: 'URL do Relay',
relayUsername: 'Nome de Usuário do Relay',
@ -1124,6 +1129,7 @@ const Strings = [
enableImage: 'Включить очередь изображений',
enableAudio: 'Включить очередь аудио',
enableVideo: 'Включить очередь видео',
enableBinary: 'Включить двоичные файлы',
enableCalls: 'Включить звонки WebRTC',
relayUrl: 'URL релея',
relayUsername: 'Имя пользователя релея',

View File

@ -220,6 +220,12 @@ export function Dashboard(props) {
<Switch style={styles.switch} value={state.enableVideo}
onValueChange={actions.setEnableVideo} trackColor={styles.track}/>
</TouchableOpacity>
<TouchableOpacity style={styles.media} activeOpacity={1}
onPress={() => actions.setEnableBinary(!state.enableBinary)}>
<Text style={styles.modalLabel}>{ state.strings.enableBinary }</Text>
<Switch style={styles.switch} value={state.enableBinary}
onValueChange={actions.setEnableBinary} trackColor={styles.track}/>
</TouchableOpacity>
<View style={styles.label}></View>
<TouchableOpacity style={styles.ice} activeOpacity={1}

View File

@ -34,6 +34,7 @@ export function useDashboard(config, server, token) {
enableImage: true,
enableAudio: true,
enableVideo: true,
enableBinary: true,
createToken: null,
enableIce: false,
iceUrl: null,
@ -67,9 +68,9 @@ export function useDashboard(config, server, token) {
};
useEffect(() => {
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
const storage = Math.ceil(accountStorage / 1073741824);
updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
}, [config]);
useEffect(() => {
@ -124,6 +125,9 @@ export function useDashboard(config, server, token) {
setEnableVideo: (enableVideo) => {
updateState({ enableVideo });
},
setEnableBinary: (enableBinary) => {
updateState({ enableBinary });
},
setKeyType: (keyType) => {
updateState({ keyType });
},
@ -140,9 +144,9 @@ export function useDashboard(config, server, token) {
updateState({ icePassword });
},
saveConfig: async () => {
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword } = state;
const accountStorage = Number(storage) * 1073741824;
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword };
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword };
await setNodeConfig(server, token, config);
},
enableUser: async (accountId, enabled) => {

View File

@ -192,9 +192,11 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
<MatIcons name="music-note" size={24} color={Colors.text} />
</TouchableOpacity>
)}
<TouchableOpacity style={styles.addButton} onPress={addBinary}>
<MatIcons name="file-outline" size={24} color={Colors.text} />
</TouchableOpacity>
{ state.enableBinary && (
<TouchableOpacity style={styles.addButton} onPress={addBinary}>
<MatIcons name="file-outline" size={24} color={Colors.text} />
</TouchableOpacity>
)}
<View style={styles.divider} />
<TouchableOpacity style={styles.addButton} onPress={actions.showFontSize}>
<MatIcons name="format-size" size={24} color={Colors.text} />

View File

@ -26,6 +26,7 @@ export function useAddTopic(contentKey) {
enableImage: false,
enableAudio: false,
enableVideo: false,
enableBinary: false,
locked: true,
loaded: false,
conflict: false,
@ -50,15 +51,18 @@ export function useAddTopic(contentKey) {
if (asset.type === 'image' && !state.enableImage) {
conflict = true;
}
if (asset.video === 'video' && !state.enableVideo) {
if (asset.type === 'video' && !state.enableVideo) {
conflict = true;
}
if (asset.audio === 'audio' && !state.enableAudio) {
if (asset.type === 'audio' && !state.enableAudio) {
conflict = true;
}
if (asset.type === 'binary' && !state.enableBinary) {
conflict = true;
}
});
updateState({ conflict });
}, [state.assets, state.locked, state.enableImage, state.enableAudio, state.enableVideo]);
}, [state.assets, state.locked, state.enableImage, state.enableAudio, state.enableVideo, state.enableBinary]);
useEffect(() => {
updateState({ assets: [] });
@ -105,10 +109,10 @@ export function useAddTopic(contentKey) {
}, [upload.state, conversation.state]);
useEffect(() => {
const { enableVideo, enableAudio, enableImage } = conversation.state.channel?.detail || {};
const { enableVideo, enableAudio, enableImage, enableBinary } = conversation.state.channel?.detail || {};
const locked = conversation.state.channel?.detail?.dataType === 'superbasic' ? false : true;
const loaded = conversation.state.loaded;
updateState({ enableImage, enableAudio, enableVideo, locked, loaded });
updateState({ enableImage, enableAudio, enableVideo, enableBinary, locked, loaded });
}, [conversation.state]);
const setAsset = async (file, mime, scale) => {
@ -172,9 +176,6 @@ export function useAddTopic(contentKey) {
asset.type = 'binary';
asset.extension = name.split('.').pop().toUpperCase();
asset.label = name.slice(0, -1 * (asset.extension.length + 1));
console.log(asset);
updateState({ assets: [ ...state.assets, asset ] });
},
setVideoPosition: (key, position) => {