Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 75c3a10

Browse files
committed
Merge branches 'develop' and 't3chguy/shortcuts1' of github.com:matrix-org/matrix-react-sdk into t3chguy/shortcuts1
2 parents 4da7ce1 + c9de12e commit 75c3a10

File tree

8 files changed

+182
-39
lines changed

8 files changed

+182
-39
lines changed

res/css/views/rooms/_EventTile.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ limitations under the License.
112112

113113
.mx_EventTile_line, .mx_EventTile_reply {
114114
position: relative;
115-
/* ideally should be 100px, but 95px gives us a max thumbnail size of 800x600, which is nice */
116-
margin-right: 110px;
117115
padding-left: 65px; /* left gutter */
118116
padding-top: 4px;
119117
padding-bottom: 2px;
@@ -122,6 +120,13 @@ limitations under the License.
122120
line-height: 22px;
123121
}
124122

123+
.mx_RoomView_timeline_rr_enabled {
124+
.mx_EventTile_line, .mx_EventTile_reply {
125+
/* ideally should be 100px, but 95px gives us a max thumbnail size of 800x600, which is nice */
126+
margin-right: 110px;
127+
}
128+
}
129+
125130
.mx_EventTile_bubbleContainer {
126131
display: grid;
127132
grid-template-columns: 1fr 100px;

src/Searching.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ async function localSearch(searchTerm, roomId = undefined) {
8787
searchArgs.room_id = roomId;
8888
}
8989

90+
const emptyResult = {
91+
results: [],
92+
highlights: [],
93+
};
94+
95+
if (searchTerm === "") return emptyResult;
96+
9097
const eventIndex = EventIndexPeg.get();
9198

9299
const localResult = await eventIndex.search(searchArgs);
@@ -97,11 +104,6 @@ async function localSearch(searchTerm, roomId = undefined) {
97104
},
98105
};
99106

100-
const emptyResult = {
101-
results: [],
102-
highlights: [],
103-
};
104-
105107
const result = MatrixClientPeg.get()._processRoomEventsSearch(
106108
emptyResult, response);
107109

src/accessibility/KeyboardShortcuts.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,7 @@ export const toggleDialog = () => {
343343
},
344344
});
345345
};
346+
347+
export const registerShortcut = (category: Categories, defn: IShortcut) => {
348+
shortcuts[category].push(defn);
349+
};

