esoftplay 0.0.115-u → 0.0.115-x

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
@@ -40,7 +40,7 @@ let subscriber = {}
40
40
  let debouceTime
41
41
  let persistKeys: any = {}
42
42
 
43
- export default function m<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
43
+ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
44
44
  const _idx = globalIdx.idx
45
45
  if (!subscriber[_idx])
46
46
  subscriber[_idx] = [];
@@ -8,7 +8,7 @@ import { Platform } from 'react-native';
8
8
  import useGlobalState from '../../global';
9
9
  import moment from "../../moment";
10
10
 
11
- const state = useGlobalState?.(null)
11
+ const state = useGlobalState?.(null, { persistKey: "user" })
12
12
 
13
13
  export default class eclass {
14
14
  static state(): useGlobalReturn<any> {
@@ -17,32 +17,14 @@ export default class eclass {
17
17
  static create(user: any): Promise<void> {
18
18
  return new Promise((r, j) => {
19
19
  state?.set?.(user)
20
- AsyncStorage.setItem("user", new LibCrypt().encode(JSON.stringify(user)))
21
- if (esp.config('notification') == 1) {
22
- UserClass.pushToken()
23
- }
24
- r();
20
+ r(user)
25
21
  })
26
22
  }
27
23
 
28
24
  static load(callback?: (user?: any | null) => void): Promise<any> {
29
25
  return new Promise((r, j) => {
30
- AsyncStorage.getItem("user").then((user: string) => {
31
- if (user) {
32
- const usr = (user[0] == '{' && user[user.length - 1] == '}') ? JSON.parse(user) : JSON.parse(new LibCrypt().decode(user))
33
- if (usr) {
34
- r(usr);
35
- state?.set?.(usr)
36
- if (callback) callback(usr)
37
- } else {
38
- j()
39
- if (callback) callback(null)
40
- }
41
- } else {
42
- j()
43
- if (callback) callback(null)
44
- }
45
- })
26
+ if (callback) callback(state?.get?.())
27
+ r((state?.get?.()))
46
28
  })
47
29
  }
48
30
 
@@ -59,11 +41,10 @@ export default class eclass {
59
41
  }
60
42
 
61
43
  static delete(): Promise<void> {
62
- return new Promise(async(r) => {
44
+ return new Promise(async (r) => {
63
45
  Notifications.setBadgeCountAsync(0)
64
46
  state.reset()
65
47
  await AsyncStorage.removeItem("user_notification");
66
- await AsyncStorage.removeItem("user");
67
48
  new UserData().deleteAll()
68
49
  if (esp.config('notification') == 1) {
69
50
  UserClass.pushToken()
@@ -74,7 +55,7 @@ export default class eclass {
74
55
 
75
56
  static pushToken(): Promise<any> {
76
57
  return new Promise((resolve, reject) => {
77
- if (Constants.appOwnership == 'expo' && !esp.isDebug()) {
58
+ if (Constants.appOwnership == 'expo' && !esp.isDebug('')) {
78
59
  resolve(undefined)
79
60
  return
80
61
  }
@@ -31,7 +31,7 @@ function setFonts(): Promise<void> {
31
31
 
32
32
 
33
33
 
34
- export default function m(props: UserIndexProps): any {
34
+ export default function UserIndex(props: UserIndexProps): any {
35
35
  const [loading, setLoading] = useSafeState(true)
36
36
  const [worker] = LibWorker.workerState().useState()
37
37
  const user = UserClass.state().useSelector(s => s)
@@ -52,7 +52,7 @@ export default function m(props: UserIndexProps): any {
52
52
  // const timeout = setTimeout(() => {
53
53
  // setLoading(false)
54
54
  // }, 15 * 1000);
55
- let limitReady = 2
55
+ let limitReady = 3
56
56
  if (Platform.OS == 'android')
57
57
  if (Platform.Version <= 22) {
58
58
  limitReady = 2
@@ -72,12 +72,12 @@ export default function m(props: UserIndexProps): any {
72
72
  }
73
73
  })()
74
74
 
75
- // UserClass.isLogin(async () => {
76
- // ready.current += 1
77
- // if (ready.current >= limitReady) {
78
- // setLoading(false)
79
- // }
80
- // })
75
+ UserClass.isLogin(async () => {
76
+ ready.current += 1
77
+ if (ready.current >= limitReady) {
78
+ setLoading(false)
79
+ }
80
+ })
81
81
  if (esp.config('firebase').hasOwnProperty('apiKey')) {
82
82
  try {
83
83
  if (ChattingFirebase)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.115-u",
3
+ "version": "0.0.115-x",
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",