esoftplay 0.0.142-e → 0.0.142-f

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.
@@ -1,3 +1,4 @@
1
+ //[moved] add new function multiregister
1
2
  // noPage
2
3
  // withObject
3
4
  import AsyncStorage from '@react-native-async-storage/async-storage';
@@ -5,30 +6,51 @@ import { userDataReset } from 'esoftplay/global';
5
6
  import FastStorage from 'esoftplay/mmkv';
6
7
  import Storage from 'esoftplay/storage';
7
8
 
9
+ (() => {
10
+ AsyncStorage.getItem("user_data_dependent").then((keys) => {
11
+ if (keys) {
12
+ FastStorage.setItem("user_data_dependent", keys)
13
+ AsyncStorage.removeItem("user_data_dependent")
14
+ }
15
+ })
16
+ })()
17
+
8
18
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/user/data.md) untuk melihat dokumentasi*/
9
19
  export default {
10
- /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/user/data.md#register) untuk melihat dokumentasi*/
20
+ /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/user/data.md#register) untuk melihat dokumentasi*/
11
21
  register(name: string): void {
12
- AsyncStorage.getItem("user_data_dependent").then((x) => {
13
- let all: string[] = []
14
- if (x) {
15
- all = JSON.parse(x).filter((x) => x != name)
16
- }
17
- all.push(name)
18
- AsyncStorage.setItem("user_data_dependent", JSON.stringify(all))
19
- })
22
+ const x = FastStorage.getItemSync("user_data_dependent")
23
+ let all: string[] = []
24
+ if (x) {
25
+ all = JSON.parse(x).filter((x) => x != name)
26
+ }
27
+ all.push(name)
28
+ FastStorage.setItem("user_data_dependent", JSON.stringify(all))
29
+ },
30
+ async multiRegister(names: string[]): Promise<void> {
31
+ try {
32
+ const data = await FastStorage.getItem("user_data_dependent");
33
+ const all = data ? JSON.parse(data) : [];
34
+
35
+ const uniqueNames = names.filter((name) => !all.includes(name));
36
+ const updatedAll = [...all, ...uniqueNames];
37
+
38
+ await FastStorage.setItem("user_data_dependent", JSON.stringify(updatedAll));
39
+ } catch (error) {
40
+ console.error("Error registering multiple names:", error);
41
+ }
20
42
  },
21
43
  unregister(name: string): void {
22
- AsyncStorage.getItem("user_data_dependent").then((x) => {
44
+ FastStorage.getItem("user_data_dependent").then((x) => {
23
45
  let all = []
24
46
  if (x) {
25
47
  all = JSON.parse(x).filter((x) => x != name)
26
48
  }
27
- AsyncStorage.setItem("user_data_dependent", JSON.stringify(all))
49
+ FastStorage.setItem("user_data_dependent", JSON.stringify(all))
28
50
  })
29
51
  },
30
52
  deleteAll(): void {
31
- AsyncStorage.getItem("user_data_dependent").then((x) => {
53
+ FastStorage.getItem("user_data_dependent").then((x) => {
32
54
  if (x) {
33
55
  userDataReset.forEach((f) => f())
34
56
  const arx = JSON.parse(x)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.142-e",
3
+ "version": "0.0.142-f",
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",