@fluid-topics/ft-reader-context 2.2.37 → 2.2.39
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.d.ts +1 -0
- package/build/ft-reader-context.js +22 -10
- package/build/ft-reader-context.light.js +10 -9
- package/build/ft-reader-context.min.js +23 -22
- package/build/store/FtReaderStateManager.d.ts +4 -0
- package/build/store/FtReaderStateManager.js +29 -2
- package/build/store/model.d.ts +1 -0
- package/build/store/redux.js +1 -0
- package/build/store/utils/FtOfficialReaderService.d.ts +2 -2
- package/build/store/utils/FtOfficialReaderService.js +5 -5
- package/build/store/utils/FtReaderService.d.ts +13 -4
- package/build/store/utils/FtReaderService.js +24 -8
- package/package.json +6 -6
|
@@ -17,6 +17,7 @@ export declare class FtReaderContext extends FtLitElementRedux implements FtRead
|
|
|
17
17
|
section?: string;
|
|
18
18
|
topicPivot?: string;
|
|
19
19
|
searchInDocumentQuery?: string;
|
|
20
|
+
applyStickyFilters: boolean;
|
|
20
21
|
metadataFilters: Array<FtMetadataFilter>;
|
|
21
22
|
page?: number;
|
|
22
23
|
map?: FtMap;
|
|
@@ -23,6 +23,7 @@ class FluidTopicsReaderServiceImpl {
|
|
|
23
23
|
export class FtReaderContext extends FtLitElementRedux {
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
26
|
+
this.applyStickyFilters = false;
|
|
26
27
|
this.metadataFilters = [];
|
|
27
28
|
this.visibleTopics = [];
|
|
28
29
|
this.updateConfiguration = () => {
|
|
@@ -39,12 +40,15 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
39
40
|
<ft-toc-filtering-search-context
|
|
40
41
|
disableAnalyticsEvents
|
|
41
42
|
registrationId="reader-toc-filtering"
|
|
43
|
+
?applyStickyFilters=${this.applyStickyFilters}
|
|
42
44
|
.filters=${this.filters}
|
|
43
45
|
@ft-search-request-change=${(e) => {
|
|
44
46
|
var _a;
|
|
45
47
|
e.stopPropagation();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const metadataFilter = e.detail.metadataFilters;
|
|
49
|
+
// Empty metadataFilter means the request was built before the mapId was set, and it must not overwrite filters
|
|
50
|
+
if (e.target === this.tocFilteringContext && metadataFilter.length > 0) {
|
|
51
|
+
this.stateManager.setFilters((_a = metadataFilter.filter((m) => m.key != "ft:publicationId")) !== null && _a !== void 0 ? _a : []);
|
|
48
52
|
}
|
|
49
53
|
}}
|
|
50
54
|
@ft-search-results-change=${(e) => e.stopPropagation()}
|
|
@@ -76,7 +80,7 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
76
80
|
return this._stateManager;
|
|
77
81
|
}
|
|
78
82
|
get filters() {
|
|
79
|
-
return [
|
|
83
|
+
return this.mapId ? [
|
|
80
84
|
{
|
|
81
85
|
key: "ft:publicationId",
|
|
82
86
|
valueFilter: {
|
|
@@ -85,7 +89,7 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
85
89
|
},
|
|
86
90
|
},
|
|
87
91
|
...this.metadataFilters,
|
|
88
|
-
];
|
|
92
|
+
] : [];
|
|
89
93
|
}
|
|
90
94
|
connectedCallback() {
|
|
91
95
|
super.connectedCallback();
|
|
@@ -107,6 +111,7 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
107
111
|
super.disconnectedCallback();
|
|
108
112
|
ftAppStateManager.knownContexts.unregister(this);
|
|
109
113
|
ftAppInfoStore.addEventListener(AuthenticationChangeEvent.eventName, this.updateConfiguration);
|
|
114
|
+
this.stateManager.removeListeners();
|
|
110
115
|
}
|
|
111
116
|
update(props) {
|
|
112
117
|
var _a;
|
|
@@ -114,14 +119,16 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
114
119
|
if (props.has("readerServiceProvider") && this.readerServiceProvider) {
|
|
115
120
|
this.stateManager.initService(this.readerServiceProvider);
|
|
116
121
|
}
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// stale pre-change value mid-update() and silently drop the change.
|
|
122
|
+
// Give the new values to the state manager, including at the 1st lit lifecycle (initialization)
|
|
123
|
+
if (props.has("metadataFilters")) {
|
|
124
|
+
// Must run before any store dispatch (setStickyFilters, setMapId...): when metadataFilters is set as a property,
|
|
125
|
+
// a dispatch synchronously re-syncs it from the store, which would overwrite it with the stale
|
|
126
|
+
// store value mid-update() and silently drop the change.
|
|
123
127
|
this.stateManager.setFilters((_a = this.metadataFilters) !== null && _a !== void 0 ? _a : []);
|
|
124
128
|
}
|
|
129
|
+
if (props.has("applyStickyFilters")) {
|
|
130
|
+
this.stateManager.setApplyStickyFilters(this.applyStickyFilters);
|
|
131
|
+
}
|
|
125
132
|
if (props.has("mapId") && this.mapId) {
|
|
126
133
|
this.stateManager.setMapId(this.mapId);
|
|
127
134
|
this.lastNotifiedNotFoundRelative = undefined;
|
|
@@ -129,6 +136,8 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
129
136
|
if (props.has("searchInDocumentQuery") && this.searchInDocumentQuery != null) {
|
|
130
137
|
this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery);
|
|
131
138
|
}
|
|
139
|
+
// The 1st lit lifecycle is not a filter change
|
|
140
|
+
const filtersChanged = this.hasUpdated && props.has("metadataFilters");
|
|
132
141
|
// reload() re-navigates to the current target once the filtered data is loaded,
|
|
133
142
|
// so it must not race with a direct navigateToTarget() call from this same update.
|
|
134
143
|
if (props.has("session")) {
|
|
@@ -268,6 +277,9 @@ __decorate([
|
|
|
268
277
|
__decorate([
|
|
269
278
|
property()
|
|
270
279
|
], FtReaderContext.prototype, "searchInDocumentQuery", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
property({ type: Boolean })
|
|
282
|
+
], FtReaderContext.prototype, "applyStickyFilters", void 0);
|
|
271
283
|
__decorate([
|
|
272
284
|
redux({ store: "reader", converter: jsonPropertyConverter([]), attribute: true })
|
|
273
285
|
], FtReaderContext.prototype, "metadataFilters", void 0);
|