@applicaster/zapp-react-native-utils 12.0.23-rc.0 → 12.0.24-rc.0
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";
|
|
@@ -91,7 +93,15 @@ async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
|
91
93
|
const prepareDefaultActions = (actionExecutor) => {
|
|
92
94
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
93
95
|
const namespaces = action.options.content;
|
|
94
|
-
await
|
|
96
|
+
await batchSave(namespaces, localStorage);
|
|
97
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
98
|
+
|
|
99
|
+
return ActionResult.Success;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
actionExecutor.registerAction("sessionStorageSet", async (action) => {
|
|
103
|
+
const namespaces = action.options.content;
|
|
104
|
+
await batchSave(namespaces, sessionStorage);
|
|
95
105
|
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
96
106
|
|
|
97
107
|
return ActionResult.Success;
|
|
@@ -148,15 +158,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
148
158
|
actionExecutor.registerAction("confirmDialog", async (action) => {
|
|
149
159
|
log_info("handleAction: confirmDialog event");
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
return new Promise<ActionResult>((resolve) => {
|
|
152
162
|
showConfirmationDialog({
|
|
153
163
|
...action.options,
|
|
154
164
|
confirmCompletion: () => resolve(ActionResult.Success),
|
|
155
165
|
cancelCompletion: () => resolve(ActionResult.Cancel),
|
|
156
166
|
});
|
|
157
167
|
});
|
|
158
|
-
|
|
159
|
-
return confirmationPromise;
|
|
160
168
|
});
|
|
161
169
|
|
|
162
170
|
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": "12.0.
|
|
3
|
+
"version": "12.0.24-rc.0",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.24-rc.0",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -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
|
) {
|