src/components/structures/MessagePanel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ export default class MessagePanel extends React.Component {
523523
// if there is a previous event and it has the same sender as this event
524524
// and the types are the same/is in continuedTypes and the time between them is <= CONTINUATION_MAX_INTERVAL
525525
if (prevEvent !== null && prevEvent.sender && mxEv.sender && mxEv.sender.userId === prevEvent.sender.userId &&
526-
(mxEv.getType() === prevEvent.getType() || eventTypeContinues) &&
526+
// if we don't have tile for previous event then it was shown by showHiddenEvents and has no SenderProfile
527+
haveTileForEvent(prevEvent) && (mxEv.getType() === prevEvent.getType() || eventTypeContinues) &&
527528
(mxEv.getTs() - prevEvent.getTs() <= CONTINUATION_MAX_INTERVAL)) {
528529
continuation = true;
529530
}

src/components/structures/RoomView.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export default createReactClass({
131131
isAlone: false,
132132
isPeeking: false,
133133
showingPinned: false,
134+
showReadReceipts: true,
134135

135136
// error object, as from the matrix client/server API
136137
// If we failed to load information about the room,
@@ -179,11 +180,19 @@ export default createReactClass({
179180
this._onRoomViewStoreUpdate(true);
180181

181182
WidgetEchoStore.on('update', this._onWidgetEchoStoreUpdate);
183+
this._showReadReceiptsWatchRef = SettingsStore.watchSetting("showReadReceipts", null,
184+
this._onReadReceiptsChange);
182185

183186
this._roomView = createRef();
184187
this._searchResultsPanel = createRef();
185188
},
186189

190+
_onReadReceiptsChange: function() {
191+
this.setState({
192+
showReadReceipts: SettingsStore.getValue("showReadReceipts", this.state.roomId),
193+
});
194+
},
195+
187196
_onRoomViewStoreUpdate: function(initial) {
188197
if (this.unmounted) {
189198
return;
@@ -204,8 +213,10 @@ export default createReactClass({
204213
return;
205214
}
206215

216+
const roomId = RoomViewStore.getRoomId();
217+
207218
const newState = {
208-
roomId: RoomViewStore.getRoomId(),
219+
roomId,
209220
roomAlias: RoomViewStore.getRoomAlias(),
210221
roomLoading: RoomViewStore.isRoomLoading(),
211222
roomLoadError: RoomViewStore.getRoomLoadError(),
@@ -214,7 +225,8 @@ export default createReactClass({
214225
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
215226
forwardingEvent: RoomViewStore.getForwardingEvent(),
216227
shouldPeek: RoomViewStore.shouldPeek(),
217-
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", RoomViewStore.getRoomId()),
228+
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", roomId),
229+
showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId),
218230
};
219231

220232
// Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307
@@ -491,6 +503,11 @@ export default createReactClass({
491503

492504
WidgetEchoStore.removeListener('update', this._onWidgetEchoStoreUpdate);
493505

506+
if (this._showReadReceiptsWatchRef) {
507+
SettingsStore.unwatchSetting(this._showReadReceiptsWatchRef);
508+
this._showReadReceiptsWatchRef = null;
509+
}
510+
494511
// cancel any pending calls to the rate_limited_funcs
495512
this._updateRoomMembers.cancelPendingCall();
496513

@@ -1948,7 +1965,7 @@ export default createReactClass({
19481965
<TimelinePanel
19491966
ref={this._gatherTimelinePanelRef}
19501967
timelineSet={this.state.room.getUnfilteredTimelineSet()}
1951-
showReadReceipts={SettingsStore.getValue('showReadReceipts')}
1968+
showReadReceipts={this.state.showReadReceipts}
19521969
manageReadReceipts={!this.state.isPeeking}
19531970
manageReadMarkers={!this.state.isPeeking}
19541971
hidden={hideMessagePanel}
@@ -2003,6 +2020,10 @@ export default createReactClass({
20032020
? <RightPanel roomId={this.state.room.roomId} resizeNotifier={this.props.resizeNotifier} />
20042021
: null;
20052022

2023+
const timelineClasses = classNames("mx_RoomView_timeline", {
2024+
mx_RoomView_timeline_rr_enabled: this.state.showReadReceipts,
2025+
});
2026+
20062027
return (
20072028
<RoomContext.Provider value={this.state}>
20082029
<main className={"mx_RoomView" + (inCall ? " mx_RoomView_inCall" : "")} ref={this._roomView}>
@@ -2026,7 +2047,7 @@ export default createReactClass({
20262047
>
20272048
<div className={fadableSectionClasses}>
20282049
{auxPanel}
2029-
<div className="mx_RoomView_timeline">
2050+
<div className={timelineClasses}>
20302051
{topUnreadMessagesBar}
20312052
{jumpToBottom}
20322053
{messagePanel}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright 2016 OpenMarket Ltd
3+
Copyright 2017 Vector Creations Ltd
4+
Copyright 2019 New Vector Ltd
5+
Copyright 2019 Michael Telatynski <[email protected]>
6+
Copyright 2020 The Matrix.org Foundation C.I.C.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
*/
20+
21+
import React from 'react';
22+
import PropTypes from 'prop-types';
23+
import {MatrixClientPeg} from '../../../MatrixClientPeg';
24+
import * as sdk from '../../../index';
25+
import * as FormattingUtils from '../../../utils/FormattingUtils';
26+
import { _t } from '../../../languageHandler';
27+
28+
export default class ManualDeviceKeyVerificationDialog extends React.Component {
29+
static propTypes = {
30+
userId: PropTypes.string.isRequired,
31+
device: PropTypes.object.isRequired,
32+
onFinished: PropTypes.func.isRequired,
33+
};
34+
35+
_onCancelClick = () => {
36+
this.props.onFinished(false);
37+
}
38+
39+
_onLegacyFinished = (confirm) => {
40+
if (confirm) {
41+
MatrixClientPeg.get().setDeviceVerified(
42+
this.props.userId, this.props.device.deviceId, true,
43+
);
44+
}
45+
this.props.onFinished(confirm);
46+
}
47+
48+
render() {
49+
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
50+
51+
let text;
52+
if (MatrixClientPeg.get().getUserId() === this.props.userId) {
53+
text = _t("Confirm by comparing the following with the User Settings in your other session:");
54+
} else {
55+
text = _t("Confirm this user's session by comparing the following with their User Settings:");
56+
}
57+
58+
const key = FormattingUtils.formatCryptoKey(this.props.device.getFingerprint());
59+
const body = (
60+
<div>
61+
<p>
62+
{ text }
63+
</p>
64+
<div className="mx_DeviceVerifyDialog_cryptoSection">
65+
<ul>
66+
<li><label>{ _t("Session name") }:</label> <span>{ this.props.device.getDisplayName() }</span></li>
67+
<li><label>{ _t("Session ID") }:</label> <span><code>{ this.props.device.deviceId }</code></span></li>
68+
<li><label>{ _t("Session key") }:</label> <span><code><b>{ key }</b></code></span></li>
69+
</ul>
70+
</div>
71+
<p>
72+
{ _t("If they don't match, the security of your communication may be compromised.") }
73+
</p>
74+
</div>
75+
);
76+
77+
return (
78+
<QuestionDialog
79+
title={_t("Verify session")}
80+
description={body}
81+
button={_t("Verify session")}
82+
onFinished={this._onLegacyFinished}
83+
/>
84+
);
85+
}
86+
}

src/i18n/strings/en_EN.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@
294294
"Not Trusted": "Not Trusted",
295295
"%(name)s (%(userId)s) signed in to a new session without verifying it:": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
296296
"Ask this user to verify their session, or manually verify it below.": "Ask this user to verify their session, or manually verify it below.",
297+
"Manually Verify by Text": "Manually Verify by Text",
298+
"Interactively verify by Emoji": "Interactively verify by Emoji",
297299
"Done": "Done",
298-
"Manually Verify": "Manually Verify",
299300
"%(displayName)s is typing …": "%(displayName)s is typing …",
300301
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
301302
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
@@ -1613,6 +1614,9 @@
16131614
"Manually export keys": "Manually export keys",
16141615
"You'll lose access to your encrypted messages": "You'll lose access to your encrypted messages",
16151616
"Are you sure you want to sign out?": "Are you sure you want to sign out?",
1617+
"Confirm by comparing the following with the User Settings in your other session:": "Confirm by comparing the following with the User Settings in your other session:",
1618+
"Confirm this user's session by comparing the following with their User Settings:": "Confirm this user's session by comparing the following with their User Settings:",
1619+
"If they don't match, the security of your communication may be compromised.": "If they don't match, the security of your communication may be compromised.",
16161620
"Your homeserver doesn't seem to support this feature.": "Your homeserver doesn't seem to support this feature.",
16171621
"Message edits": "Message edits",
16181622
"Your account is not secure": "Your account is not secure",

src/verification.js

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,58 @@ async function enable4SIfNeeded() {
3939
return true;
4040
}
4141

42+
function UntrustedDeviceDialog(props) {
43+
const {device, user, onFinished} = props;
44+
const BaseDialog = sdk.getComponent("dialogs.BaseDialog");
45+
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
46+
return <BaseDialog
47+
onFinished={onFinished}
48+
headerImage={require("../res/img/e2e/warning.svg")}
49+
title={_t("Not Trusted")}>
50+
<div className="mx_Dialog_content" id='mx_Dialog_content'>
51+
<p>{_t("%(name)s (%(userId)s) signed in to a new session without verifying it:", {name: user.displayName, userId: user.userId})}</p>
52+
<p>{device.getDisplayName()} ({device.deviceId})</p>
53+
<p>{_t("Ask this user to verify their session, or manually verify it below.")}</p>
54+
</div>
55+
<div className='mx_Dialog_buttons'>
56+
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("legacy")}>{_t("Manually Verify by Text")}</AccessibleButton>
57+
<AccessibleButton element="button" kind="secondary" onClick={() => onFinished("sas")}>{_t("Interactively verify by Emoji")}</AccessibleButton>
58+
<AccessibleButton kind="primary" onClick={() => onFinished()}>{_t("Done")}</AccessibleButton>
59+
</div>
60+
</BaseDialog>;
61+
}
62+
4263
export async function verifyDevice(user, device) {
4364
if (!await enable4SIfNeeded()) {
4465
return;
4566
}
46-
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
47-
Modal.createTrackedDialog("Verification warning", "unverified session", QuestionDialog, {
48-
headerImage: require("../res/img/e2e/warning.svg"),
49-
title: _t("Not Trusted"),
50-
description: <div>
51-
<p>{_t("%(name)s (%(userId)s) signed in to a new session without verifying it:", {name: user.displayName, userId: user.userId})}</p>
52-
<p>{device.getDisplayName()} ({device.deviceId})</p>
53-
<p>{_t("Ask this user to verify their session, or manually verify it below.")}</p>
54-
</div>,
55-
onFinished: async (doneClicked) => {
56-
const manuallyVerifyClicked = !doneClicked;
57-
if (!manuallyVerifyClicked) {
58-
return;
67+
Modal.createTrackedDialog("Verification warning", "unverified session", UntrustedDeviceDialog, {
68+
user,
69+
device,
70+
onFinished: async (action) => {
71+
if (action === "sas") {
72+
const cli = MatrixClientPeg.get();
73+
const verificationRequestPromise = cli.legacyDeviceVerification(
74+
user.userId,
75+
device.deviceId,
76+
verificationMethods.SAS,
77+
);
78+
dis.dispatch({
79+
action: "set_right_panel_phase",
80+
phase: RIGHT_PANEL_PHASES.EncryptionPanel,
81+
refireParams: {member: user, verificationRequestPromise},
82+
});
83+
} else if (action === "legacy") {
84+
const ManualDeviceKeyVerificationDialog = sdk.getComponent("dialogs.ManualDeviceKeyVerificationDialog");
85+
Modal.createTrackedDialog("Legacy verify session", "legacy verify session",
86+
ManualDeviceKeyVerificationDialog,
87+
{
88+
userId: user.userId,
89+
device,
90+
},
91+
);
5992
}
60-
const cli = MatrixClientPeg.get();
61-
const verificationRequestPromise = cli.legacyDeviceVerification(
62-
user.userId,
63-
device.deviceId,
64-
verificationMethods.SAS,
65-
);
66-
dis.dispatch({
67-
action: "set_right_panel_phase",
68-
phase: RIGHT_PANEL_PHASES.EncryptionPanel,
69-
refireParams: {member: user, verificationRequestPromise},
70-
});
7193
},
72-
primaryButton: _t("Done"),
73-
cancelButton: _t("Manually Verify"),
7494
});
7595
}
7696

0 commit comments

Comments
 (0)