@applicaster/zapp-react-native-bridge 12.0.0-rc.9 → 12.0.0-rc.90
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/OfflineAssets/__tests__/__snapshots__/fileManager.test.ts.snap +2 -2
- package/OfflineAssets/__tests__/fileManager.test.ts +53 -50
- package/OfflineAssets/index.ts +11 -3
- package/PushNotifications/PushTopicManager.ts +4 -6
- package/QuickBrick/__tests__/quickBrickModule.test.ts +45 -49
- package/QuickBrick/__tests__/quickBrickModule_noModule.test.ts +8 -7
- package/ZappStorage/Storage.ts +9 -1
- package/ZappStorage/StorageMultiSelectProvider.ts +45 -22
- package/ZappStorage/__tests__/__snapshots__/localStorage.test.ts.snap +12 -12
- package/ZappStorage/__tests__/__snapshots__/sessionStorage.test.ts.snap +12 -12
- package/ZappStorage/__tests__/localStorage.test.ts +383 -383
- package/ZappStorage/__tests__/localStorageAndroid.test.ts +3 -6
- package/ZappStorage/__tests__/sessionStorage.test.ts +415 -394
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`deleteFolders deletes each provided path 1`] = `true`;
|
|
3
|
+
exports[`fileManager deleteFolders deletes each provided path 1`] = `true`;
|
|
4
4
|
|
|
5
|
-
exports[`storeFiles calls the store file function of the native module with the provided args 1`] = `
|
|
5
|
+
exports[`fileManager storeFiles calls the store file function of the native module with the provided args 1`] = `
|
|
6
6
|
Object {
|
|
7
7
|
"http://file": true,
|
|
8
8
|
"http://file2": true,
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
+
import * as ReactNative from "react-native";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
NativeModules: {
|
|
5
|
-
OfflineAssetsBridge: {
|
|
6
|
-
storeFiles: jest.fn((files) => {
|
|
7
|
-
if (files.includes("fail")) throw new Error("Error storing file");
|
|
4
|
+
const { NativeModules } = ReactNative;
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
const OfflineAssetsBridge = {
|
|
7
|
+
storeFiles: jest.fn((files) => {
|
|
8
|
+
if (files.includes("fail")) throw new Error("Error storing file");
|
|
9
|
+
|
|
10
|
+
return Promise.resolve(
|
|
11
|
+
files.reduce((acc, curr) => {
|
|
12
|
+
return R.assoc(curr.url, true, acc);
|
|
13
|
+
}, {})
|
|
14
|
+
);
|
|
15
|
+
}),
|
|
16
|
+
delete: jest.fn((file) => {
|
|
17
|
+
if (file.includes("fail")) throw new Error("Error deleting file");
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
19
|
+
return Promise.resolve(true);
|
|
20
|
+
}),
|
|
21
|
+
getFilesDirectory: jest.fn(() => Promise.resolve("/native/path/")),
|
|
22
|
+
};
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
NativeModules: { OfflineAssetsBridge },
|
|
27
|
-
} = require("react-native");
|
|
24
|
+
NativeModules.OfflineAssetsBridge = OfflineAssetsBridge;
|
|
28
25
|
|
|
29
26
|
const { storeFiles, deleteFolders, getNativeRootPath } = require("..");
|
|
30
27
|
|
|
@@ -34,47 +31,53 @@ function clearMocks() {
|
|
|
34
31
|
OfflineAssetsBridge.getFilesDirectory.mockClear();
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
describe("
|
|
38
|
-
|
|
34
|
+
describe("fileManager", () => {
|
|
35
|
+
describe("storeFiles", () => {
|
|
36
|
+
beforeEach(clearMocks);
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
it("calls the store file function of the native module with the provided args", async () => {
|
|
39
|
+
const files = [{ url: "http://file" }, { url: "http://file2" }];
|
|
40
|
+
const options = {};
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
const result = await storeFiles(files, options);
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
expect(OfflineAssetsBridge.storeFiles).toHaveBeenCalledWith(
|
|
45
|
+
files,
|
|
46
|
+
options
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(result).toMatchSnapshot();
|
|
50
|
+
});
|
|
48
51
|
});
|
|
49
|
-
});
|
|
50
52
|
|
|
51
|
-
describe("deleteFolders", () => {
|
|
52
|
-
|
|
53
|
+
describe("deleteFolders", () => {
|
|
54
|
+
beforeEach(clearMocks);
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
it("deletes each provided path", async () => {
|
|
57
|
+
const folders = ["folder1", "folder2", "folder3"];
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
const result = await deleteFolders(folders);
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
expect.assertions(folders.length + 2);
|
|
62
|
+
expect(result).toMatchSnapshot();
|
|
63
|
+
expect(OfflineAssetsBridge.delete).toHaveBeenCalledTimes(folders.length);
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
folders.forEach((folder, index) => {
|
|
66
|
+
expect(OfflineAssetsBridge.delete).toHaveBeenNthCalledWith(
|
|
67
|
+
index + 1,
|
|
68
|
+
folder
|
|
69
|
+
);
|
|
70
|
+
});
|
|
68
71
|
});
|
|
69
72
|
});
|
|
70
|
-
});
|
|
71
73
|
|
|
72
|
-
describe("getNativeRootPath", () => {
|
|
73
|
-
|
|
74
|
+
describe("getNativeRootPath", () => {
|
|
75
|
+
beforeEach(clearMocks);
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
it("returns the native root path", async () => {
|
|
78
|
+
const nativePath = await OfflineAssetsBridge.getFilesDirectory();
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
await expect(getNativeRootPath()).resolves.toEqual(nativePath);
|
|
81
|
+
});
|
|
79
82
|
});
|
|
80
83
|
});
|
package/OfflineAssets/index.ts
CHANGED
|
@@ -91,7 +91,8 @@ export const remapAssetPath = (
|
|
|
91
91
|
if (!localFile) {
|
|
92
92
|
bridgeLogger.warning({
|
|
93
93
|
message: `remapAssetPath: Could not replace asset with local file for url: ${url}`,
|
|
94
|
-
data: { path, obj }
|
|
94
|
+
data: { path, obj },
|
|
95
|
+
});
|
|
95
96
|
|
|
96
97
|
return obj;
|
|
97
98
|
}
|
|
@@ -104,7 +105,10 @@ export const remapAssetPath = (
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
if (!target) {
|
|
107
|
-
bridgeLogger.error({
|
|
108
|
+
bridgeLogger.error({
|
|
109
|
+
message: `remapAssetPath: Could not find path ${path.join(".")}`,
|
|
110
|
+
data: obj,
|
|
111
|
+
});
|
|
108
112
|
} else {
|
|
109
113
|
// Set the final value
|
|
110
114
|
target[path[path.length - 1]] = localFile;
|
|
@@ -113,7 +117,11 @@ export const remapAssetPath = (
|
|
|
113
117
|
return obj;
|
|
114
118
|
}, JSON.parse(JSON.stringify(source)));
|
|
115
119
|
|
|
116
|
-
bridgeLogger.log({
|
|
120
|
+
bridgeLogger.log({
|
|
121
|
+
message: `remapAssetPath: remapping took ${
|
|
122
|
+
performance.now() - startTime
|
|
123
|
+
} ms, tag: ${tag}`,
|
|
124
|
+
});
|
|
117
125
|
|
|
118
126
|
return result;
|
|
119
127
|
};
|
|
@@ -25,14 +25,14 @@ export enum PushTopicManagerConsts {
|
|
|
25
25
|
export enum PushTopicManagerEvents {
|
|
26
26
|
push_topics_changed = "push_topics_changed",
|
|
27
27
|
plugin_enabled = "plugin_enabled",
|
|
28
|
-
plugin_disabled = "plugin_disabled"
|
|
28
|
+
plugin_disabled = "plugin_disabled",
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export class PushTopicManager {
|
|
32
32
|
private registeredTags: string[] | null;
|
|
33
33
|
private pushTopicSubject: BehaviorSubject<string[] | null>;
|
|
34
34
|
|
|
35
|
-
constructor() {
|
|
35
|
+
constructor() {}
|
|
36
36
|
|
|
37
37
|
getEntryObservable = (): BehaviorSubject<string[]> => {
|
|
38
38
|
return this.pushTopicSubject;
|
|
@@ -53,11 +53,9 @@ export class PushTopicManager {
|
|
|
53
53
|
)}'`
|
|
54
54
|
);
|
|
55
55
|
} else {
|
|
56
|
-
log_error(
|
|
57
|
-
`routeEvent: Unknown event received: ${event.type}`,
|
|
58
|
-
);
|
|
56
|
+
log_error(`routeEvent: Unknown event received: ${event.type}`);
|
|
59
57
|
}
|
|
60
|
-
}
|
|
58
|
+
};
|
|
61
59
|
|
|
62
60
|
prepareTags = async () => {
|
|
63
61
|
try {
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
foo: "bar",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
});
|
|
1
|
+
import * as ReactNative from "react-native";
|
|
2
|
+
|
|
3
|
+
ReactNative.NativeModules.QuickBrickCommunicationModule = {
|
|
4
|
+
quickBrickEvent: jest.fn(),
|
|
5
|
+
accountId: 123,
|
|
6
|
+
accountsAccountId: "accountsAccountIDString1234",
|
|
7
|
+
broadcasterId: 145,
|
|
8
|
+
bundleIdentifier: "com.apptestname",
|
|
9
|
+
initialProps: {
|
|
10
|
+
foo: "bar",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
19
13
|
|
|
20
14
|
const {
|
|
21
15
|
sendQuickBrickEvent,
|
|
22
16
|
getAppData,
|
|
23
17
|
getLegacyInitialProps,
|
|
24
|
-
} = require("
|
|
18
|
+
} = require("..");
|
|
25
19
|
|
|
26
20
|
const eventName = "event";
|
|
27
21
|
const payload = {};
|
|
@@ -33,44 +27,46 @@ const bundleIdentifier = "com.apptestname";
|
|
|
33
27
|
|
|
34
28
|
const { NativeModules } = require("react-native");
|
|
35
29
|
|
|
36
|
-
describe("
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
describe("QuickBrickModule", () => {
|
|
31
|
+
describe("sendQuickBrickEvent", () => {
|
|
32
|
+
it("invokes the native module", () => {
|
|
33
|
+
sendQuickBrickEvent(eventName, payload);
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
expect(
|
|
36
|
+
NativeModules.QuickBrickCommunicationModule.quickBrickEvent
|
|
37
|
+
).toHaveBeenCalledWith(eventName, payload);
|
|
38
|
+
});
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
it("passes an empty object as payload if not provided", () => {
|
|
41
|
+
sendQuickBrickEvent(eventName);
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
expect(
|
|
44
|
+
NativeModules.QuickBrickCommunicationModule.quickBrickEvent
|
|
45
|
+
).toHaveBeenCalledWith(eventName, {});
|
|
46
|
+
});
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
NativeModules.QuickBrickCommunicationModule.quickBrickEvent.mockRestore();
|
|
50
|
+
});
|
|
55
51
|
});
|
|
56
|
-
});
|
|
57
52
|
|
|
58
|
-
describe("getAppData", () => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
describe("getAppData", () => {
|
|
54
|
+
it("returns the app data", () => {
|
|
55
|
+
const appData = getAppData();
|
|
56
|
+
expect(appData).toHaveProperty("accountId", accountId);
|
|
57
|
+
expect(appData).toHaveProperty("accountsAccountId", accountsAccountId);
|
|
58
|
+
expect(appData).toHaveProperty("broadcasterId", broadcasterId);
|
|
59
|
+
expect(appData).toHaveProperty("bundleIdentifier", bundleIdentifier);
|
|
60
|
+
});
|
|
65
61
|
});
|
|
66
|
-
});
|
|
67
62
|
|
|
68
|
-
describe("getLegacyInitialProps", () => {
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
describe("getLegacyInitialProps", () => {
|
|
64
|
+
it("returns the initial props", () => {
|
|
65
|
+
const initialProps = getLegacyInitialProps();
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
expect(initialProps).toEqual(
|
|
68
|
+
NativeModules.QuickBrickCommunicationModule.initialProps
|
|
69
|
+
);
|
|
70
|
+
});
|
|
75
71
|
});
|
|
76
72
|
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
Foo: jest.fn(),
|
|
3
|
-
};
|
|
1
|
+
const { NativeModules } = require("react-native");
|
|
4
2
|
|
|
5
|
-
jest.
|
|
6
|
-
NativeModules: mock_NativeModules,
|
|
7
|
-
}));
|
|
3
|
+
NativeModules.Foo = jest.fn();
|
|
8
4
|
|
|
9
5
|
jest.mock("../../logger", () => ({
|
|
10
6
|
bridgeLogger: {
|
|
@@ -16,7 +12,7 @@ const {
|
|
|
16
12
|
sendQuickBrickEvent,
|
|
17
13
|
getAppData,
|
|
18
14
|
getLegacyInitialProps,
|
|
19
|
-
} = require("../
|
|
15
|
+
} = require("../");
|
|
20
16
|
|
|
21
17
|
const eventName = "event";
|
|
22
18
|
const payload = {};
|
|
@@ -24,6 +20,11 @@ const payload = {};
|
|
|
24
20
|
const { bridgeLogger } = require("../../logger");
|
|
25
21
|
|
|
26
22
|
describe("when QuickBrickCommunication Module is undefined", () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
jest.unmock("react-native");
|
|
25
|
+
jest.resetModules();
|
|
26
|
+
});
|
|
27
|
+
|
|
27
28
|
describe("sendQuickBrickEvent", () => {
|
|
28
29
|
it("throws an error", () => {
|
|
29
30
|
expect(() => sendQuickBrickEvent(eventName, payload)).toThrow();
|
package/ZappStorage/Storage.ts
CHANGED
|
@@ -110,12 +110,20 @@ export abstract class Storage {
|
|
|
110
110
|
|
|
111
111
|
// Storage methods
|
|
112
112
|
|
|
113
|
-
getItem = async (
|
|
113
|
+
getItem = async (
|
|
114
|
+
key,
|
|
115
|
+
namespace = DEFAULT_NAMESPACE,
|
|
116
|
+
skipJsonParse = false
|
|
117
|
+
) => {
|
|
114
118
|
if (!key) throwUndefinedKeyError(this.storageName, UNDEFINED_KEY_MESSAGE);
|
|
115
119
|
|
|
116
120
|
try {
|
|
117
121
|
const result = await this.nativeStorageModule.getItem(key, namespace);
|
|
118
122
|
|
|
123
|
+
if (skipJsonParse) {
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
119
127
|
return parseJsonIfNeeded(result);
|
|
120
128
|
} catch (error) {
|
|
121
129
|
throwNativeStorageError(
|
|
@@ -33,11 +33,16 @@ export interface MultiSelectProvider {
|
|
|
33
33
|
|
|
34
34
|
export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
35
35
|
// TODO: Unsubscribe and remove when there is no listeners
|
|
36
|
-
private static multiSelectProviders: Record<
|
|
36
|
+
private static multiSelectProviders: Record<
|
|
37
|
+
string,
|
|
38
|
+
StorageMultiSelectProvider
|
|
39
|
+
> = {};
|
|
37
40
|
|
|
38
|
-
public static getProvider(keyNamespace:string): StorageMultiSelectProvider {
|
|
41
|
+
public static getProvider(keyNamespace: string): StorageMultiSelectProvider {
|
|
39
42
|
if (!this.multiSelectProviders[keyNamespace]) {
|
|
40
|
-
this.multiSelectProviders[keyNamespace] = new StorageMultiSelectProvider(
|
|
43
|
+
this.multiSelectProviders[keyNamespace] = new StorageMultiSelectProvider(
|
|
44
|
+
keyNamespace
|
|
45
|
+
);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
return this.multiSelectProviders[keyNamespace];
|
|
@@ -45,8 +50,8 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
45
50
|
|
|
46
51
|
private itemSubject: BehaviorSubject<string[] | null>;
|
|
47
52
|
|
|
48
|
-
private readonly key:string
|
|
49
|
-
private readonly namespace:string;
|
|
53
|
+
private readonly key: string;
|
|
54
|
+
private readonly namespace: string;
|
|
50
55
|
|
|
51
56
|
private constructor(keyNamespace: string) {
|
|
52
57
|
const { namespace, key } = getNamespaceAndKey(keyNamespace);
|
|
@@ -65,10 +70,13 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
65
70
|
log_debug("StorageMultiSelectProvider: Initializing");
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
private reloadItems = async ({ value }:StorageListenerArgs) => {
|
|
73
|
+
private reloadItems = async ({ value }: StorageListenerArgs) => {
|
|
69
74
|
const selectedItems = value ? value.split(",") : [];
|
|
70
75
|
|
|
71
|
-
log_debug(
|
|
76
|
+
log_debug(
|
|
77
|
+
`reloadItems: request to reload items for value: ${value}`,
|
|
78
|
+
selectedItems
|
|
79
|
+
);
|
|
72
80
|
|
|
73
81
|
this.itemSubject.next(selectedItems);
|
|
74
82
|
};
|
|
@@ -76,7 +84,10 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
76
84
|
public getObservable = (): BehaviorSubject<string[]> => this.itemSubject;
|
|
77
85
|
|
|
78
86
|
private async getSetOfCurrentItems() {
|
|
79
|
-
const currentResult: string = await localStorage.getItem(
|
|
87
|
+
const currentResult: string = await localStorage.getItem(
|
|
88
|
+
this.key,
|
|
89
|
+
this.namespace
|
|
90
|
+
);
|
|
80
91
|
|
|
81
92
|
return new Set(currentResult ? currentResult.split(",") : []);
|
|
82
93
|
}
|
|
@@ -89,49 +100,61 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
89
100
|
this.itemSubject.next(arrayOfItems);
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
public addItem = async(item: string): Promise<void> => {
|
|
103
|
+
public addItem = async (item: string): Promise<void> => {
|
|
93
104
|
const currentItems = await this.getSetOfCurrentItems();
|
|
94
105
|
currentItems.add(item);
|
|
95
106
|
log_debug(`addItem: Adding new item: ${item}`);
|
|
96
107
|
|
|
97
108
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
98
|
-
}
|
|
109
|
+
};
|
|
99
110
|
|
|
100
|
-
public addItems = async(items: string[]): Promise<void> => {
|
|
111
|
+
public addItems = async (items: string[]): Promise<void> => {
|
|
101
112
|
const currentItems = await this.getSetOfCurrentItems();
|
|
102
113
|
|
|
103
114
|
items.forEach((item) => currentItems.add(item));
|
|
104
115
|
|
|
105
|
-
log_debug(
|
|
116
|
+
log_debug(
|
|
117
|
+
`addItems: Adding new items: ${items.join(
|
|
118
|
+
","
|
|
119
|
+
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
120
|
+
);
|
|
106
121
|
|
|
107
122
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
108
|
-
}
|
|
123
|
+
};
|
|
109
124
|
|
|
110
|
-
public removeItem = async(item: string): Promise<void> => {
|
|
125
|
+
public removeItem = async (item: string): Promise<void> => {
|
|
111
126
|
const currentItems = await this.getSetOfCurrentItems();
|
|
112
127
|
currentItems.delete(item);
|
|
113
128
|
|
|
114
|
-
log_debug(
|
|
129
|
+
log_debug(
|
|
130
|
+
`removeItem: Removing item: ${item}, current items: ${Array.from(
|
|
131
|
+
currentItems
|
|
132
|
+
).join(",")}`
|
|
133
|
+
);
|
|
115
134
|
|
|
116
135
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
117
|
-
}
|
|
136
|
+
};
|
|
118
137
|
|
|
119
138
|
public removeItems = async (items: string[]): Promise<void> => {
|
|
120
139
|
const currentItems = await this.getSetOfCurrentItems();
|
|
121
140
|
|
|
122
141
|
items.forEach((item) => currentItems.delete(item));
|
|
123
142
|
|
|
124
|
-
log_debug(
|
|
143
|
+
log_debug(
|
|
144
|
+
`removeItems: Removing items: ${items.join(
|
|
145
|
+
","
|
|
146
|
+
)}, current items: ${Array.from(currentItems).join(",")}`
|
|
147
|
+
);
|
|
125
148
|
|
|
126
149
|
await this.updateItemsAndNotifyObservers(currentItems);
|
|
127
|
-
}
|
|
150
|
+
};
|
|
128
151
|
|
|
129
152
|
public removeAllItems = async (): Promise<void> => {
|
|
130
153
|
await localStorage.removeItem(this.key, this.namespace);
|
|
131
154
|
log_debug(`removeAllItems: Removing all items, current items: ${[]}`);
|
|
132
155
|
|
|
133
156
|
this.itemSubject.next([]);
|
|
134
|
-
}
|
|
157
|
+
};
|
|
135
158
|
|
|
136
159
|
public getSelectedAsync = async (): Promise<string[]> => {
|
|
137
160
|
const value = await localStorage.getItem(this.key, this.namespace);
|
|
@@ -139,15 +162,15 @@ export class StorageMultiSelectProvider implements MultiSelectProvider {
|
|
|
139
162
|
this.itemSubject.next(selectedItems);
|
|
140
163
|
|
|
141
164
|
return selectedItems;
|
|
142
|
-
}
|
|
165
|
+
};
|
|
143
166
|
|
|
144
167
|
public getSelectedItems = (): string[] => {
|
|
145
168
|
return this.itemSubject.getValue();
|
|
146
|
-
}
|
|
169
|
+
};
|
|
147
170
|
|
|
148
171
|
setSelectedItems = async (items: string[]): Promise<void> => {
|
|
149
172
|
log_debug(`setSelectedItems: Setting selected items: ${items.join(",")}`);
|
|
150
173
|
|
|
151
174
|
await this.updateItemsAndNotifyObservers(new Set(items));
|
|
152
|
-
}
|
|
175
|
+
};
|
|
153
176
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`localStorage
|
|
3
|
+
exports[`localStorage getAllItems throws if an error happen on native side 1`] = `"An error occured while getting an item from native storage: namespace not found"`;
|
|
4
4
|
|
|
5
|
-
exports[`localStorage
|
|
5
|
+
exports[`localStorage getItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
6
6
|
|
|
7
|
-
exports[`localStorage
|
|
7
|
+
exports[`localStorage getItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
8
8
|
|
|
9
|
-
exports[`localStorage
|
|
9
|
+
exports[`localStorage getItem throws if there is an error on the native side 1`] = `"An error occured while getting an item from native storage: failed to get item"`;
|
|
10
10
|
|
|
11
|
-
exports[`localStorage
|
|
11
|
+
exports[`localStorage removeItem throws if a native error is thrown 1`] = `"An error occured while removing an item from native storage: failed to remove item"`;
|
|
12
12
|
|
|
13
|
-
exports[`localStorage
|
|
13
|
+
exports[`localStorage removeItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
14
14
|
|
|
15
|
-
exports[`localStorage
|
|
15
|
+
exports[`localStorage removeItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
16
16
|
|
|
17
|
-
exports[`localStorage
|
|
17
|
+
exports[`localStorage setItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
18
18
|
|
|
19
|
-
exports[`localStorage
|
|
19
|
+
exports[`localStorage setItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
20
20
|
|
|
21
|
-
exports[`localStorage
|
|
21
|
+
exports[`localStorage setItem throws if there is an error in the native module 1`] = `"An error occured while setting an item in native storage: failed to set item"`;
|
|
22
22
|
|
|
23
|
-
exports[`localStorage
|
|
23
|
+
exports[`localStorage setItem throws if value is null 1`] = `"Value to set in storage cannot be null or undefined"`;
|
|
24
24
|
|
|
25
|
-
exports[`localStorage
|
|
25
|
+
exports[`localStorage setItem throws if value is undefined 1`] = `"Value to set in storage cannot be null or undefined"`;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`sessionStorage
|
|
3
|
+
exports[`sessionStorage getAllItems throws if an error happen on native side 1`] = `"An error occured while getting an item from native storage: namespace not found"`;
|
|
4
4
|
|
|
5
|
-
exports[`sessionStorage
|
|
5
|
+
exports[`sessionStorage getItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
6
6
|
|
|
7
|
-
exports[`sessionStorage
|
|
7
|
+
exports[`sessionStorage getItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
8
8
|
|
|
9
|
-
exports[`sessionStorage
|
|
9
|
+
exports[`sessionStorage getItem throws if there is an error on the native side 1`] = `"An error occured while getting an item from native storage: failed to get item"`;
|
|
10
10
|
|
|
11
|
-
exports[`sessionStorage
|
|
11
|
+
exports[`sessionStorage removeItem throws if a native error is thrown 1`] = `"An error occured while removing an item from native storage: failed to remove item"`;
|
|
12
12
|
|
|
13
|
-
exports[`sessionStorage
|
|
13
|
+
exports[`sessionStorage removeItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
14
14
|
|
|
15
|
-
exports[`sessionStorage
|
|
15
|
+
exports[`sessionStorage removeItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
16
16
|
|
|
17
|
-
exports[`sessionStorage
|
|
17
|
+
exports[`sessionStorage setItem throws if key is null 1`] = `"Requested key is null or undefined"`;
|
|
18
18
|
|
|
19
|
-
exports[`sessionStorage
|
|
19
|
+
exports[`sessionStorage setItem throws if key is undefined 1`] = `"Requested key is null or undefined"`;
|
|
20
20
|
|
|
21
|
-
exports[`sessionStorage
|
|
21
|
+
exports[`sessionStorage setItem throws if there is an error in the native module 1`] = `"An error occured while setting an item in native storage: failed to set item"`;
|
|
22
22
|
|
|
23
|
-
exports[`sessionStorage
|
|
23
|
+
exports[`sessionStorage setItem throws if value is null 1`] = `"Value to set in storage cannot be null or undefined"`;
|
|
24
24
|
|
|
25
|
-
exports[`sessionStorage
|
|
25
|
+
exports[`sessionStorage setItem throws if value is undefined 1`] = `"Value to set in storage cannot be null or undefined"`;
|