@applicaster/zapp-react-native-utils 13.0.0-rc.128 → 13.0.0-rc.129
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,7 +5,10 @@ import {
|
|
|
5
5
|
actionExecutor as _actionExecutor,
|
|
6
6
|
ActionResult,
|
|
7
7
|
} from "./ActionExecutor";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
batchRemoveAllFromNamespaceForStorage,
|
|
10
|
+
batchSave,
|
|
11
|
+
} from "../zappFrameworkUtils/localStorageHelper";
|
|
9
12
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
10
13
|
|
|
11
14
|
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
@@ -29,7 +32,8 @@ import {
|
|
|
29
32
|
usePickFromState,
|
|
30
33
|
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
31
34
|
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
|
|
32
|
-
import { postEvent } from "../reactHooks/useSubscriberFor";
|
|
35
|
+
import { postEvent, useSubscriberFor } from "../reactHooks/useSubscriberFor";
|
|
36
|
+
import { APP_EVENTS } from "../appUtils/events";
|
|
33
37
|
|
|
34
38
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
35
39
|
subsystem: "ActionExecutorContext",
|
|
@@ -311,9 +315,24 @@ export function withActionExecutor(Component) {
|
|
|
311
315
|
};
|
|
312
316
|
}, []);
|
|
313
317
|
|
|
318
|
+
useSubscriberFor(APP_EVENTS.onLogout, () => {
|
|
319
|
+
log_debug(
|
|
320
|
+
"User profile: onLogout event received, clearing user profile data"
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
const userAccountKey = "user_account";
|
|
324
|
+
void batchRemoveAllFromNamespaceForStorage(userAccountKey, localStorage);
|
|
325
|
+
|
|
326
|
+
void batchRemoveAllFromNamespaceForStorage(
|
|
327
|
+
userAccountKey,
|
|
328
|
+
sessionStorage
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
|
|
314
332
|
useEffect(() => {
|
|
315
333
|
return _actionExecutor.registerAction(
|
|
316
334
|
"navigateToScreen",
|
|
335
|
+
|
|
317
336
|
async (action: ActionType, context?: Record<string, any>) => {
|
|
318
337
|
const screenType = action.options?.typeMapping;
|
|
319
338
|
|
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.129",
|
|
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.129",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -78,18 +78,25 @@ export async function batchSaveToLocalStorage(
|
|
|
78
78
|
return await batchSave(storageValues, localStorage);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export async function
|
|
82
|
-
storageValues: StorageValuesToRemove
|
|
81
|
+
export async function batchRemoveFromStorage(
|
|
82
|
+
storageValues: StorageValuesToRemove,
|
|
83
|
+
storage: Storage = localStorage
|
|
83
84
|
) {
|
|
84
85
|
for (const namespace of Object.keys(storageValues)) {
|
|
85
86
|
const namespaceData = storageValues[namespace];
|
|
86
87
|
|
|
87
88
|
for (const key of namespaceData) {
|
|
88
|
-
await
|
|
89
|
+
await storage.removeItem(key, namespace);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
export async function batchRemoveFromLocalStorage(
|
|
95
|
+
storageValues: StorageValuesToRemove
|
|
96
|
+
) {
|
|
97
|
+
await batchRemoveFromStorage(storageValues, localStorage);
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
async function addOwnedKeys({
|
|
94
101
|
newKeys,
|
|
95
102
|
ownershipKey,
|
|
@@ -232,13 +239,20 @@ export async function batchRemoveOwnedNamespaceKeys({
|
|
|
232
239
|
});
|
|
233
240
|
}
|
|
234
241
|
|
|
235
|
-
export async function
|
|
236
|
-
|
|
242
|
+
export async function batchRemoveAllFromNamespaceForStorage(
|
|
243
|
+
namespace: string,
|
|
244
|
+
storage: Storage
|
|
245
|
+
) {
|
|
246
|
+
const allDataInNamespace = await storage.getAllItems(namespace);
|
|
237
247
|
const keysToRemove = Object.keys(allDataInNamespace);
|
|
238
248
|
|
|
239
|
-
const dataToRemove = {
|
|
249
|
+
const dataToRemove: StorageValuesToRemove = {
|
|
240
250
|
[namespace]: keysToRemove,
|
|
241
251
|
};
|
|
242
252
|
|
|
243
|
-
await
|
|
253
|
+
await batchRemoveFromStorage(dataToRemove, storage);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export async function batchRemoveAllFromNamespace(namespace: string) {
|
|
257
|
+
await batchRemoveAllFromNamespaceForStorage(namespace, localStorage);
|
|
244
258
|
}
|