@fluid-topics/ft-app-context 1.3.29 → 1.3.30
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.
|
@@ -31,6 +31,22 @@ declare const reducers: {
|
|
|
31
31
|
type: string;
|
|
32
32
|
}) => void;
|
|
33
33
|
clearBookmarkCountByMap: (state: FtUserAssetsState) => void;
|
|
34
|
+
addAsset: (state: FtUserAssetsState, action: {
|
|
35
|
+
payload: {
|
|
36
|
+
assetType: FtUserAssetType;
|
|
37
|
+
asset: FtBookmark | FtMySearch;
|
|
38
|
+
mapId?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
type: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
removeAsset: (state: FtUserAssetsState, action: {
|
|
43
|
+
payload: {
|
|
44
|
+
assetType: FtUserAssetType;
|
|
45
|
+
assetId: string;
|
|
46
|
+
mapId?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
type: string;
|
|
49
|
+
}) => void;
|
|
34
50
|
};
|
|
35
51
|
export type FtUserAssetsStateReducers = typeof reducers;
|
|
36
52
|
export type FtUserAssetsStore = FtReduxStore<FtUserAssetsState, FtUserAssetsStateReducers>;
|
|
@@ -23,6 +23,59 @@ const reducers = {
|
|
|
23
23
|
clearBookmarkCountByMap: (state) => {
|
|
24
24
|
state.assetCounts.bookmarkByMap = {};
|
|
25
25
|
},
|
|
26
|
+
addAsset: (state, action) => {
|
|
27
|
+
const { assetType, mapId, asset } = action.payload;
|
|
28
|
+
switch (assetType) {
|
|
29
|
+
case FtUserAssetType.BOOKMARKS:
|
|
30
|
+
if (state.bookmarks) {
|
|
31
|
+
state.bookmarks.push(asset);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
state.bookmarks = [asset];
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case FtUserAssetType.SEARCHES:
|
|
38
|
+
if (state.savedSearches) {
|
|
39
|
+
state.savedSearches.push(asset);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
state.savedSearches = [asset];
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
const currentCount = state.assetCounts.allAsset[assetType];
|
|
47
|
+
if (currentCount !== undefined) {
|
|
48
|
+
state.assetCounts.allAsset[assetType] = currentCount + 1;
|
|
49
|
+
}
|
|
50
|
+
if (assetType === FtUserAssetType.BOOKMARKS && mapId !== undefined) {
|
|
51
|
+
const currentMapCount = state.assetCounts.bookmarkByMap[mapId];
|
|
52
|
+
if (currentMapCount !== undefined) {
|
|
53
|
+
state.assetCounts.bookmarkByMap[mapId] = currentMapCount + 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
removeAsset: (state, action) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const { assetType, mapId, assetId } = action.payload;
|
|
60
|
+
switch (assetType) {
|
|
61
|
+
case FtUserAssetType.BOOKMARKS:
|
|
62
|
+
state.bookmarks = (_a = state.bookmarks) === null || _a === void 0 ? void 0 : _a.filter((b) => b.id !== assetId);
|
|
63
|
+
break;
|
|
64
|
+
case FtUserAssetType.SEARCHES:
|
|
65
|
+
state.savedSearches = (_b = state.savedSearches) === null || _b === void 0 ? void 0 : _b.filter((s) => s.id !== assetId);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const currentCount = state.assetCounts.allAsset[assetType];
|
|
69
|
+
if (currentCount !== undefined && currentCount > 0) {
|
|
70
|
+
state.assetCounts.allAsset[assetType] = currentCount - 1;
|
|
71
|
+
}
|
|
72
|
+
if (assetType === FtUserAssetType.BOOKMARKS && mapId !== undefined) {
|
|
73
|
+
const currentMapCount = state.assetCounts.bookmarkByMap[mapId];
|
|
74
|
+
if (currentMapCount !== undefined && currentMapCount > 0) {
|
|
75
|
+
state.assetCounts.bookmarkByMap[mapId] = currentMapCount - 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
26
79
|
};
|
|
27
80
|
export const ftUserAssetsStore = FtReduxStore.get({
|
|
28
81
|
name: FtUserAssetsStoreName,
|
|
@@ -31,7 +84,8 @@ export const ftUserAssetsStore = FtReduxStore.get({
|
|
|
31
84
|
savedSearches: undefined,
|
|
32
85
|
bookmarks: undefined,
|
|
33
86
|
assetCounts: {
|
|
34
|
-
allAsset: Object.fromEntries(Object.values(FtUserAssetType).map((key) => [key, undefined])),
|
|
87
|
+
allAsset: Object.fromEntries(Object.values(FtUserAssetType).map((key) => [key, undefined])),
|
|
88
|
+
bookmarkByMap: {},
|
|
35
89
|
},
|
|
36
90
|
assetLabels: [],
|
|
37
91
|
},
|
|
@@ -83,6 +137,7 @@ export class UserAssetsActions {
|
|
|
83
137
|
this.bookmarksService.clearCache();
|
|
84
138
|
await this.updateBookmarksIfUsed();
|
|
85
139
|
}
|
|
140
|
+
// Also used in GWT
|
|
86
141
|
async reloadAssetLabels() {
|
|
87
142
|
this.assetLabelsService.clearCache();
|
|
88
143
|
const assetLabels = await this.assetLabelsService.getUserAssetLabels();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-app-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.30",
|
|
4
4
|
"description": "Global application context for Fluid Topics integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "1.3.30",
|
|
23
23
|
"lit": "3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@fluid-topics/public-api": "1.0.106"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "af95166a9c177803f6419c75f531a38979a8b202"
|
|
29
29
|
}
|