Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/fix/17686
Conflicts: src/stores/SpaceStore.tsx
This commit is contained in:
commit
18bb4bce35
52 changed files with 2572 additions and 2251 deletions
|
@ -41,6 +41,7 @@ import { arrayHasDiff } from "../utils/arrays";
|
|||
import { objectDiff } from "../utils/objects";
|
||||
import { arrayHasOrderChange } from "../utils/arrays";
|
||||
import { reorderLexicographically } from "../utils/stringOrderField";
|
||||
import { TAG_ORDER } from "../components/views/rooms/RoomList";
|
||||
import { shouldShowSpaceSettings } from "../utils/space";
|
||||
import ToastStore from "./ToastStore";
|
||||
import { _t } from "../languageHandler";
|
||||
|
@ -140,6 +141,41 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
return this._suggestedRooms;
|
||||
}
|
||||
|
||||
public async setActiveRoomInSpace(space: Room | null): Promise<void> {
|
||||
if (space && !space.isSpaceRoom()) return;
|
||||
if (space !== this.activeSpace) await this.setActiveSpace(space);
|
||||
|
||||
if (space) {
|
||||
const notificationState = this.getNotificationState(space.roomId);
|
||||
const roomId = notificationState.getFirstRoomWithNotifications();
|
||||
defaultDispatcher.dispatch({
|
||||
action: "view_room",
|
||||
room_id: roomId,
|
||||
context_switch: true,
|
||||
});
|
||||
} else {
|
||||
const lists = RoomListStore.instance.unfilteredLists;
|
||||
for (let i = 0; i < TAG_ORDER.length; i++) {
|
||||
const t = TAG_ORDER[i];
|
||||
const listRooms = lists[t];
|
||||
const unreadRoom = listRooms.find((r: Room) => {
|
||||
if (this.showInHomeSpace(r)) {
|
||||
const state = RoomNotificationStateStore.instance.getRoomState(r);
|
||||
return state.isUnread;
|
||||
}
|
||||
});
|
||||
if (unreadRoom) {
|
||||
defaultDispatcher.dispatch({
|
||||
action: "view_room",
|
||||
room_id: unreadRoom.roomId,
|
||||
context_switch: true,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public get restrictedJoinRuleSupport(): IRoomCapability {
|
||||
return this._restrictedJoinRuleSupport;
|
||||
}
|
||||
|
@ -152,7 +188,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
* should not be done when the space switch is done implicitly due to another event like switching room.
|
||||
*/
|
||||
public async setActiveSpace(space: Room | null, contextSwitch = true) {
|
||||
if (space === this.activeSpace || (space && !space?.isSpaceRoom())) return;
|
||||
if (space === this.activeSpace || (space && !space.isSpaceRoom())) return;
|
||||
|
||||
this._activeSpace = space;
|
||||
this.emit(UPDATE_SELECTED_SPACE, this.activeSpace);
|
||||
|
|
|
@ -15,7 +15,11 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import EventEmitter from "events";
|
||||
import ResizeObserver from 'resize-observer-polyfill';
|
||||
// XXX: resize-observer-polyfill has types that now conflict with typescript's
|
||||
// own DOM types: https://github.com/que-etc/resize-observer-polyfill/issues/80
|
||||
// Using require here rather than import is a horrenous workaround. We should
|
||||
// be able to remove the polyfill once Safari 14 is released.
|
||||
const ResizeObserverPolyfill = require('resize-observer-polyfill'); // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
import ResizeObserverEntry from 'resize-observer-polyfill/src/ResizeObserverEntry';
|
||||
|
||||
export enum UI_EVENTS {
|
||||
|
@ -43,7 +47,7 @@ export default class UIStore extends EventEmitter {
|
|||
// eslint-disable-next-line no-restricted-properties
|
||||
this.windowHeight = window.innerHeight;
|
||||
|
||||
this.resizeObserver = new ResizeObserver(this.resizeObserverCallback);
|
||||
this.resizeObserver = new ResizeObserverPolyfill(this.resizeObserverCallback);
|
||||
this.resizeObserver.observe(document.body);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,10 @@ export class SpaceNotificationState extends NotificationState {
|
|||
this.calculateTotalState();
|
||||
}
|
||||
|
||||
public getFirstRoomWithNotifications() {
|
||||
return this.rooms.find((room) => room.getUnreadNotificationCount() > 0).roomId;
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
super.destroy();
|
||||
for (const state of Object.values(this.states)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue