Skip to content

Commit 8ee6a08

Browse files
committed
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/fix/19304
2 parents cadc9d2 + 0f212b2 commit 8ee6a08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2428
-1064
lines changed

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
@import "./structures/_ViewSource.scss";
4040
@import "./structures/auth/_CompleteSecurity.scss";
4141
@import "./structures/auth/_Login.scss";
42+
@import "./structures/auth/_SetupEncryptionBody.scss";
4243
@import "./views/audio_messages/_AudioPlayer.scss";
4344
@import "./views/audio_messages/_PlayPauseButton.scss";
4445
@import "./views/audio_messages/_PlaybackContainer.scss";

res/css/structures/auth/_CompleteSecurity.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ limitations under the License.
3333
margin: 0 auto;
3434
}
3535

36+
.mx_CompleteSecurity_skip {
37+
mask: url('$(res)/img/feather-customised/cancel.svg');
38+
mask-repeat: no-repeat;
39+
mask-position: center;
40+
mask-size: cover;
41+
width: 18px;
42+
height: 18px;
43+
background-color: $dialog-close-fg-color;
44+
cursor: pointer;
45+
position: absolute;
46+
right: 24px;
47+
}
48+
3649
.mx_CompleteSecurity_body {
3750
font-size: $font-15px;
3851
}

src/contexts/MatrixClientContext.ts renamed to res/css/structures/auth/_SetupEncryptionBody.scss

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 The Matrix.org Foundation C.I.C.
2+
Copyright 2021 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,9 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { createContext } from "react";
18-
import { MatrixClient } from "matrix-js-sdk/src/client";
17+
.mx_SetupEncryptionBody_reset {
18+
color: $light-fg-color;
19+
margin-top: $font-14px;
1920

20-
const MatrixClientContext = createContext<MatrixClient>(undefined);
21-
MatrixClientContext.displayName = "MatrixClientContext";
22-
export default MatrixClientContext;
21+
a.mx_SetupEncryptionBody_reset_link:is(:link, :hover, :visited) {
22+
color: $warning-color;
23+
}
24+
}

res/css/views/dialogs/_AddExistingToSpaceDialog.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ limitations under the License.
7575
@mixin ProgressBarBorderRadius 8px;
7676
}
7777

