Merge pull request #5775 from matrix-org/travis/fix-archive
Remove forgotten rooms from the room list once forgottenpull/21833/head
commit
1f5c090ed2
|
@ -85,6 +85,8 @@ import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast
|
||||||
import SpaceStore from "../../stores/SpaceStore";
|
import SpaceStore from "../../stores/SpaceStore";
|
||||||
import SpaceRoomDirectory from "./SpaceRoomDirectory";
|
import SpaceRoomDirectory from "./SpaceRoomDirectory";
|
||||||
import {replaceableComponent} from "../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../utils/replaceableComponent";
|
||||||
|
import RoomListStore from "../../stores/room-list/RoomListStore";
|
||||||
|
import {RoomUpdateCause} from "../../stores/room-list/models";
|
||||||
|
|
||||||
/** constants for MatrixChat.state.view */
|
/** constants for MatrixChat.state.view */
|
||||||
export enum Views {
|
export enum Views {
|
||||||
|
@ -1140,11 +1142,17 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private forgetRoom(roomId: string) {
|
private forgetRoom(roomId: string) {
|
||||||
|
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
MatrixClientPeg.get().forget(roomId).then(() => {
|
MatrixClientPeg.get().forget(roomId).then(() => {
|
||||||
// Switch to home page if we're currently viewing the forgotten room
|
// Switch to home page if we're currently viewing the forgotten room
|
||||||
if (this.state.currentRoomId === roomId) {
|
if (this.state.currentRoomId === roomId) {
|
||||||
dis.dispatch({ action: "view_home_page" });
|
dis.dispatch({ action: "view_home_page" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We have to manually update the room list because the forgotten room will not
|
||||||
|
// be notified to us, therefore the room list will have no other way of knowing
|
||||||
|
// the room is forgotten.
|
||||||
|
RoomListStore.instance.manualRoomUpdate(room, RoomUpdateCause.RoomRemoved);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
const errCode = err.errcode || _td("unknown error code");
|
const errCode = err.errcode || _td("unknown error code");
|
||||||
Modal.createTrackedDialog("Failed to forget room", '', ErrorDialog, {
|
Modal.createTrackedDialog("Failed to forget room", '', ErrorDialog, {
|
||||||
|
|
|
@ -655,6 +655,18 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
if (!algorithmTags) return [DefaultTagID.Untagged];
|
if (!algorithmTags) return [DefaultTagID.Untagged];
|
||||||
return algorithmTags;
|
return algorithmTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually update a room with a given cause. This should only be used if the
|
||||||
|
* room list store would otherwise be incapable of doing the update itself. Note
|
||||||
|
* that this may race with the room list's regular operation.
|
||||||
|
* @param {Room} room The room to update.
|
||||||
|
* @param {RoomUpdateCause} cause The cause to update for.
|
||||||
|
*/
|
||||||
|
public async manualRoomUpdate(room: Room, cause: RoomUpdateCause) {
|
||||||
|
await this.handleRoomUpdate(room, cause);
|
||||||
|
this.updateFn.trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class RoomListStore {
|
export default class RoomListStore {
|
||||||
|
|
Loading…
Reference in New Issue