@fluid-topics/ft-reader-context 1.2.49 → 1.2.51

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.
@@ -39,6 +39,8 @@ export declare class FtReaderStateManager {
39
39
  setTranslationLoading(isLoading: boolean): Promise<void>;
40
40
  setTranslationError(isError: boolean): Promise<void>;
41
41
  getTranslationSettings(): FtTranslationSettings | undefined;
42
+ fetchMapRating(): Promise<void>;
43
+ fetchTopicRating(tocId: string): Promise<void>;
42
44
  registerMetadataForSwitchToRelatives(id: string): void;
43
45
  unregisterMetadataForSwitchToRelatives(id: string): void;
44
46
  getAccurateNavigationData(tocId?: string, currentPage?: FtReaderPage, oldScrollTarget?: FtReaderScrollTarget): Promise<import("./model").FtReaderNavigationData>;
@@ -46,4 +48,5 @@ export declare class FtReaderStateManager {
46
48
  fetchTopicContent(tocNode: FtReaderTocNode): Promise<string> | undefined;
47
49
  getTocNode(tocId: string): Promise<FtReaderTocNode>;
48
50
  getPage(targetPageNumber: number): Promise<FtReaderPage>;
51
+ onMapAttachmentsUpdate(): void;
49
52
  }
@@ -1,3 +1,4 @@
1
+ import { FtReaderStoreEvents } from "./model";
1
2
  import { CanceledPromiseError, ClusteringHelper, Debouncer, waitFor, waitUntil } from "@fluid-topics/ft-wc-utils";
2
3
  import { createReaderStore } from "./redux";
3
4
  import { FtOfficialReaderService } from "./utils/FtOfficialReaderService";
@@ -95,6 +96,7 @@ export class FtReaderStateManager {
95
96
  isLoading: false,
96
97
  isError: false
97
98
  });
99
+ this.store.actions.mapRating(undefined);
98
100
  (_a = this.service) === null || _a === void 0 ? void 0 : _a.clear();
99
101
  this.clusteringHelper = undefined;
100
102
  }
@@ -153,7 +155,7 @@ export class FtReaderStateManager {
153
155
  updateClusteringHelper() {
154
156
  this.clusteringHelper = this.createClusteringHelper();
155
157
  if (this.clusteringHelper) {
156
- this.store.dispatchEvent(new CustomEvent("clustering-helper-created"));
158
+ this.store.dispatchEvent(new Event(FtReaderStoreEvents.clusteringHelperCreated));
157
159
  }
158
160
  }
159
161
  createClusteringHelper() {
@@ -215,6 +217,17 @@ export class FtReaderStateManager {
215
217
  sourceLanguage: (_a = state.map) === null || _a === void 0 ? void 0 : _a.lang
216
218
  } : undefined;
217
219
  }
220
+ async fetchMapRating() {
221
+ var _a;
222
+ this.store.actions.mapRating(await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getMapRating()));
223
+ }
224
+ async fetchTopicRating(tocId) {
225
+ var _a;
226
+ const topicRating = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getTopicRating(tocId));
227
+ if (topicRating) {
228
+ this.store.actions.setTopicsRating({ [tocId]: topicRating });
229
+ }
230
+ }
218
231
  registerMetadataForSwitchToRelatives(id) {
219
232
  this.metadataForSwitchToRelatives.add(id);
220
233
  if (this.store.getState().relatives == undefined) {
@@ -258,4 +271,9 @@ export class FtReaderStateManager {
258
271
  var _a;
259
272
  return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getPage(targetPageNumber, this.getTranslationSettings());
260
273
  }
274
+ onMapAttachmentsUpdate() {
275
+ var _a;
276
+ (_a = this.service) === null || _a === void 0 ? void 0 : _a.clearMapAttachments();
277
+ this.store.dispatchEvent(new Event(FtReaderStoreEvents.mapAttachmentsUpdate));
278
+ }
261
279
  }
@@ -1,5 +1,9 @@
1
- import { FtMap, FtPaginationConfiguration, FtRatingType, FtRatingTypeKeys, FtReaderConfiguration, FtSearchResultClusterEntry, FtSession, FtTocNode, FtTopic, FtTopicRating, FtTranslationLocale } from "@fluid-topics/public-api";
1
+ import { FtMap, FtPaginationConfiguration, FtPublicationRatingSummary, FtRatingType, FtRatingTypeKeys, FtReaderConfiguration, FtSearchResultClusterEntry, FtSession, FtTocNode, FtTopic, FtTopicRating, FtTranslationLocale } from "@fluid-topics/public-api";
2
2
  import { Optional } from "@fluid-topics/ft-wc-utils";
3
+ export declare enum FtReaderStoreEvents {
4
+ clusteringHelperCreated = "clustering-helper-created",
5
+ mapAttachmentsUpdate = "map-attachments-update"
6
+ }
3
7
  export interface FtPagesTocNode {
4
8
  depth: number;
5
9
  tocId: string;
@@ -42,6 +46,10 @@ export interface FtReaderState {
42
46
  configuration: Optional<FtReaderConfiguration>;
43
47
  searchInDocumentQuery: Optional<string>;
44
48
  relatives: Optional<Array<FtSearchResultClusterEntry>>;
49
+ mapRating: Optional<FtPublicationRatingSummary>;
50
+ topicsRating: {
51
+ [id: string]: FtTopicRatingSummary;
52
+ };
45
53
  translation: {
46
54
  sourceLanguage: Optional<FtTranslationLocale>;
47
55
  destinationLanguage: Optional<FtTranslationLocale>;
@@ -1,3 +1,8 @@
1
+ export var FtReaderStoreEvents;
2
+ (function (FtReaderStoreEvents) {
3
+ FtReaderStoreEvents["clusteringHelperCreated"] = "clustering-helper-created";
4
+ FtReaderStoreEvents["mapAttachmentsUpdate"] = "map-attachments-update";
5
+ })(FtReaderStoreEvents || (FtReaderStoreEvents = {}));
1
6
  export var FtReaderFeatures;
2
7
  (function (FtReaderFeatures) {
3
8
  FtReaderFeatures["FEEDBACK"] = "FEEDBACK";
@@ -7,6 +7,7 @@ declare const readerStoreStateReducers: {
7
7
  setTranslationProfileId: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["profileId"]>) => void;
8
8
  setTranslationLoading: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["isLoading"]>) => void;
9
9
  setTranslationError: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["isError"]>) => void;
10
+ setTopicsRating: (state: FtReaderState, action: PayloadAction<FtReaderState["topicsRating"]>) => void;
10
11
  };
11
12
  export type FtReaderStateReducers = typeof readerStoreStateReducers;
12
13
  export type FtReaderReduxStore = FtReduxStore<FtReaderState, FtReaderStateReducers>;
@@ -16,5 +17,6 @@ export declare const createReaderStore: (id: string) => FtReduxStore<FtReaderSta
16
17
  setTranslationProfileId: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["profileId"]>) => void;
17
18
  setTranslationLoading: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["isLoading"]>) => void;
18
19
  setTranslationError: (state: FtReaderState, action: PayloadAction<FtReaderState["translation"]["isError"]>) => void;
20
+ setTopicsRating: (state: FtReaderState, action: PayloadAction<FtReaderState["topicsRating"]>) => void;
19
21
  }, import("redux").AnyAction>;
