@applicaster/zapp-react-native-utils 13.0.0-rc.124 → 13.0.0-rc.125
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.
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
actionExecutor as _actionExecutor,
|
|
6
6
|
ActionResult,
|
|
7
7
|
} from "./ActionExecutor";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { batchSave } from "../zappFrameworkUtils/localStorageHelper";
|
|
9
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
10
|
+
|
|
10
11
|
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
12
|
+
import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
11
13
|
import { showConfirmationDialog } from "../alertUtils";
|
|
12
14
|
import { createCloudEvent, sendCloudEvent } from "../cloudEventsUtils";
|
|
13
15
|
import { createLogger } from "../logger";
|
|
@@ -92,7 +94,15 @@ async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
|
92
94
|
const prepareDefaultActions = (actionExecutor) => {
|
|
93
95
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
94
96
|
const namespaces = action.options.content;
|
|
95
|
-
await
|
|
97
|
+
await batchSave(namespaces, localStorage);
|
|
98
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
99
|
+
|
|
100
|
+
return ActionResult.Success;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
actionExecutor.registerAction("sessionStorageSet", async (action) => {
|
|
104
|
+
const namespaces = action.options.content;
|
|
105
|
+
await batchSave(namespaces, sessionStorage);
|
|
96
106
|
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
97
107
|
|
|
98
108
|
return ActionResult.Success;
|
|
@@ -149,15 +159,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
149
159
|
actionExecutor.registerAction("confirmDialog", async (action) => {
|
|
150
160
|
log_info("handleAction: confirmDialog event");
|
|
151
161
|
|
|
152
|
-
|
|
162
|
+
return new Promise<ActionResult>((resolve) => {
|
|
153
163
|
showConfirmationDialog({
|
|
154
164
|
...action.options,
|
|
155
165
|
confirmCompletion: () => resolve(ActionResult.Success),
|
|
156
166
|
cancelCompletion: () => resolve(ActionResult.Cancel),
|
|
157
167
|
});
|
|
158
168
|
});
|
|
159
|
-
|
|
160
|
-
return confirmationPromise;
|
|
161
169
|
});
|
|
162
170
|
|
|
163
171
|
actionExecutor.registerAction("sendCloudEvent", async (action, context) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-rc.
|
|
3
|
+
"version": "13.0.0-rc.125",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "13.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-rc.125",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
StorageValuesToRemove,
|
|
8
8
|
StorageValuesToAdd,
|
|
9
9
|
} from "./types";
|
|
10
|
+
import { Storage } from "@applicaster/zapp-react-native-bridge/ZappStorage/Storage";
|
|
10
11
|
|
|
11
12
|
const defaultOwnedKey = "owned_keys";
|
|
12
13
|
const DEFAULT_NAMESPACE = "applicaster.v2";
|
|
@@ -50,8 +51,9 @@ function mapOwnedKeysToAdd(
|
|
|
50
51
|
return mappedData;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
export async function
|
|
54
|
-
storageValues: StorageValuesToAdd
|
|
54
|
+
export async function batchSave(
|
|
55
|
+
storageValues: StorageValuesToAdd,
|
|
56
|
+
storage: Storage
|
|
55
57
|
) {
|
|
56
58
|
if (isNilOrEmpty(storageValues)) {
|
|
57
59
|
return false;
|
|
@@ -64,12 +66,18 @@ export async function batchSaveToLocalStorage(
|
|
|
64
66
|
const value = namespaceData[key];
|
|
65
67
|
|
|
66
68
|
if (!isNilOrEmpty(value)) {
|
|
67
|
-
await
|
|
69
|
+
await storage.setItem(key, value, namespace);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
export async function batchSaveToLocalStorage(
|
|
76
|
+
storageValues: StorageValuesToAdd
|
|
77
|
+
) {
|
|
78
|
+
return await batchSave(storageValues, localStorage);
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
export async function batchRemoveFromLocalStorage(
|
|
74
82
|
storageValues: StorageValuesToRemove
|
|
75
83
|
) {
|