Merge branch 'develop' into t3chguy/fix/18071
This commit is contained in:
@@ -49,7 +49,7 @@ class GroupFilterOrderStore extends Store {
|
||||
this.__emitChange();
|
||||
}
|
||||
|
||||
__onDispatch(payload) {
|
||||
__onDispatch(payload) { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
switch (payload.action) {
|
||||
// Initialise state after initial sync
|
||||
case 'view_room': {
|
||||
|
||||
@@ -44,7 +44,7 @@ class LifecycleStore extends Store<ActionPayload> {
|
||||
this.__emitChange();
|
||||
}
|
||||
|
||||
protected __onDispatch(payload: ActionPayload) {
|
||||
protected __onDispatch(payload: ActionPayload) { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
switch (payload.action) {
|
||||
case 'do_after_sync_prepared':
|
||||
this.setState({
|
||||
|
||||
@@ -144,7 +144,7 @@ export default class RightPanelStore extends Store<ActionPayload> {
|
||||
this.__emitChange();
|
||||
}
|
||||
|
||||
__onDispatch(payload: ActionPayload) {
|
||||
__onDispatch(payload: ActionPayload) { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
switch (payload.action) {
|
||||
case 'view_room':
|
||||
if (payload.room_id === this.lastRoomId) break; // skip this transition, probably a permalink
|
||||
|
||||
@@ -96,7 +96,7 @@ class RoomViewStore extends Store<ActionPayload> {
|
||||
this.__emitChange();
|
||||
}
|
||||
|
||||
__onDispatch(payload) {
|
||||
__onDispatch(payload) { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
switch (payload.action) {
|
||||
// view_room:
|
||||
// - room_alias: '#somealias:matrix.org'
|
||||
@@ -325,8 +325,8 @@ class RoomViewStore extends Store<ActionPayload> {
|
||||
msg = _t("There was an error joining the room");
|
||||
} else if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') {
|
||||
msg = <div>
|
||||
{_t("Sorry, your homeserver is too old to participate in this room.")}<br />
|
||||
{_t("Please contact your homeserver administrator.")}
|
||||
{ _t("Sorry, your homeserver is too old to participate in this room.") }<br />
|
||||
{ _t("Please contact your homeserver administrator.") }
|
||||
</div>;
|
||||
} else if (err.httpStatus === 404) {
|
||||
const invitingUserId = this.getInvitingUserId(this.state.roomId);
|
||||
|
||||
+119
-1
@@ -14,11 +14,14 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { ListIteratee, Many, sortBy, throttle } from "lodash";
|
||||
import { EventType, RoomType } from "matrix-js-sdk/src/@types/event";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { ISpaceSummaryRoom } from "matrix-js-sdk/src/@types/spaces";
|
||||
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
||||
import { IRoomCapability } from "matrix-js-sdk/src/client";
|
||||
|
||||
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
|
||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||
@@ -38,6 +41,13 @@ 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";
|
||||
import GenericToast from "../components/views/toasts/GenericToast";
|
||||
import Modal from "../Modal";
|
||||
import InfoDialog from "../components/views/dialogs/InfoDialog";
|
||||
|
||||
type SpaceKey = string | symbol;
|
||||
|
||||
@@ -113,6 +123,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
private _suggestedRooms: ISuggestedRoom[] = [];
|
||||
private _invitedSpaces = new Set<Room>();
|
||||
private spaceOrderLocalEchoMap = new Map<string, string>();
|
||||
private _restrictedJoinRuleSupport?: IRoomCapability;
|
||||
|
||||
public get invitedSpaces(): Room[] {
|
||||
return Array.from(this._invitedSpaces);
|
||||
@@ -130,6 +141,45 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active space, updates room list filters,
|
||||
* optionally switches the user's room back to where they were when they last viewed that space.
|
||||
@@ -138,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);
|
||||
@@ -179,6 +229,65 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
window.localStorage.removeItem(ACTIVE_SPACE_LS_KEY);
|
||||
}
|
||||
|
||||
// New in Spaces beta toast for Restricted Join Rule
|
||||
const lsKey = "mx_SpaceBeta_restrictedJoinRuleToastSeen";
|
||||
if (contextSwitch && space?.getJoinRule() === JoinRule.Invite && shouldShowSpaceSettings(space) &&
|
||||
space.getJoinedMemberCount() > 1 && !localStorage.getItem(lsKey)
|
||||
&& this.restrictedJoinRuleSupport?.preferred
|
||||
) {
|
||||
const toastKey = "restrictedjoinrule";
|
||||
ToastStore.sharedInstance().addOrReplaceToast({
|
||||
key: toastKey,
|
||||
title: _t("New in the Spaces beta"),
|
||||
props: {
|
||||
description: _t("Help people in spaces to find and join private rooms"),
|
||||
acceptLabel: _t("Learn more"),
|
||||
onAccept: () => {
|
||||
localStorage.setItem(lsKey, "true");
|
||||
ToastStore.sharedInstance().dismissToast(toastKey);
|
||||
|
||||
Modal.createTrackedDialog("New in the Spaces beta", "restricted join rule", InfoDialog, {
|
||||
title: _t("Help space members find private rooms"),
|
||||
description: <>
|
||||
<p>{ _t("To help space members find and join a private room, " +
|
||||
"go to that room's Security & Privacy settings.") }</p>
|
||||
|
||||
{ /* Reuses classes from TabbedView for simplicity, non-interactive */ }
|
||||
<div style={{ width: "190px" }}>
|
||||
<div className="mx_TabbedView_tabLabel">
|
||||
<span className="mx_TabbedView_maskedIcon mx_RoomSettingsDialog_settingsIcon" />
|
||||
<span className="mx_TabbedView_tabLabel_text">{ _t("General") }</span>
|
||||
</div>
|
||||
<div className="mx_TabbedView_tabLabel mx_TabbedView_tabLabel_active">
|
||||
<span className="mx_TabbedView_maskedIcon mx_RoomSettingsDialog_securityIcon" />
|
||||
<span className="mx_TabbedView_tabLabel_text">{ _t("Security & Privacy") }</span>
|
||||
</div>
|
||||
<div className="mx_TabbedView_tabLabel">
|
||||
<span className="mx_TabbedView_maskedIcon mx_RoomSettingsDialog_rolesIcon" />
|
||||
<span className="mx_TabbedView_tabLabel_text">{ _t("Roles & Permissions") }</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>{ _t("This makes it easy for rooms to stay private to a space, " +
|
||||
"while letting people in the space find and join them. " +
|
||||
"All new rooms in a space will have this option available.") }</p>
|
||||
</>,
|
||||
button: _t("OK"),
|
||||
hasCloseButton: false,
|
||||
fixedWidth: true,
|
||||
});
|
||||
},
|
||||
rejectLabel: _t("Skip"),
|
||||
onReject: () => {
|
||||
localStorage.setItem(lsKey, "true");
|
||||
ToastStore.sharedInstance().dismissToast(toastKey);
|
||||
},
|
||||
},
|
||||
component: GenericToast,
|
||||
priority: 35,
|
||||
});
|
||||
}
|
||||
|
||||
if (space) {
|
||||
const suggestedRooms = await this.fetchSuggestedRooms(space);
|
||||
if (this._activeSpace === space) {
|
||||
@@ -265,6 +374,10 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
return sortBy(parents, r => r.roomId)?.[0] || null;
|
||||
}
|
||||
|
||||
public getKnownParents(roomId: string): Set<string> {
|
||||
return this.parentMap.get(roomId) || new Set();
|
||||
}
|
||||
|
||||
public getSpaceFilteredRoomIds = (space: Room | null): Set<string> => {
|
||||
if (!space && spacesTweakAllRoomsEnabled) {
|
||||
return new Set(this.matrixClient.getVisibleRooms().map(r => r.roomId));
|
||||
@@ -642,6 +755,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
this.matrixClient.on("accountData", this.onAccountData);
|
||||
}
|
||||
|
||||
this.matrixClient.getCapabilities().then(capabilities => {
|
||||
this._restrictedJoinRuleSupport = capabilities
|
||||
?.["m.room_versions"]?.["org.matrix.msc3244.room_capabilities"]?.["restricted"];
|
||||
});
|
||||
|
||||
await this.onSpaceUpdate(); // trigger an initial update
|
||||
|
||||
// restore selected state from last session if any and still valid
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
|
||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../dispatcher/payloads";
|
||||
import { VoiceRecording } from "../voice/VoiceRecording";
|
||||
import { VoiceRecording } from "../audio/VoiceRecording";
|
||||
|
||||
interface IState {
|
||||
recording?: VoiceRecording;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ const PREVIEWS = {
|
||||
const MAX_EVENTS_BACKWARDS = 50;
|
||||
|
||||
// type merging ftw
|
||||
type TAG_ANY = "im.vector.any";
|
||||
type TAG_ANY = "im.vector.any"; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
const TAG_ANY: TAG_ANY = "im.vector.any";
|
||||
|
||||
interface IState {
|
||||
|
||||
Reference in New Issue
Block a user