20
22
  export {};
@@ -15,6 +15,11 @@ const readerStoreStateReducers = {
15
15
  setTranslationError: (state, action) => {
16
16
  state.translation.isError = action.payload;
17
17
  },
18
+ setTopicsRating: (state, action) => {
19
+ for (let key in action.payload) {
20
+ state.topicsRating[key] = action.payload[key];
21
+ }
22
+ },
18
23
  };
19
24
  export const createReaderStore = (id) => FtReduxStore.get({
20
25
  name: "ft-reader-" + id,
@@ -31,6 +36,8 @@ export const createReaderStore = (id) => FtReduxStore.get({
31
36
  configuration: undefined,
32
37
  searchInDocumentQuery: undefined,
33
38
  relatives: undefined,
39
+ mapRating: undefined,
40
+ topicsRating: {},
34
41
  translation: {
35
42
  sourceLanguage: undefined,
36
43
  destinationLanguage: undefined,
@@ -49,6 +49,7 @@ export declare abstract class FtReaderService extends FtServiceWithCache {
49
49
  getTopicContent(tocNode: FtTocNode): Promise<string>;
50
50
  getTranslatedTopicContent(tocNode: FtTocNode, translationInput: FtTranslationSettings): Promise<FtTranslationContent>;
51
51
  getAttachments(): Promise<Array<FtMapAttachment>>;
52
+ clearMapAttachments(): void;
52
53
  getRelativesForDocument(metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
53
54
  getRelativesForTopicInMap(mapId: string, metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
54
55
  getAttachmentDownloadLink(id: string): string;
@@ -103,6 +103,9 @@ export class FtReaderService extends FtServiceWithCache {
103
103
  getAttachments() {
104
104
  return this.cache.get("map-attachments", () => this.fetchAttachments());
105
105
  }
106
+ clearMapAttachments() {
107
+ this.cache.clear("map-attachments");
108
+ }
106
109
  getRelativesForDocument(metadataPivotKey, metadataPivotValues) {
107
110
  return this.cache.get("document-relatives-" + metadataPivotKey + "-" + metadataPivotValues.join("-"), () => this.fetchRelativesForDocument(metadataPivotKey, metadataPivotValues));
108
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-context",
3
- "version": "1.2.49",
3
+ "version": "1.2.51",
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.2.49",
23
- "@fluid-topics/ft-wc-utils": "1.2.49",
22
+ "@fluid-topics/ft-app-context": "1.2.51",
23
+ "@fluid-topics/ft-wc-utils": "1.2.51",
24
24
  "@reduxjs/toolkit": "^1.6.2",
25
25
  "lit": "3.1.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@fluid-topics/public-api": "1.0.89"
28
+ "@fluid-topics/public-api": "1.0.90"
29
29
  },
30
- "gitHead": "eac6d1d34424e5f5ca7e20068e646caeba2e15a7"
30
+ "gitHead": "f37803963479545409bdddea3571d34dbad90413"
31
31
  }