esoftplay 0.0.115-v → 0.0.115-w
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/modules/user/class.ts +5 -25
- package/package.json +1 -1
package/modules/user/class.ts
CHANGED
|
@@ -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,13 @@ 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();
|
|
25
20
|
})
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
static load(callback?: (user?: any | null) => void): Promise<any> {
|
|
29
24
|
return new Promise((r, j) => {
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
})
|
|
25
|
+
if (callback) callback(state?.get?.())
|
|
26
|
+
r((state?.get?.()))
|
|
46
27
|
})
|
|
47
28
|
}
|
|
48
29
|
|
|
@@ -59,11 +40,10 @@ export default class eclass {
|
|
|
59
40
|
}
|
|
60
41
|
|
|
61
42
|
static delete(): Promise<void> {
|
|
62
|
-
return new Promise(async(r) => {
|
|
43
|
+
return new Promise(async (r) => {
|
|
63
44
|
Notifications.setBadgeCountAsync(0)
|
|
64
45
|
state.reset()
|
|
65
46
|
await AsyncStorage.removeItem("user_notification");
|
|
66
|
-
await AsyncStorage.removeItem("user");
|
|
67
47
|
new UserData().deleteAll()
|
|
68
48
|
if (esp.config('notification') == 1) {
|
|
69
49
|
UserClass.pushToken()
|
|
@@ -74,7 +54,7 @@ export default class eclass {
|
|
|
74
54
|
|
|
75
55
|
static pushToken(): Promise<any> {
|
|
76
56
|
return new Promise((resolve, reject) => {
|
|
77
|
-
if (Constants.appOwnership == 'expo' && !esp.isDebug()) {
|
|
57
|
+
if (Constants.appOwnership == 'expo' && !esp.isDebug('')) {
|
|
78
58
|
resolve(undefined)
|
|
79
59
|
return
|
|
80
60
|
}
|