@norcy/react-native-toolkit 0.1.107 → 0.1.111
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/.DS_Store +0 -0
- package/.vscode/settings.json +9 -0
- package/{cocoa_plugins/cocoapods-rn-toolkit/lib → ios}/.DS_Store +0 -0
- package/ios/ReactNativeToolkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/lib/commonjs/ConfigDataModel.js +3 -30
- package/lib/commonjs/ConfigDataModel.js.map +1 -1
- package/lib/commonjs/VipManager.js +19 -11
- package/lib/commonjs/VipManager.js.map +1 -1
- package/lib/module/ConfigDataModel.js +3 -30
- package/lib/module/ConfigDataModel.js.map +1 -1
- package/lib/module/VipManager.js +19 -11
- package/lib/module/VipManager.js.map +1 -1
- package/package.json +1 -1
- package/{cocoa_plugins/cocoapods-rn-toolkit/lib/cocoapods-rn-toolkit → src}/.DS_Store +0 -0
- package/src/ConfigDataModel.ts +1 -31
- package/src/VipManager.ts +20 -9
- package/yarn-error.log +11644 -0
- package/cocoa_plugins/.DS_Store +0 -0
- package/cocoa_plugins/cocoapods-rn-toolkit/.DS_Store +0 -0
package/src/ConfigDataModel.ts
CHANGED
@@ -6,7 +6,6 @@ import { LoginResultDataType } from './LoginManager';
|
|
6
6
|
import { Notification } from './Notification';
|
7
7
|
import { BuildInPrefs } from './PrefData';
|
8
8
|
import { VipAndroidManager } from './VipAndroidManager';
|
9
|
-
import { VipManager } from './VipManager';
|
10
9
|
|
11
10
|
const EventEmitter = require('events').EventEmitter;
|
12
11
|
const eventEmitter = new EventEmitter();
|
@@ -46,23 +45,6 @@ const _filterByVersion = (items: Object[]) => {
|
|
46
45
|
return ret;
|
47
46
|
};
|
48
47
|
|
49
|
-
const _filterByVip = (items: Object[]) => {
|
50
|
-
let ret = [];
|
51
|
-
const isVip = VipManager.isVip();
|
52
|
-
const isForeverVip = VipManager.isForeverVip();
|
53
|
-
for (const item of items) {
|
54
|
-
const vipFilter = item.get('vipFilter');
|
55
|
-
if (
|
56
|
-
vipFilter === 0 ||
|
57
|
-
(vipFilter === 1 && !isVip) ||
|
58
|
-
(vipFilter === 2 && !isForeverVip)
|
59
|
-
) {
|
60
|
-
ret.push(item);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
return ret;
|
64
|
-
};
|
65
|
-
|
66
48
|
const _updateKeyValues = (items: Object[]) => {
|
67
49
|
for (const item of items) {
|
68
50
|
let value = item.get('value');
|
@@ -102,19 +84,16 @@ const handleVersionInfo = () => {
|
|
102
84
|
};
|
103
85
|
|
104
86
|
let isDataReady = false;
|
105
|
-
let isVipStateReady = false;
|
106
87
|
let isNetwordDataReady = false;
|
107
88
|
let OnlineItems: Object[] = [];
|
108
89
|
|
109
90
|
const _handleResponse = () => {
|
110
|
-
if (!
|
91
|
+
if (!isNetwordDataReady) {
|
111
92
|
return;
|
112
93
|
}
|
113
94
|
|
114
95
|
// 根据版本过滤
|
115
96
|
let items = _filterByVersion(OnlineItems);
|
116
|
-
// 根据 VIP 状态过滤
|
117
|
-
items = _filterByVip(items);
|
118
97
|
_updateKeyValues(items);
|
119
98
|
// 处理 Version 信息
|
120
99
|
handleVersionInfo();
|
@@ -128,20 +107,11 @@ const ConfigDataModel = {
|
|
128
107
|
init: (defaultValues: ConfigsType) => {
|
129
108
|
MyItems = defaultValues;
|
130
109
|
|
131
|
-
Notification.addListener('onVipRefresh', ({ e }: { e: any }) => {
|
132
|
-
// 监听多次,直到成功,整个生命周期最多处理一次
|
133
|
-
if (!e && !isVipStateReady) {
|
134
|
-
isVipStateReady = true;
|
135
|
-
_handleResponse();
|
136
|
-
}
|
137
|
-
});
|
138
|
-
|
139
110
|
Notification.addListener(
|
140
111
|
'onLogin',
|
141
112
|
({ isAuto, user, error }: LoginResultDataType) => {
|
142
113
|
if (!isAuto && user && !error) {
|
143
114
|
isDataReady = false;
|
144
|
-
isVipStateReady = false;
|
145
115
|
isNetwordDataReady = false;
|
146
116
|
OnlineItems = [];
|
147
117
|
ConfigDataModel.fetch();
|
package/src/VipManager.ts
CHANGED
@@ -9,10 +9,21 @@ import { Notification } from './Notification';
|
|
9
9
|
import { BuildInPrefs } from './PrefData';
|
10
10
|
import { Tool, ToolkitConfig } from './Tool';
|
11
11
|
import { VipAndroidManager } from './VipAndroidManager';
|
12
|
+
import { UserType } from './constant';
|
12
13
|
|
13
14
|
let _customerInfo: CustomerInfo | null;
|
14
15
|
let isReady = false;
|
15
16
|
|
17
|
+
const onLogin = async (user: UserType) => {
|
18
|
+
try {
|
19
|
+
await Purchases.logIn(user.AVUser.get('objectId'));
|
20
|
+
await Purchases.setAttributes({ nickname: user.nickname });
|
21
|
+
await VipManager.refreshVip();
|
22
|
+
} catch (e) {
|
23
|
+
console.error(e);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
16
27
|
export const VipManager = {
|
17
28
|
init: async () => {
|
18
29
|
isReady = !!ToolkitConfig.RC_API_KEY;
|
@@ -24,7 +35,7 @@ export const VipManager = {
|
|
24
35
|
|
25
36
|
console.log('Vip 模块初始化');
|
26
37
|
|
27
|
-
if (
|
38
|
+
if (ToolkitConfig.RC_PROXY_URL) {
|
28
39
|
console.log('设置代理', ToolkitConfig.RC_PROXY_URL);
|
29
40
|
await Purchases.setProxyURL(ToolkitConfig.RC_PROXY_URL);
|
30
41
|
}
|
@@ -32,18 +43,18 @@ export const VipManager = {
|
|
32
43
|
|
33
44
|
VipManager.refreshVip();
|
34
45
|
|
46
|
+
const loginUser = LoginManager.currentUser();
|
47
|
+
if (loginUser) {
|
48
|
+
console.log('Vip 模块用户登录 from 直接');
|
49
|
+
onLogin(loginUser);
|
50
|
+
}
|
51
|
+
|
35
52
|
Notification.addListener(
|
36
53
|
'onLogin',
|
37
54
|
async ({ error, user }: LoginResultDataType) => {
|
38
|
-
console.log('Vip 模块用户登录');
|
55
|
+
console.log('Vip 模块用户登录 from 监听');
|
39
56
|
if (!error && user) {
|
40
|
-
|
41
|
-
await Purchases.logIn(user.AVUser.get('objectId'));
|
42
|
-
await Purchases.setAttributes({ nickname: user.nickname });
|
43
|
-
await VipManager.refreshVip();
|
44
|
-
} catch (e) {
|
45
|
-
console.error(e);
|
46
|
-
}
|
57
|
+
onLogin(user);
|
47
58
|
}
|
48
59
|
}
|
49
60
|
);
|