@fto-consult/expo-ui 7.8.2 → 7.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "7.8.2",
3
+ "version": "7.8.5",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -71,8 +71,8 @@
71
71
  "@expo/html-elements": "^0.5.1",
72
72
  "@expo/vector-icons": "^13.0.0",
73
73
  "@faker-js/faker": "^8.0.2",
74
- "@fto-consult/common": "^3.75.1",
75
- "@fto-consult/electron-gen": "^1.3.4",
74
+ "@fto-consult/common": "^3.75.2",
75
+ "@fto-consult/electron-gen": "^1.3.5",
76
76
  "@pchmn/expo-material3-theme": "^1.3.1",
77
77
  "@react-native-async-storage/async-storage": "1.18.2",
78
78
  "@react-native-community/datetimepicker": "7.2.0",
@@ -11,7 +11,7 @@ import useContext from "$econtext/hooks";
11
11
  import PropTypes from "prop-types";
12
12
  import APP from "$capp/instance";
13
13
  import {isElectron} from "$cplatform";
14
- import {isValidUrl} from "$cutils/uri";
14
+ import {isValidUrl} from "$cutils";
15
15
  import {screenName} from "./utils";
16
16
 
17
17
  export default function UserProfileScreen({fields,...p}){
@@ -34,6 +34,16 @@ export default function UserProfileScreen({fields,...p}){
34
34
  })
35
35
  const p2 = {...p,fields};
36
36
  const props = typeof profilePropsMutator =='function'? extendObj({},p,profilePropsMutator(p2)) : p2;
37
+ const {changeElectronAppUrlPerm} = props;
38
+ const changeElectronUrl = React.useMemo(()=>{
39
+ if(!isElectron() || !window?.ELECTRON || typeof ELECTRON?.setAppUrl !=='function' || typeof ELECTRON?.getAppUrl !=='function') return false;
40
+ if(typeof changeElectronAppUrlPerm ==='string'){
41
+ return Auth.isAllowedFromStr(changeElectronAppUrlPerm);
42
+ } else if(typeof changeElectronAppUrlPerm =='function'){
43
+ return !!changeElectronAppUrlPerm(props);
44
+ }
45
+ return Auth.isMasterAdmin();
46
+ },[changeElectronAppUrlPerm]);
37
47
  const user = defaultObj(props.user,Auth.getLoggedUser());
38
48
  const testID = defaultStr(props.testID,"RN_UserProfile_FormData");
39
49
  const themeRef = React.useRef(defaultObj(user.theme));
@@ -67,7 +77,7 @@ export default function UserProfileScreen({fields,...p}){
67
77
  if(args.value === user.avatar) return;
68
78
  hasChangeRef.current = true;
69
79
  }
70
- if(isElectron() && typeof ELECTRON !=='undefined' && window?.ELECTRON && ELECTRON.session && typeof ELECTRON.session?.get =='function'){
80
+ if(changeElectronUrl){
71
81
  fields.mainElectronAppUrl = {
72
82
  label : "Url de l'application",
73
83
  onValidatorValid : ({value})=>{
@@ -75,7 +85,7 @@ export default function UserProfileScreen({fields,...p}){
75
85
  return "Vous devez spécifier une adresse url valide";
76
86
  }
77
87
  },
78
- defaultValue : ELECTRON.appUrl,
88
+ defaultValue : ELECTRON.getAppUrl(),
79
89
  };
80
90
  }
81
91
  const onSaveProfile = ({data,goBack,...rest})=>{
@@ -83,8 +93,8 @@ export default function UserProfileScreen({fields,...p}){
83
93
  Preloader.open("Modification en cours...");
84
94
  const toSave = {...user,...data};
85
95
  return Auth.upsertUser(toSave,true).then((response)=>{
86
- if(isValidUrl(data.mainElectronAppUrl) && isElectron()){
87
- ELECTRON.appUrl = data.mainElectronAppUrl;
96
+ if(changeElectronUrl){
97
+ ELECTRON.setAppUrl(data.mainElectronAppUrl);
88
98
  }
89
99
  setTimeout(()=>{
90
100
  APP.trigger(APP.EVENTS.UPDATE_THEME,user.theme);
@@ -95,6 +105,8 @@ export default function UserProfileScreen({fields,...p}){
95
105
  return goBack(true);
96
106
  }
97
107
  navigate('Home');
108
+ }).catch(e=>{
109
+ console.log(e," settings profile data");
98
110
  }).finally(()=>{
99
111
  setTimeout(()=>{
100
112
  Preloader.close();