@fluid-topics/ft-viewer 2.2.15 → 2.2.17

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.
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { applyMixinOnce, hasChanged, } from "@fluid-topics/ft-wc-utils";
8
8
  import { state } from "lit/decorators.js";
9
9
  import { consume, createContext, } from "@lit/context";
10
- export const udViewerStateManagerContext = createContext(Symbol("ud-viewer-state-manager"));
10
+ export const udViewerStateManagerContext = createContext("ud-viewer-state-manager");
11
11
  export const toFtUdViewerComponent = applyMixinOnce(Symbol("toFtUdViewerComponent"), function (ReduxClass) {
12
12
  class FtUdViewerComponentClass extends ReduxClass {
13
13
  constructor() {
@@ -7,7 +7,7 @@ export declare class FtUdViewerContext extends FtLitElementRedux implements FtUd
7
7
  viewerStateManager: FtUdViewerStateManager;
8
8
  protected render(): import("lit-html").TemplateResult<1>;
9
9
  protected willUpdate(props: PropertyValues<FtUdViewerContext>): void;
10
- private initStateManager;
10
+ load(): Promise<void>;
11
11
  connectedCallback(): void;
12
12
  onAuthenticationChange(): void;
13
13
  private reactToUiLocaleChanged;
@@ -25,10 +25,10 @@ export class FtUdViewerContext extends FtLitElementRedux {
25
25
  willUpdate(props) {
26
26
  super.willUpdate(props);
27
27
  if (props.has("documentId")) {
28
- this.initStateManager();
28
+ this.load();
29
29
  }
30
30
  }
31
- async initStateManager() {
31
+ async load() {
32
32
  try {
33
33
  const state = await this.viewerStateManager.setDocumentId(this.documentId);
34
34
  if (this.documentId) {
@@ -42,6 +42,7 @@ export class FtUdViewerContext extends FtLitElementRedux {
42
42
  connectedCallback() {
43
43
  super.connectedCallback();
44
44
  this.addStore(ftAppInfoStore);
45
+ this.load();
45
46
  }
46
47
  onAuthenticationChange() {
47
48
  this.viewerStateManager.reload();
@@ -13,7 +13,6 @@ export declare class FtUdViewerService extends FtServiceWithCache {
13
13
  sendDocumentFeedback(documentId: string, message: string, from?: string): Promise<void>;
14
14
  isFeatureAccessible(feature: FtViewerFeatures, { session }: FtViewerFeatureAccessData): boolean;
15
15
  getConfiguration(): Promise<FtViewerConfiguration>;
16
- clearConfiguration(): void;
17
16
  private fetchRelativesForDocument;
18
17
  getRelativesForDocument(metadataPivotKey: string, metadataPivotValues: string[]): Promise<FtSearchResults>;
19
18
  }
@@ -42,9 +42,6 @@ export class FtUdViewerService extends FtServiceWithCache {
42
42
  getConfiguration() {
43
43
  return this.cache.get("configuration", () => this.api.getViewerConfiguration());
44
44
  }
45
- clearConfiguration() {
46
- this.cache.clear("configuration");
47
- }
48
45
  fetchRelativesForDocument(metadataPivotKey, metadataPivotValues) {
49
46
  const request = {
50
47
  query: "",
@@ -2,16 +2,16 @@ import { FtViewerFileOrigin } from "../../common/model/ft-viewer.models";
2
2
  import { createViewerStore, } from "../../common/model/FtViewerReduxStore";
3
3
  import { FtViewerStateManager } from "../../common/model/FtViewerStateManager";
4
4
  import { FtUdViewerService } from "./FtUdViewerService";
5
- import { FtAssetHolderType } from "@fluid-topics/public-api";
6
- import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
7
- import { accessResultId, accessResultUrl, ClusteringHelper } from "@fluid-topics/ft-wc-utils";
5
+ import { FtAssetHolderType, } from "@fluid-topics/public-api";
6
+ import { ftAppInfoStore, ftAppStateManager, } from "@fluid-topics/ft-app-context";
7
+ import { accessResultId, accessResultUrl, ClusteringHelper, } from "@fluid-topics/ft-wc-utils";
8
8
  import { FtUdViewerStoreEvents } from "./ft-ud-viewer.models";
9
9
  export class FtUdViewerStateManager extends FtViewerStateManager {
10
10
  static build(viewerId) {
11
11
  return new FtUdViewerStateManager(createViewerStore(viewerId), new FtUdViewerService());
12
12
  }
13
13
  constructor(store, service, clusteringHelperProvider) {
14
- super(store);
14
+ super(store, service);
15
15
  this.store = store;
16
16
  this.service = service;
17
17
  this.clusteringHelperProvider = clusteringHelperProvider;
@@ -59,7 +59,7 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
59
59
  async fetchMapRating() {
60
60
  var _a;
61
61
  const { documentId } = this.store.getState();
62
- if (documentId) {
62
+ if (documentId && ftAppStateManager.userHasAnyRole("RATING_USER")) {
63
63
  this.store.actions.documentRating(await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getDocumentRating(documentId)));
64
64
  }
65
65
  }
@@ -67,9 +67,7 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
67
67
  this.store.clearKeeping("documentId", "origin");
68
68
  }
69
69
  reload() {
70
- var _a;
71
70
  this.clear();
72
- (_a = this.service) === null || _a === void 0 ? void 0 : _a.clearConfiguration();
73
71
  return this.load();
74
72
  }
75
73
  setDocumentId(documentId) {
@@ -81,10 +79,11 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
81
79
  return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getConfiguration().then((conf) => this.store.actions.configuration(conf));
82
80
  }
83
81
  async fetchRelatives() {
84
- var _a, _b;
85
- const relativeMetadataValues = (_a = this.store.getState().document) === 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);
82
+ var _a;
83
+ const { document, configuration } = this.store.getState();
84
+ const relativeMetadataValues = document === null || document === void 0 ? void 0 : document.metadata.filter((metadata) => metadata.key == (configuration === null || configuration === void 0 ? void 0 : configuration.relativePivotMetadata)).flatMap((metadata) => metadata.values);
86
85
  if (relativeMetadataValues !== undefined && relativeMetadataValues.length > 0) {
87
- const searchResults = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getRelativesForDocument(this.store.getState().configuration.relativePivotMetadata, relativeMetadataValues));
86
+ const searchResults = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getRelativesForDocument(configuration.relativePivotMetadata, relativeMetadataValues));
88
87
  const relatives = searchResults === null || searchResults === void 0 ? void 0 : searchResults.results.flatMap((result) => result.entries);
89
88
  this.store.actions.relatives(relatives);
90
89
  }
@@ -101,9 +100,9 @@ export class FtUdViewerStateManager extends FtViewerStateManager {
101
100
  if (this.clusteringHelperProvider) {
102
101
  return this.clusteringHelperProvider();
103
102
  }
104
- const relatives = this.store.getState().relatives;
103
+ const { relatives, documentId } = this.store.getState();
105
104
  if (relatives) {
106
- const selectedResult = relatives.find((relative) => accessResultId(relative) == this.store.getState().documentId);
105
+ const selectedResult = relatives.find((relative) => accessResultId(relative) == documentId);
107
106
  const metadataDescriptors = (_b = (_a = ftAppInfoStore.getState().metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : [];
108
107
  return new ClusteringHelper(relatives, selectedResult, this.metadataForSwitchToRelatives, metadataDescriptors);
109
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-viewer",
3
- "version": "2.2.15",
3
+ "version": "2.2.17",
4
4
  "description": "File viewer components",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,18 +19,18 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-content-watermark": "2.2.15",
23
- "@fluid-topics/ft-i18n": "2.2.15",
24
- "@fluid-topics/ft-reader-attachments": "2.2.15",
25
- "@fluid-topics/ft-reader-feedback": "2.2.15",
26
- "@fluid-topics/ft-search-result-context": "2.2.15",
27
- "@fluid-topics/ft-wc-utils": "2.2.15",
28
- "@fluid-topics/public-api": "1.0.141",
22
+ "@fluid-topics/ft-content-watermark": "2.2.17",
23
+ "@fluid-topics/ft-i18n": "2.2.17",
24
+ "@fluid-topics/ft-reader-attachments": "2.2.17",
25
+ "@fluid-topics/ft-reader-feedback": "2.2.17",
26
+ "@fluid-topics/ft-search-result-context": "2.2.17",
27
+ "@fluid-topics/ft-wc-utils": "2.2.17",
28
+ "@fluid-topics/public-api": "1.0.142",
29
29
  "@lit/context": "1.1.6",
30
30
  "lit": "3.3.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@fluid-topics/ft-wc-test-utils": "2.2.15"
33
+ "@fluid-topics/ft-wc-test-utils": "2.2.17"
34
34
  },
35
- "gitHead": "7fed0188675c448361c4f688602549554f99c045"
35
+ "gitHead": "36907c574a4cfc29bc07e86865cdb5b7e19d3d03"
36
36
  }