esoftplay 0.0.117-a → 0.0.117-b

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/global.ts CHANGED
@@ -51,7 +51,9 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
51
51
  rehidryte(o.persistKey, (p) => {
52
52
  if (typeof p == 'string') {
53
53
  if (p.startsWith("{") || p.startsWith("["))
54
- set(JSON.parse(p))
54
+ try {
55
+ set(JSON.parse(p))
56
+ } catch (error) { }
55
57
  else {
56
58
  set(p);
57
59
  }
@@ -158,9 +160,7 @@ function rehidryte(key: string, func: (e: string) => void) {
158
160
  debounce(() => {
159
161
  AsyncStorage.multiGet(Object.keys(persistKeys), (e, v) => {
160
162
  if (v && !e) {
161
- v.forEach((iv, i) => {
162
- persistKeys[iv[0]]?.(iv[1])
163
- })
163
+ v.forEach((iv, i) => { persistKeys[iv[0]]?.(iv[1]) })
164
164
  _global.useGlobalStateReady = 1
165
165
  } else {
166
166
  _global.useGlobalStateReady = 1
@@ -15,8 +15,9 @@ export default class eclass {
15
15
  return state
16
16
  }
17
17
  static create(user: any): Promise<void> {
18
- return new Promise((r, j) => {
18
+ return new Promise(async (r, j) => {
19
19
  state?.set?.(user)
20
+ await AsyncStorage.setItem('user', JSON.stringify(user))
20
21
  if (esp.config('notification') == 1) {
21
22
  UserClass.pushToken()
22
23
  }
@@ -26,8 +27,11 @@ export default class eclass {
26
27
 
27
28
  static load(callback?: (user?: any | null) => void): Promise<any> {
28
29
  return new Promise((r, j) => {
29
- if (callback) callback(state?.get?.())
30
- r((state?.get?.()))
30
+ AsyncStorage.getItem('user').then((user) => {
31
+ const _user = user ? JSON.parse(user) : null
32
+ if (callback) callback(_user)
33
+ r(_user)
34
+ })
31
35
  })
32
36
  }
33
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.117-a",
3
+ "version": "0.0.117-b",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",