@fto-consult/expo-ui 8.20.2 → 8.20.4

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": "8.20.2",
3
+ "version": "8.20.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
package/src/App.js CHANGED
@@ -21,8 +21,7 @@ export default function ExpoUIAppEntryProvider({children:cChildren,init,...rest}
21
21
  const canInit = typeof session.init =="function";
22
22
  useEffect(()=>{
23
23
  if(!canInit) return ()=>{}
24
- Promise.resolve(init).finally(()=>{
25
- console.log("will initializing")
24
+ Promise.resolve(session.init()).finally(()=>{
26
25
  return setChildren(<Provider {...rest}>
27
26
  <App init={init} children={cChildren}/>
28
27
  </Provider>);
@@ -34,23 +34,27 @@ export class SQLiteSession {
34
34
  }
35
35
  async init () {
36
36
  if (!this.db || !this.hasInit) {
37
- const dbName = this.getDBName();
38
- debug(`Opening sqlite database ${dbName} for session storage`);
39
37
  if(!this.openingPromise){
40
- this.openingPromise = SQLite.openDatabaseAsync(dbName).then((db)=>{
41
- return db.execAsync(`
42
- CREATE TABLE IF NOT EXISTS ${SESSION_TABLE} (id INTEGER PRIMARY KEY NOT NULL, key TEXT, value TEXT);
43
- `).then((d)=>{
38
+ const dbName = this.getDBName();
39
+ debug(`Opening sqlite database ${dbName} for session storage`);
40
+ this.openingPromise = new Promise((resolve,reject)=>{
41
+ return SQLite.openDatabaseAsync(dbName).then((db)=>{
42
+ return db.execAsync(`
43
+ CREATE TABLE IF NOT EXISTS ${SESSION_TABLE} (id INTEGER PRIMARY KEY NOT NULL, key TEXT, value TEXT);
44
+ `).then((d)=>{
44
45
  this.db = db;
45
46
  this.hasInit = true;
46
- this.getAll();
47
+ return this.getAll().then((()=>{
48
+ resolve(db);
49
+ }));
50
+ })
47
51
  }).catch((e)=>{
48
- debug(e," error when initializing sqlite session");
49
- throw e;
50
- });
51
- }).finally(()=>{
52
- delete this.openingPromise;
53
- });;
52
+ debug(e," error when initializing sqlite session");
53
+ reject(e);
54
+ }).finally(()=>{
55
+ delete this.openingPromise;
56
+ });;
57
+ });
54
58
  }
55
59
  return this.openingPromise;
56
60
  }