From b61f3da87855e107f56b00b5e06123ff3e09e57b Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Mon, 3 Jun 2024 12:55:40 -0700 Subject: [PATCH] hide ice service option when not supported --- app/mobile/src/dashboard/Dashboard.jsx | 90 +++++++------------ app/mobile/src/dashboard/useDashboard.hook.js | 14 +-- 2 files changed, 43 insertions(+), 61 deletions(-) diff --git a/app/mobile/src/dashboard/Dashboard.jsx b/app/mobile/src/dashboard/Dashboard.jsx index f9cbc6aa..59bcee1e 100644 --- a/app/mobile/src/dashboard/Dashboard.jsx +++ b/app/mobile/src/dashboard/Dashboard.jsx @@ -285,65 +285,43 @@ export function Dashboard(props) { { state.enableIce && ( <> - actions.setEnableIce(!state.iceService)}> - { state.strings.iceService } - - - - { !state.iceService && ( - <> - - - - - - + { state.iceServiceFlag != null && ( + actions.setIceServiceFlag(!state.iceServiceFlag)}> + { state.strings.iceService } + + )} - { state.iceService && ( - <> - - - - + { !state.iceServiceFlag && ( + )} + + + + )} diff --git a/app/mobile/src/dashboard/useDashboard.hook.js b/app/mobile/src/dashboard/useDashboard.hook.js index 03a9d470..0a33e62d 100644 --- a/app/mobile/src/dashboard/useDashboard.hook.js +++ b/app/mobile/src/dashboard/useDashboard.hook.js @@ -41,7 +41,7 @@ export function useDashboard(server, token, mfa) { enableBinary: true, createToken: null, enableIce: false, - iceService: false, + iceServiceFlag: false, iceUrl: null, iceUsername: null, icePassword: null, @@ -81,7 +81,10 @@ export function useDashboard(server, token, mfa) { const accounts = nodeAccounts.map(setAccountItem); const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword } = config || {}; const storage = Math.ceil(accountStorage / 1073741824); - updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword, accounts, mfaEnabled }); + const iceServiceFlag = iceService === 'cloudflare' ? true : iceService == null ? null : true; +console.log("ICE:", iceService, iceServiceFlag); + + updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceServiceFlag, iceUrl, iceUsername, icePassword, accounts, mfaEnabled }); } const refreshAccounts = async () => { @@ -151,8 +154,8 @@ export function useDashboard(server, token, mfa) { setEnableIce: (enableIce) => { updateState({ enableIce }); }, - setIceService: (iceService) => { - updateState({ iceService }); + setIceServiceFlag: (iceServiceFlag) => { + updateState({ iceServiceFlag }); }, setIceUrl: (iceUrl) => { updateState({ iceUrl }); @@ -164,7 +167,8 @@ export function useDashboard(server, token, mfa) { updateState({ icePassword }); }, saveConfig: async () => { - const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword } = state; + const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceServiceFlag, iceUrl, iceUsername, icePassword } = state; + const iceService = iceServiceFlag ? 'cloudflare' : ''; const accountStorage = Number(storage) * 1073741824; const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword }; await setNodeConfig(server, token, config);