@threekit-tools/treble 0.0.74 → 0.0.75
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,4 +1,4 @@
|
|
|
1
|
-
import { CachedProduct } from '../../store/product';
|
|
1
|
+
import { CachedProduct, LoadProductConfig } from '../../store/product';
|
|
2
2
|
import { IReloadConfig } from '../../store/treble';
|
|
3
3
|
interface HydratedCacheProduct extends Pick<CachedProduct, 'name' | 'label' | 'thumbnail'> {
|
|
4
4
|
selected: boolean;
|
|
@@ -8,7 +8,7 @@ interface HydratedCacheProduct extends Pick<CachedProduct, 'name' | 'label' | 't
|
|
|
8
8
|
interface ISelectableProduct {
|
|
9
9
|
id: string;
|
|
10
10
|
label: string;
|
|
11
|
-
handleSelect: () => void;
|
|
11
|
+
handleSelect: (config?: LoadProductConfig) => void;
|
|
12
12
|
}
|
|
13
13
|
interface CacheData {
|
|
14
14
|
cache: Array<HydratedCacheProduct>;
|
|
@@ -21,7 +21,9 @@ var useProductCache = function () {
|
|
|
21
21
|
var products = Object.keys(product_1.PRODUCTS).map(function (prod) { return ({
|
|
22
22
|
id: prod,
|
|
23
23
|
label: prod,
|
|
24
|
-
handleSelect: function () {
|
|
24
|
+
handleSelect: function (config) {
|
|
25
|
+
return dispatch((0, product_1.loadProduct)(prod, config));
|
|
26
|
+
},
|
|
25
27
|
}); });
|
|
26
28
|
return [{ cache: hydratedCache, products: products }, handleLoadNewProduct];
|
|
27
29
|
};
|
package/dist/store/product.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export interface CachedProduct {
|
|
|
13
13
|
connection: IConnectionConfig;
|
|
14
14
|
configuration: IConfiguration;
|
|
15
15
|
}
|
|
16
|
+
export interface LoadProductConfig {
|
|
17
|
+
cacheProduct: boolean;
|
|
18
|
+
}
|
|
16
19
|
export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
|
|
17
20
|
data: string;
|
|
18
21
|
}
|
|
@@ -60,7 +63,7 @@ export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" |
|
|
|
60
63
|
payload: CachedProductState;
|
|
61
64
|
type: string;
|
|
62
65
|
};
|
|
63
|
-
export declare const loadProduct: (id: string) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
|
+
export declare const loadProduct: (id: string, config?: LoadProductConfig | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
64
67
|
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
65
68
|
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
69
|
export declare const removeProductIdx: (idx?: number | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
package/dist/store/product.js
CHANGED
|
@@ -193,25 +193,25 @@ var cacheActiveProduct = function (config) {
|
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
exports.cacheActiveProduct = cacheActiveProduct;
|
|
196
|
-
var loadProduct = function (id) {
|
|
196
|
+
var loadProduct = function (id, config) {
|
|
197
197
|
return function (dispatch, getState) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
-
var state, productsList,
|
|
198
|
+
var cacheProduct, state, productsList, productConfig;
|
|
199
199
|
return __generator(this, function (_a) {
|
|
200
200
|
switch (_a.label) {
|
|
201
201
|
case 0:
|
|
202
|
+
cacheProduct = (config || { cacheProduct: true }).cacheProduct;
|
|
202
203
|
state = getState();
|
|
203
204
|
productsList = Object.keys(exports.PRODUCTS);
|
|
204
|
-
shouldCacheProduct = true;
|
|
205
205
|
if (!productsList.includes(id))
|
|
206
206
|
return [2 /*return*/];
|
|
207
207
|
productConfig = exports.PRODUCTS[id][state.treble.threekitEnv];
|
|
208
208
|
dispatch((0, exports.setProductId)(id));
|
|
209
|
-
if (
|
|
209
|
+
if (cacheProduct)
|
|
210
210
|
dispatch((0, exports.cacheActiveProduct)());
|
|
211
211
|
return [4 /*yield*/, dispatch((0, treble_1.reloadPlayer)(productConfig))];
|
|
212
212
|
case 1:
|
|
213
213
|
_a.sent();
|
|
214
|
-
if (
|
|
214
|
+
if (cacheProduct) {
|
|
215
215
|
dispatch((0, exports.incrementActiveCacheIdx)());
|
|
216
216
|
dispatch((0, exports.cacheActiveProduct)());
|
|
217
217
|
}
|