mirror of https://github.com/vector-im/riot-web
updated TagFilterStore
parent
4f8b0afc41
commit
f5a40eff4b
|
@ -17,14 +17,14 @@ limitations under the License.
|
|||
|
||||
import Analytics from '../Analytics';
|
||||
import { asyncAction } from './actionCreators';
|
||||
import TagOrderStore from '../stores/TagOrderStore';
|
||||
import GroupFilterOrderStore from '../stores/GroupFilterOrderStore';
|
||||
import { AsyncActionPayload } from "../dispatcher/payloads";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
|
||||
export default class TagOrderActions {
|
||||
/**
|
||||
* Creates an action thunk that will do an asynchronous request to
|
||||
* move a tag in TagOrderStore to destinationIx.
|
||||
* move a tag in GroupFilterOrderStore to destinationIx.
|
||||
*
|
||||
* @param {MatrixClient} matrixClient the matrix client to set the
|
||||
* account data on.
|
||||
|
@ -36,8 +36,8 @@ export default class TagOrderActions {
|
|||
*/
|
||||
public static moveTag(matrixClient: MatrixClient, tag: string, destinationIx: number): AsyncActionPayload {
|
||||
// Only commit tags if the state is ready, i.e. not null
|
||||
let tags = TagOrderStore.getOrderedTags();
|
||||
let removedTags = TagOrderStore.getRemovedTagsAccountData() || [];
|
||||
let tags = GroupFilterOrderStore.getOrderedTags();
|
||||
let removedTags = GroupFilterOrderStore.getRemovedTagsAccountData() || [];
|
||||
if (!tags) {
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export default class TagOrderActions {
|
|||
|
||||
removedTags = removedTags.filter((t) => t !== tag);
|
||||
|
||||
const storeId = TagOrderStore.getStoreId();
|
||||
const storeId = GroupFilterOrderStore.getStoreId();
|
||||
|
||||
return asyncAction('TagOrderActions.moveTag', () => {
|
||||
Analytics.trackEvent('TagOrderActions', 'commitTagOrdering');
|
||||
|
@ -83,8 +83,8 @@ export default class TagOrderActions {
|
|||
*/
|
||||
public static removeTag(matrixClient: MatrixClient, tag: string): AsyncActionPayload {
|
||||
// Don't change tags, just removedTags
|
||||
const tags = TagOrderStore.getOrderedTags();
|
||||
const removedTags = TagOrderStore.getRemovedTagsAccountData() || [];
|
||||
const tags = GroupFilterOrderStore.getOrderedTags();
|
||||
const removedTags = GroupFilterOrderStore.getRemovedTagsAccountData() || [];
|
||||
|
||||
if (removedTags.includes(tag)) {
|
||||
// Return a thunk that doesn't do anything, we don't even need
|
||||
|
@ -94,7 +94,7 @@ export default class TagOrderActions {
|
|||
|
||||
removedTags.push(tag);
|
||||
|
||||
const storeId = TagOrderStore.getStoreId();
|
||||
const storeId = GroupFilterOrderStore.getStoreId();
|
||||
|
||||
return asyncAction('TagOrderActions.removeTag', () => {
|
||||
Analytics.trackEvent('TagOrderActions', 'removeTag');
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import TagOrderStore from '../../stores/TagOrderStore';
|
||||
import GroupFilterOrderStore from '../../stores/GroupFilterOrderStore';
|
||||
|
||||
import GroupActions from '../../actions/GroupActions';
|
||||
|
||||
|
@ -44,13 +44,13 @@ class GroupFilterPanel extends React.Component {
|
|||
this.context.on("Group.myMembership", this._onGroupMyMembership);
|
||||
this.context.on("sync", this._onClientSync);
|
||||
|
||||
this._tagOrderStoreToken = TagOrderStore.addListener(() => {
|
||||
this._GroupFilterOrderStoreToken = GroupFilterOrderStore.addListener(() => {
|
||||
if (this.unmounted) {
|
||||
return;
|
||||
}
|
||||
this.setState({
|
||||
orderedTags: TagOrderStore.getOrderedTags() || [],
|
||||
selectedTags: TagOrderStore.getSelectedTags(),
|
||||
orderedTags: GroupFilterOrderStore.getOrderedTags() || [],
|
||||
selectedTags: GroupFilterOrderStore.getSelectedTags(),
|
||||
});
|
||||
});
|
||||
// This could be done by anything with a matrix client
|
||||
|
@ -61,8 +61,8 @@ class GroupFilterPanel extends React.Component {
|
|||
this.unmounted = true;
|
||||
this.context.removeListener("Group.myMembership", this._onGroupMyMembership);
|
||||
this.context.removeListener("sync", this._onClientSync);
|
||||
if (this._tagOrderStoreToken) {
|
||||
this._tagOrderStoreToken.remove();
|
||||
if (this._GroupFilterOrderStoreToken) {
|
||||
this._GroupFilterOrderStoreToken.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ class LoggedInView extends React.Component<IProps, IState> {
|
|||
const draggableId = result.draggableId.split(' ').pop();
|
||||
|
||||
// Dispatch synchronously so that the GroupFilterPanel receives an
|
||||
// optimistic update from TagOrderStore before the previous
|
||||
// optimistic update from GroupFilterOrderStore before the previous
|
||||
// state is shown.
|
||||
dis.dispatch(TagOrderActions.moveTag(
|
||||
this._matrixClient,
|
||||
|
|
|
@ -30,7 +30,7 @@ import Analytics from '../../Analytics';
|
|||
import {getHttpUriForMxc} from "matrix-js-sdk/src/content-repo";
|
||||
import {ALL_ROOMS} from "../views/directory/NetworkDropdown";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import TagOrderStore from "../../stores/TagOrderStore";
|
||||
import GroupFilterOrderStore from "../../stores/GroupFilterOrderStore";
|
||||
import GroupStore from "../../stores/GroupStore";
|
||||
import FlairStore from "../../stores/FlairStore";
|
||||
|
||||
|
@ -49,7 +49,7 @@ export default class RoomDirectory extends React.Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const selectedCommunityId = TagOrderStore.getSelectedTags()[0];
|
||||
const selectedCommunityId = GroupFilterOrderStore.getSelectedTags()[0];
|
||||
this.state = {
|
||||
publicRooms: [],
|
||||
loading: true,
|
||||
|
|
|
@ -44,7 +44,7 @@ import IconizedContextMenu, {
|
|||
} from "../views/context_menus/IconizedContextMenu";
|
||||
import { CommunityPrototypeStore } from "../../stores/CommunityPrototypeStore";
|
||||
import * as fbEmitter from "fbemitter";
|
||||
import TagOrderStore from "../../stores/TagOrderStore";
|
||||
import GroupFilterOrderStore from "../../stores/GroupFilterOrderStore";
|
||||
import { showCommunityInviteDialog } from "../../RoomInvite";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
|
||||
|
@ -87,7 +87,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
public componentDidMount() {
|
||||
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
||||
this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged);
|
||||
this.tagStoreRef = TagOrderStore.addListener(this.onTagStoreUpdate);
|
||||
this.tagStoreRef = GroupFilterOrderStore.addListener(this.onTagStoreUpdate);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
|
|
|
@ -26,7 +26,7 @@ import * as FormattingUtils from '../../../utils/FormattingUtils';
|
|||
|
||||
import FlairStore from '../../../stores/FlairStore';
|
||||
import GroupStore from '../../../stores/GroupStore';
|
||||
import TagOrderStore from '../../../stores/TagOrderStore';
|
||||
import GroupFilterOrderStore from '../../../stores/GroupFilterOrderStore';
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import AccessibleButton from "./AccessibleButton";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
|
@ -142,7 +142,7 @@ export default class TagTile extends React.Component {
|
|||
mx_TagTile_selected_prototype: this.props.selected && isPrototype,
|
||||
});
|
||||
|
||||
const badge = TagOrderStore.getGroupBadge(this.props.tag);
|
||||
const badge = GroupFilterOrderStore.getGroupBadge(this.props.tag);
|
||||
let badgeElement;
|
||||
if (badge && !this.state.hover && !this.props.menuDisplayed) {
|
||||
const badgeClasses = classNames({
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import * as fbEmitter from "fbemitter";
|
||||
import TagOrderStore from "../../../stores/TagOrderStore";
|
||||
import GroupFilterOrderStore from "../../../stores/GroupFilterOrderStore";
|
||||
import AccessibleTooltipButton from "./AccessibleTooltipButton";
|
||||
import classNames from "classnames";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
@ -36,12 +36,12 @@ export default class UserTagTile extends React.PureComponent<IProps, IState> {
|
|||
super(props);
|
||||
|
||||
this.state = {
|
||||
selected: TagOrderStore.getSelectedTags().length === 0,
|
||||
selected: GroupFilterOrderStore.getSelectedTags().length === 0,
|
||||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
this.tagStoreRef = TagOrderStore.addListener(this.onTagStoreUpdate);
|
||||
this.tagStoreRef = GroupFilterOrderStore.addListener(this.onTagStoreUpdate);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
|
@ -49,7 +49,7 @@ export default class UserTagTile extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private onTagStoreUpdate = () => {
|
||||
const selected = TagOrderStore.getSelectedTags().length === 0;
|
||||
const selected = GroupFilterOrderStore.getSelectedTags().length === 0;
|
||||
this.setState({selected});
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import SettingsStore from "../settings/SettingsStore";
|
|||
import * as utils from "matrix-js-sdk/src/utils";
|
||||
import { UPDATE_EVENT } from "./AsyncStore";
|
||||
import FlairStore from "./FlairStore";
|
||||
import TagOrderStore from "./TagOrderStore";
|
||||
import GroupFilterOrderStore from "./GroupFilterOrderStore";
|
||||
import GroupStore from "./GroupStore";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
||||
|
@ -50,7 +50,7 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient<IState> {
|
|||
|
||||
public getSelectedCommunityId(): string {
|
||||
if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
|
||||
return TagOrderStore.getSelectedTags()[0];
|
||||
return GroupFilterOrderStore.getSelectedTags()[0];
|
||||
}
|
||||
return null; // no selection as far as this function is concerned
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const INITIAL_STATE = {
|
|||
/**
|
||||
* A class for storing application state for ordering tags in the GroupFilterPanel.
|
||||
*/
|
||||
class TagOrderStore extends Store {
|
||||
class GroupFilterOrderStore extends Store {
|
||||
constructor() {
|
||||
super(dis);
|
||||
|
||||
|
@ -268,7 +268,7 @@ class TagOrderStore extends Store {
|
|||
}
|
||||
}
|
||||
|
||||
if (global.singletonTagOrderStore === undefined) {
|
||||
global.singletonTagOrderStore = new TagOrderStore();
|
||||
if (global.singletonGroupFilterOrderStore === undefined) {
|
||||
global.singletonGroupFilterOrderStore = new GroupFilterOrderStore();
|
||||
}
|
||||
export default global.singletonTagOrderStore;
|
||||
export default global.singletonGroupFilterOrderStore;
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { RoomListStoreClass } from "./RoomListStore";
|
||||
import TagOrderStore from "../TagOrderStore";
|
||||
import GroupFilterOrderStore from "../GroupFilterOrderStore";
|
||||
import { CommunityFilterCondition } from "./filters/CommunityFilterCondition";
|
||||
import { arrayDiff, arrayHasDiff } from "../../utils/arrays";
|
||||
|
||||
|
@ -26,12 +26,12 @@ export class TagWatcher {
|
|||
private filters = new Map<string, CommunityFilterCondition>();
|
||||
|
||||
constructor(private store: RoomListStoreClass) {
|
||||
TagOrderStore.addListener(this.onTagsUpdated);
|
||||
GroupFilterOrderStore.addListener(this.onTagsUpdated);
|
||||
}
|
||||
|
||||
private onTagsUpdated = () => {
|
||||
const lastTags = Array.from(this.filters.keys());
|
||||
const newTags = TagOrderStore.getSelectedTags();
|
||||
const newTags = GroupFilterOrderStore.getSelectedTags();
|
||||
|
||||
if (arrayHasDiff(lastTags, newTags)) {
|
||||
// Selected tags changed, do some filtering
|
||||
|
|
Loading…
Reference in New Issue