78-
.mx_AddExistingToSpace_progressText {
78+
.mx_AddExistingToSpaceDialog_progressText {
7979
margin-top: 8px;
8080
font-size: $font-15px;
8181
line-height: $font-24px;

res/css/views/dialogs/_CreateSpaceFromCommunityDialog.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ limitations under the License.
7474
font-size: $font-12px;
7575
line-height: $font-15px;
7676
color: $secondary-content;
77+
margin-top: -13px; // match height of buttons to prevent height changing
7778

7879
.mx_ProgressBar {
7980
height: 8px;

res/css/views/settings/_ProfileSettings.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ limitations under the License.
6767

6868
> .mx_AccessibleButton_kind_link {
6969
padding-left: 0; // to align with left side
70+
padding-right: 0;
71+
margin-right: 10px;
7072
}
7173
}

src/Avatar.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,11 @@ export function avatarUrlForRoom(room: Room, width: number, height: number, resi
142142
// space rooms cannot be DMs so skip the rest
143143
if (SpaceStore.spacesEnabled && room.isSpaceRoom()) return null;
144144

145-
let otherMember = null;
146-
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
147-
if (otherUserId) {
148-
otherMember = room.getMember(otherUserId);
149-
} else {
150-
// if the room is not marked as a 1:1, but only has max 2 members
151-
// then still try to show any avatar (pref. other member)
152-
otherMember = room.getAvatarFallbackMember();
153-
}
145+
// If the room is not a DM don't fallback to a member avatar
146+
if (!DMRoomMap.shared().getUserIdForRoomId(room.roomId)) return null;
147+
148+
// If there are only two members in the DM use the avatar of the other member
149+
const otherMember = room.getAvatarFallbackMember();
154150
if (otherMember?.getMxcAvatarUrl()) {
155151
return mediaFromMxc(otherMember.getMxcAvatarUrl()).getThumbnailOfSourceHttp(width, height, resizeMethod);
156152
}

src/RoomInvite.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ export interface IInviteResult {
4242
*
4343
* @param {string} roomId The ID of the room to invite to
4444
* @param {string[]} addresses Array of strings of addresses to invite. May be matrix IDs or 3pids.
45+
* @param {function} progressCallback optional callback, fired after each invite.
4546
* @returns {Promise} Promise
4647
*/
47-
export function inviteMultipleToRoom(roomId: string, addresses: string[]): Promise<IInviteResult> {
48-
const inviter = new MultiInviter(roomId);
48+
export function inviteMultipleToRoom(
49+
roomId: string,
50+
addresses: string[],
51+
progressCallback?: () => void,
52+
): Promise<IInviteResult> {
53+
const inviter = new MultiInviter(roomId, progressCallback);
4954
return inviter.invite(addresses).then(states => Promise.resolve({ states, inviter }));
5055
}
5156

@@ -104,8 +109,8 @@ export function isValid3pidInvite(event: MatrixEvent): boolean {
104109
return true;
105110
}
106111

107-
export function inviteUsersToRoom(roomId: string, userIds: string[]): Promise<void> {
108-
return inviteMultipleToRoom(roomId, userIds).then((result) => {
112+
export function inviteUsersToRoom(roomId: string, userIds: string[], progressCallback?: () => void): Promise<void> {
113+
return inviteMultipleToRoom(roomId, userIds, progressCallback).then((result) => {
109114
const room = MatrixClientPeg.get().getRoom(roomId);
110115
showAnyInviteErrors(result.states, room, result.inviter);
111116
}).catch((err) => {

src/ScalarMessaging.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ function setBotOptions(event: MessageEvent<any>, roomId: string, userId: string)
452452
});
453453
}
454454

455-
function setBotPower(event: MessageEvent<any>, roomId: string, userId: string, level: number): void {
455+
async function setBotPower(
456+
event: MessageEvent<any>, roomId: string, userId: string, level: number, ignoreIfGreater?: boolean,
457+
): Promise<void> {
456458
if (!(Number.isInteger(level) && level >= 0)) {
457459
sendError(event, _t('Power level must be positive integer.'));
458460
return;
@@ -465,22 +467,34 @@ function setBotPower(event: MessageEvent<any>, roomId: string, userId: string, l
465467
return;
466468
}
467469

468-
client.getStateEvent(roomId, "m.room.power_levels", "").then((powerLevels) => {
469-
const powerEvent = new MatrixEvent(
470+
try {
471+
const powerLevels = await client.getStateEvent(roomId, "m.room.power_levels", "");
472+
473+
// If the PL is equal to or greater than the requested PL, ignore.
474+
if (ignoreIfGreater === true) {
475+
// As per https://matrix.org/docs/spec/client_server/r0.6.0#m-room-power-levels
476+
const currentPl = (
477+
powerLevels.content.users && powerLevels.content.users[userId]
478+
) || powerLevels.content.users_default || 0;
479+
480+
if (currentPl >= level) {
481+
return sendResponse(event, {
482+
success: true,
483+
});
484+
}
485+
}
486+
await client.setPowerLevel(roomId, userId, level, new MatrixEvent(
470487
{
471488
type: "m.room.power_levels",
472489
content: powerLevels,
473490
},
474-
);
475-
476-
client.setPowerLevel(roomId, userId, level, powerEvent).then(() => {
477-
sendResponse(event, {
478-
success: true,
479-
});
480-
}, (err) => {
481-
sendError(event, err.message ? err.message : _t('Failed to send request.'), err);
491+
));
492+
return sendResponse(event, {
493+
success: true,
482494
});
483-
});
495+
} catch (err) {
496+
sendError(event, err.message ? err.message : _t('Failed to send request.'), err);
497+
}
484498
}
485499

486500
function getMembershipState(event: MessageEvent<any>, roomId: string, userId: string): void {
@@ -678,7 +692,7 @@ const onMessage = function(event: MessageEvent<any>): void {
678692
setBotOptions(event, roomId, userId);
679693
break;
680694
case Action.SetBotPower:
681-
setBotPower(event, roomId, userId, event.data.level);
695+
setBotPower(event, roomId, userId, event.data.level, event.data.ignoreIfGreater);
682696
break;
683697
default:
684698
console.warn("Unhandled postMessage event with action '" + event.data.action +"'");

src/components/structures/ContextMenu.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ export class ContextMenu extends React.PureComponent<IProps, IState> {
226226
}
227227
};
228228

229+
private onClick = (ev: React.MouseEvent) => {
230+
// Don't allow clicks to escape the context menu wrapper
231+
ev.stopPropagation();
232+
};
233+
229234
private onKeyDown = (ev: React.KeyboardEvent) => {
230235
// don't let keyboard handling escape the context menu
231236
ev.stopPropagation();
@@ -383,6 +388,7 @@ export class ContextMenu extends React.PureComponent<IProps, IState> {
383388
className={classNames("mx_ContextualMenu_wrapper", this.props.wrapperClassName)}
384389
style={{ ...position, ...wrapperStyle }}
385390
onKeyDown={this.onKeyDown}
391+
onClick={this.onClick}
386392
onContextMenu={this.onContextMenuPreventBubbling}
387393
>
388394
<div

0 commit comments

Comments
 (0)