1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Switch to using stable values for Threads (#2228)

This commit is contained in:
Germain
2022-03-11 09:04:17 +00:00
committed by GitHub
parent e16e7bc098
commit 9058dbf289
20 changed files with 138 additions and 124 deletions

View File

@@ -15,11 +15,8 @@ limitations under the License.
*/
import { RelationType } from "./@types/event";
import {
UNSTABLE_FILTER_RELATED_BY_REL_TYPES,
UNSTABLE_FILTER_RELATED_BY_SENDERS,
} from "./filter";
import { MatrixEvent } from "./models/event";
import { FILTER_RELATED_BY_REL_TYPES, FILTER_RELATED_BY_SENDERS, THREAD_RELATION_TYPE } from "./models/thread";
/**
* @module filter-component
@@ -51,8 +48,12 @@ export interface IFilterComponent {
not_senders?: string[];
contains_url?: boolean;
limit?: number;
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]?: string[];
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]?: Array<RelationType | string>;
related_by_senders?: Array<RelationType | string>;
related_by_rel_types?: string[];
// Unstable values
"io.element.relation_senders"?: Array<RelationType | string>;
"io.element.relation_types"?: string[];
}
/* eslint-enable camelcase */
@@ -84,7 +85,7 @@ export class FilterComponent {
// of performance
// This should be improved when bundled relationships solve that problem
const relationSenders = [];
if (this.userId && bundledRelationships?.[RelationType.Thread]?.current_user_participated) {
if (this.userId && bundledRelationships?.[THREAD_RELATION_TYPE.name]?.current_user_participated) {
relationSenders.push(this.userId);
}
@@ -103,15 +104,17 @@ export class FilterComponent {
*/
public toJSON(): object {
return {
types: this.filterJson.types || null,
not_types: this.filterJson.not_types || [],
rooms: this.filterJson.rooms || null,
not_rooms: this.filterJson.not_rooms || [],
senders: this.filterJson.senders || null,
not_senders: this.filterJson.not_senders || [],
contains_url: this.filterJson.contains_url || null,
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: UNSTABLE_FILTER_RELATED_BY_SENDERS.findIn(this.filterJson),
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: UNSTABLE_FILTER_RELATED_BY_REL_TYPES.findIn(this.filterJson),
"types": this.filterJson.types || null,
"not_types": this.filterJson.not_types || [],
"rooms": this.filterJson.rooms || null,
"not_rooms": this.filterJson.not_rooms || [],
"senders": this.filterJson.senders || null,
"not_senders": this.filterJson.not_senders || [],
"contains_url": this.filterJson.contains_url || null,
"related_by_senders": this.filterJson.related_by_rel_types || [],
"related_by_rel_types": this.filterJson.related_by_rel_types || [],
"io.element.relation_senders": this.filterJson["io.element.relation_senders"] || [],
"io.element.relation_types": this.filterJson["io.element.relation_types"] || [],
};
}
@@ -165,14 +168,14 @@ export class FilterComponent {
return false;
}
const relationTypesFilter = this.filterJson[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name];
const relationTypesFilter = this.filterJson[FILTER_RELATED_BY_REL_TYPES.name];
if (relationTypesFilter !== undefined) {
if (!this.arrayMatchesFilter(relationTypesFilter, relationTypes)) {
return false;
}
}
const relationSendersFilter = this.filterJson[UNSTABLE_FILTER_RELATED_BY_SENDERS.name];
const relationSendersFilter = this.filterJson[FILTER_RELATED_BY_SENDERS.name];
if (relationSendersFilter !== undefined) {
if (!this.arrayMatchesFilter(relationSendersFilter, relationSenders)) {
return false;