@fluid-topics/ft-reader-context 1.3.13 → 1.3.14
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/build/ft-reader-context.js +9 -11
- package/build/ft-reader-context.light.js +3 -3
- package/build/ft-reader-context.min.js +10 -10
- package/build/store/FtReaderStateManager.d.ts +6 -1
- package/build/store/FtReaderStateManager.js +17 -8
- package/build/store/utils/FtReaderService.d.ts +1 -1
- package/build/store/utils/FtReaderService.js +12 -12
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FtReaderPage, FtReaderScrollTarget, FtReaderTocNode } from "./model";
|
|
2
|
-
import { ClusteringHelper } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { ClusteringHelper, Optional } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtReaderReduxStore } from "./redux";
|
|
4
4
|
import type { FtReaderService } from "./utils/FtReaderService";
|
|
5
5
|
import { FtTranslationLocale, FtTranslationSettings } from "@fluid-topics/public-api";
|
|
@@ -28,6 +28,11 @@ export declare class FtReaderStateManager {
|
|
|
28
28
|
clear(): void;
|
|
29
29
|
reload(): Promise<void>;
|
|
30
30
|
private fetchData;
|
|
31
|
+
private loadConfiguration;
|
|
32
|
+
reloadConfiguration(): Promise<{
|
|
33
|
+
payload: Optional<import("@fluid-topics/public-api").FtReaderConfiguration>;
|
|
34
|
+
type: `${string}/configuration`;
|
|
35
|
+
}> | undefined;
|
|
31
36
|
private fetchRelatives;
|
|
32
37
|
private updateClusteringHelper;
|
|
33
38
|
private createClusteringHelper;
|
|
@@ -105,7 +105,7 @@ export class FtReaderStateManager {
|
|
|
105
105
|
return this.load();
|
|
106
106
|
}
|
|
107
107
|
async fetchData(translationSettings) {
|
|
108
|
-
var _a, _b, _c, _d, _e
|
|
108
|
+
var _a, _b, _c, _d, _e;
|
|
109
109
|
try {
|
|
110
110
|
if (translationSettings) {
|
|
111
111
|
this.setTranslationLoading(true);
|
|
@@ -117,12 +117,12 @@ export class FtReaderStateManager {
|
|
|
117
117
|
throw e;
|
|
118
118
|
};
|
|
119
119
|
await Promise.all([
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
(
|
|
123
|
-
(
|
|
124
|
-
(
|
|
125
|
-
(
|
|
120
|
+
this.loadConfiguration(),
|
|
121
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getMap(translationSettings).then((map) => this.store.actions.map(map)).catch(handleTranslationError),
|
|
122
|
+
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getToc(translationSettings).then((toc) => this.store.actions.toc(toc)).catch(handleTranslationError),
|
|
123
|
+
(_c = this.service) === null || _c === void 0 ? void 0 : _c.getPagesToc(translationSettings).then((pagesToc) => this.store.actions.pagesToc(pagesToc)).catch(handleTranslationError),
|
|
124
|
+
(_d = this.service) === null || _d === void 0 ? void 0 : _d.getPaginationConfiguration().then((conf) => this.store.actions.paginationConfiguration(conf)).catch(handleTranslationError),
|
|
125
|
+
(_e = this.service) === null || _e === void 0 ? void 0 : _e.getTranslationError(translationSettings).then((translationError) => this.setTranslationError(translationError)),
|
|
126
126
|
]);
|
|
127
127
|
if (this.metadataForSwitchToRelatives.size > 0) {
|
|
128
128
|
this.fetchRelatives();
|
|
@@ -138,6 +138,15 @@ export class FtReaderStateManager {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
loadConfiguration() {
|
|
142
|
+
var _a;
|
|
143
|
+
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getConfiguration().then((conf) => this.store.actions.configuration(conf));
|
|
144
|
+
}
|
|
145
|
+
reloadConfiguration() {
|
|
146
|
+
var _a;
|
|
147
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.clearConfiguration();
|
|
148
|
+
return this.loadConfiguration();
|
|
149
|
+
}
|
|
141
150
|
fetchRelatives() {
|
|
142
151
|
var _a, _b;
|
|
143
152
|
const relativeMetadataValues = (_a = this.store.getState().map) === null || _a === void 0 ? void 0 : _a.metadata.filter((metadata) => { var _a; return metadata.key == ((_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.relativePivotMetadata); }).flatMap((metadata) => metadata.values);
|
|
@@ -252,7 +261,7 @@ export class FtReaderStateManager {
|
|
|
252
261
|
var _a, _b;
|
|
253
262
|
const translationSettings = this.getTranslationSettings();
|
|
254
263
|
if (translationSettings) {
|
|
255
|
-
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTranslatedTopicContent(tocNode, translationSettings).then(translationContent => {
|
|
264
|
+
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTranslatedTopicContent(tocNode, translationSettings).then((translationContent) => {
|
|
256
265
|
if (translationContent.isTranslationError) {
|
|
257
266
|
this.setTranslationError(true);
|
|
258
267
|
}
|
|
@@ -34,6 +34,7 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
34
34
|
getMap(translationSettings?: FtTranslationSettings): Promise<FtMap>;
|
|
35
35
|
getMapNow(translationSettings?: FtTranslationSettings): FtMap | undefined;
|
|
36
36
|
getConfiguration(): Promise<FtReaderConfiguration>;
|
|
37
|
+
clearConfiguration(): void;
|
|
37
38
|
private getEnrichedToc;
|
|
38
39
|
private getEnrichedTocNow;
|
|
39
40
|
getPaginationConfiguration(): Promise<FtPaginationConfiguration>;
|
|
@@ -72,5 +73,4 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
|
|
|
72
73
|
buildBreadcrumb(tocId: string, translationInput?: FtTranslationSettings): Array<FtReaderBreadcrumb>;
|
|
73
74
|
isFeatureAccessible(feature: FtReaderFeatures, { session }: FtReaderFeatureAccessData): boolean;
|
|
74
75
|
makeAbsolute(endpoint: string): string;
|
|
75
|
-
reloadConfiguration(): void;
|
|
76
76
|
}
|
|
@@ -21,17 +21,17 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
21
21
|
return this._mapId ? provider(this._mapId) : undefined;
|
|
22
22
|
}
|
|
23
23
|
initCache() {
|
|
24
|
-
this.cache.
|
|
25
|
-
this.cache.register("map", () => this.withMapId(mapId => this.fetchMap(mapId)));
|
|
26
|
-
this.cache.register("enrichedToc", () => this.withMapId(mapId => this.fetchPages(mapId).then(toc => this.converter.convertPaginatedToc(mapId, toc))));
|
|
24
|
+
this.cache.register("configuration", () => this.api.getReaderConfiguration());
|
|
25
|
+
this.cache.register("map", () => this.withMapId((mapId) => this.fetchMap(mapId)));
|
|
26
|
+
this.cache.register("enrichedToc", () => this.withMapId((mapId) => this.fetchPages(mapId).then((toc) => this.converter.convertPaginatedToc(mapId, toc))));
|
|
27
27
|
this.cache.register("ratingSummary", () => {
|
|
28
28
|
var _a, _b;
|
|
29
29
|
const userHaveRatingRole = userHasRole((_b = (_a = ftAppInfoStore.getState().session) === null || _a === void 0 ? void 0 : _a.profile.roles) !== null && _b !== void 0 ? _b : [], "RATING_USER");
|
|
30
|
-
return userHaveRatingRole ? this.withMapId(mapId => this.fetchMapRating(mapId)) : Promise.resolve();
|
|
30
|
+
return userHaveRatingRole ? this.withMapId((mapId) => this.fetchMapRating(mapId)) : Promise.resolve();
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
clear() {
|
|
34
|
-
this.cache.
|
|
34
|
+
this.cache.clearMatching((key) => key !== "configuration");
|
|
35
35
|
}
|
|
36
36
|
makeCacheKey(base, translationSettings) {
|
|
37
37
|
return base + (translationSettings ? "-destinationLanguage-" + (translationSettings === null || translationSettings === void 0 ? void 0 : translationSettings.destinationLanguage) : "");
|
|
@@ -45,8 +45,11 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
45
45
|
getConfiguration() {
|
|
46
46
|
return this.cache.get("configuration");
|
|
47
47
|
}
|
|
48
|
+
clearConfiguration() {
|
|
49
|
+
this.cache.clear("configuration");
|
|
50
|
+
}
|
|
48
51
|
getEnrichedToc(translationSettings) {
|
|
49
|
-
return this.cache.get(this.makeCacheKey("enrichedToc", translationSettings), () => this.fetchPages(this.mapId, translationSettings).then(toc => this.converter.convertPaginatedToc(this.mapId, toc)));
|
|
52
|
+
return this.cache.get(this.makeCacheKey("enrichedToc", translationSettings), () => this.fetchPages(this.mapId, translationSettings).then((toc) => this.converter.convertPaginatedToc(this.mapId, toc)));
|
|
50
53
|
}
|
|
51
54
|
getEnrichedTocNow(translationSettings) {
|
|
52
55
|
return this.cache.getNow(this.makeCacheKey("enrichedToc", translationSettings));
|
|
@@ -160,14 +163,14 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
160
163
|
return this.getRatingSummary();
|
|
161
164
|
}
|
|
162
165
|
getMapRating() {
|
|
163
|
-
return this.getRatingSummary().then(rm => rm === null || rm === void 0 ? void 0 : rm.publication);
|
|
166
|
+
return this.getRatingSummary().then((rm) => rm === null || rm === void 0 ? void 0 : rm.publication);
|
|
164
167
|
}
|
|
165
168
|
getTopicRating(tocId) {
|
|
166
|
-
return this.getRatingSummary().then(rm => {
|
|
169
|
+
return this.getRatingSummary().then((rm) => {
|
|
167
170
|
var _a;
|
|
168
171
|
return rm ? {
|
|
169
172
|
type: rm.topics.type,
|
|
170
|
-
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find(t => t.tocId === tocId),
|
|
173
|
+
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find((t) => t.tocId === tocId),
|
|
171
174
|
} : undefined;
|
|
172
175
|
});
|
|
173
176
|
}
|
|
@@ -236,7 +239,4 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
236
239
|
makeAbsolute(endpoint) {
|
|
237
240
|
return this.api.makeAbsolute(endpoint);
|
|
238
241
|
}
|
|
239
|
-
reloadConfiguration() {
|
|
240
|
-
this.cache.registerFinal("configuration", () => this.api.getReaderConfiguration());
|
|
241
|
-
}
|
|
242
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"description": "Context block for integrated reader components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.3.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.3.14",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.14",
|
|
24
24
|
"@reduxjs/toolkit": "^1.6.2",
|
|
25
25
|
"lit": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@fluid-topics/public-api": "1.0.100"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "18f0f8e7a68ec235ee6838c4f86002821393322e"
|
|
31
31
|
}
|