Forget member-list query when switching out of the room (#7093)
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
0f8272c6a1
commit
6d3ba0eb95
2 changed files with 23 additions and 26 deletions
|
@ -77,6 +77,7 @@ interface IState {
|
||||||
event: MatrixEvent;
|
event: MatrixEvent;
|
||||||
initialEvent?: MatrixEvent;
|
initialEvent?: MatrixEvent;
|
||||||
initialEventHighlighted?: boolean;
|
initialEventHighlighted?: boolean;
|
||||||
|
searchQuery: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("structures.RightPanel")
|
@replaceableComponent("structures.RightPanel")
|
||||||
|
@ -92,6 +93,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
phase: this.getPhaseFromProps(),
|
phase: this.getPhaseFromProps(),
|
||||||
isUserPrivilegedInGroup: null,
|
isUserPrivilegedInGroup: null,
|
||||||
member: this.getUserForPanel(),
|
member: this.getUserForPanel(),
|
||||||
|
searchQuery: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +250,10 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onSearchQueryChanged = (searchQuery: string): void => {
|
||||||
|
this.setState({ searchQuery });
|
||||||
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
let panel = <div />;
|
let panel = <div />;
|
||||||
const roomId = this.props.room ? this.props.room.roomId : undefined;
|
const roomId = this.props.room ? this.props.room.roomId : undefined;
|
||||||
|
@ -255,7 +261,13 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
switch (this.state.phase) {
|
switch (this.state.phase) {
|
||||||
case RightPanelPhases.RoomMemberList:
|
case RightPanelPhases.RoomMemberList:
|
||||||
if (roomId) {
|
if (roomId) {
|
||||||
panel = <MemberList roomId={roomId} key={roomId} onClose={this.onClose} />;
|
panel = <MemberList
|
||||||
|
roomId={roomId}
|
||||||
|
key={roomId}
|
||||||
|
onClose={this.onClose}
|
||||||
|
searchQuery={this.state.searchQuery}
|
||||||
|
onSearchQueryChanged={this.onSearchQueryChanged}
|
||||||
|
/>;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RightPanelPhases.SpaceMemberList:
|
case RightPanelPhases.SpaceMemberList:
|
||||||
|
@ -263,6 +275,8 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
roomId={this.state.space ? this.state.space.roomId : roomId}
|
roomId={this.state.space ? this.state.space.roomId : roomId}
|
||||||
key={this.state.space ? this.state.space.roomId : roomId}
|
key={this.state.space ? this.state.space.roomId : roomId}
|
||||||
onClose={this.onClose}
|
onClose={this.onClose}
|
||||||
|
searchQuery={this.state.searchQuery}
|
||||||
|
onSearchQueryChanged={this.onSearchQueryChanged}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,6 @@ import { shouldShowComponent } from "../../../customisations/helpers/UIComponent
|
||||||
import { UIComponent } from "../../../settings/UIFeature";
|
import { UIComponent } from "../../../settings/UIFeature";
|
||||||
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
||||||
|
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
|
||||||
|
|
||||||
const getSearchQueryLSKey = (roomId: string) => `mx_MemberList_searchQuarry_${roomId}`;
|
|
||||||
|
|
||||||
const INITIAL_LOAD_NUM_MEMBERS = 30;
|
const INITIAL_LOAD_NUM_MEMBERS = 30;
|
||||||
const INITIAL_LOAD_NUM_INVITED = 5;
|
const INITIAL_LOAD_NUM_INVITED = 5;
|
||||||
const SHOW_MORE_INCREMENT = 100;
|
const SHOW_MORE_INCREMENT = 100;
|
||||||
|
@ -62,7 +58,9 @@ const SORT_REGEX = /[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+/g;
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
|
searchQuery: string;
|
||||||
onClose(): void;
|
onClose(): void;
|
||||||
|
onSearchQueryChanged: (query: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
|
@ -73,7 +71,6 @@ interface IState {
|
||||||
canInvite: boolean;
|
canInvite: boolean;
|
||||||
truncateAtJoined: number;
|
truncateAtJoined: number;
|
||||||
truncateAtInvited: number;
|
truncateAtInvited: number;
|
||||||
searchQuery: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.rooms.MemberList")
|
@replaceableComponent("views.rooms.MemberList")
|
||||||
|
@ -182,27 +179,19 @@ export default class MemberList extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getMembersState(members: Array<RoomMember>): IState {
|
private getMembersState(members: Array<RoomMember>): IState {
|
||||||
let searchQuery;
|
|
||||||
try {
|
|
||||||
searchQuery = window.localStorage.getItem(getSearchQueryLSKey(this.props.roomId));
|
|
||||||
} catch (error) {
|
|
||||||
logger.warn("Failed to get last the MemberList search query", error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the state after determining showPresence to make sure it's
|
// set the state after determining showPresence to make sure it's
|
||||||
// taken into account while rendering
|
// taken into account while rendering
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
members: members,
|
members: members,
|
||||||
filteredJoinedMembers: this.filterMembers(members, 'join', searchQuery),
|
filteredJoinedMembers: this.filterMembers(members, 'join', this.props.searchQuery),
|
||||||
filteredInvitedMembers: this.filterMembers(members, 'invite', searchQuery),
|
filteredInvitedMembers: this.filterMembers(members, 'invite', this.props.searchQuery),
|
||||||
canInvite: this.canInvite,
|
canInvite: this.canInvite,
|
||||||
|
|
||||||
// ideally we'd size this to the page height, but
|
// ideally we'd size this to the page height, but
|
||||||
// in practice I find that a little constraining
|
// in practice I find that a little constraining
|
||||||
truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS,
|
truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS,
|
||||||
truncateAtInvited: INITIAL_LOAD_NUM_INVITED,
|
truncateAtInvited: INITIAL_LOAD_NUM_INVITED,
|
||||||
searchQuery: searchQuery ?? "",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,8 +255,8 @@ export default class MemberList extends React.Component<IProps, IState> {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: false,
|
loading: false,
|
||||||
members: members,
|
members: members,
|
||||||
filteredJoinedMembers: this.filterMembers(members, 'join', this.state.searchQuery),
|
filteredJoinedMembers: this.filterMembers(members, 'join', this.props.searchQuery),
|
||||||
filteredInvitedMembers: this.filterMembers(members, 'invite', this.state.searchQuery),
|
filteredInvitedMembers: this.filterMembers(members, 'invite', this.props.searchQuery),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,14 +421,8 @@ export default class MemberList extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onSearchQueryChanged = (searchQuery: string): void => {
|
private onSearchQueryChanged = (searchQuery: string): void => {
|
||||||
try {
|
this.props.onSearchQueryChanged(searchQuery);
|
||||||
window.localStorage.setItem(getSearchQueryLSKey(this.props.roomId), searchQuery);
|
|
||||||
} catch (error) {
|
|
||||||
logger.warn("Failed to set the last MemberList search query", error);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
searchQuery,
|
|
||||||
filteredJoinedMembers: this.filterMembers(this.state.members, 'join', searchQuery),
|
filteredJoinedMembers: this.filterMembers(this.state.members, 'join', searchQuery),
|
||||||
filteredInvitedMembers: this.filterMembers(this.state.members, 'invite', searchQuery),
|
filteredInvitedMembers: this.filterMembers(this.state.members, 'invite', searchQuery),
|
||||||
});
|
});
|
||||||
|
@ -579,7 +562,7 @@ export default class MemberList extends React.Component<IProps, IState> {
|
||||||
className="mx_MemberList_query mx_textinput_icon mx_textinput_search"
|
className="mx_MemberList_query mx_textinput_icon mx_textinput_search"
|
||||||
placeholder={_t('Filter room members')}
|
placeholder={_t('Filter room members')}
|
||||||
onSearch={this.onSearchQueryChanged}
|
onSearch={this.onSearchQueryChanged}
|
||||||
initialValue={this.state.searchQuery}
|
initialValue={this.props.searchQuery}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue