From e1a496f231619c7c2dde03f6b5be35cb9e89e4c2 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 9 Apr 2020 17:30:10 +0100 Subject: [PATCH 01/27] Pass along key backup for bootstrap If we ask for the key backup key early in creating secret storage to ensure we trust the backup, then we stash it to ensure it's available to bootstrap as well without prompting again. Fixes https://github.com/vector-im/riot-web/issues/12958 --- src/CrossSigningManager.js | 2 +- .../CreateSecretStorageDialog.js | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/CrossSigningManager.js b/src/CrossSigningManager.js index 1bcf1ba706..07ec776bd1 100644 --- a/src/CrossSigningManager.js +++ b/src/CrossSigningManager.js @@ -185,7 +185,7 @@ export async function promptForBackupPassphrase() { const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog'); const { finished } = Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, { - showSummary: false, keyCallback: k => key = k, + showSummary: false, keyCallback: k => key = k, }, null, /* priority = */ false, /* static = */ true); const success = await finished; diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index 01a2856df0..d63db617d5 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -70,6 +70,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { this._recoveryKey = null; this._recoveryKeyNode = null; this._setZxcvbnResultTimeout = null; + this._backupKey = null; this.state = { phase: PHASE_LOADING, @@ -243,7 +244,15 @@ export default class CreateSecretStorageDialog extends React.PureComponent { createSecretStorageKey: async () => this._recoveryKey, keyBackupInfo: this.state.backupInfo, setupNewKeyBackup: !this.state.backupInfo && this.state.useKeyBackup, - getKeyBackupPassphrase: promptForBackupPassphrase, + getKeyBackupPassphrase: () => { + // We may already have the backup key if we earlier went + // through the restore backup path, so pass it along + // rather than prompting again. + if (this._backupKey) { + return this._backupKey; + } + return promptForBackupPassphrase(); + }, }); } this.setState({ @@ -272,10 +281,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent { } _restoreBackup = async () => { + // It's possible we'll need the backup key later on for bootstrapping, + // so let's stash it here, rather than prompting for it twice. + const keyCallback = k => this._backupKey = k; + const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog'); const { finished } = Modal.createTrackedDialog( - 'Restore Backup', '', RestoreKeyBackupDialog, {showSummary: false}, null, - /* priority = */ false, /* static = */ false, + 'Restore Backup', '', RestoreKeyBackupDialog, + { + showSummary: false, + keyCallback, + }, + null, /* priority = */ false, /* static = */ false, ); await finished; From 34be024b21c2c52a2c77c74b084e8752e8c66d4d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 9 Apr 2020 14:47:20 -0600 Subject: [PATCH 02/27] Minimize widgets by default Fixes https://github.com/vector-im/riot-web/issues/12921 --- src/components/structures/RoomView.js | 11 +++-------- src/components/views/rooms/AppsDrawer.js | 6 ++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 90bf3a5a99..78bd34bf7f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -49,7 +49,6 @@ import RoomViewStore from '../../stores/RoomViewStore'; import RoomScrollStateStore from '../../stores/RoomScrollStateStore'; import WidgetEchoStore from '../../stores/WidgetEchoStore'; import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; -import WidgetUtils from '../../utils/WidgetUtils'; import AccessibleButton from "../views/elements/AccessibleButton"; import RightPanelStore from "../../stores/RightPanelStore"; import {haveTileForEvent} from "../views/rooms/EventTile"; @@ -406,13 +405,9 @@ export default createReactClass({ const hideWidgetDrawer = localStorage.getItem( room.roomId + "_hide_widget_drawer"); - if (hideWidgetDrawer === "true") { - return false; - } - - const widgets = WidgetEchoStore.getEchoedRoomWidgets(room.roomId, WidgetUtils.getRoomWidgets(room)); - - return widgets.length > 0 || WidgetEchoStore.roomHasPendingWidgets(room.roomId, WidgetUtils.getRoomWidgets(room)); + // This is confusing, but it means to say that we default to the tray being + // hidden unless the user clicked to open it. + return hideWidgetDrawer === "false"; }, componentDidMount: function() { diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index f7c5e8122f..b64eb33435 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -81,12 +81,14 @@ export default createReactClass({ const hideWidgetKey = this.props.room.roomId + '_hide_widget_drawer'; switch (action.action) { case 'appsDrawer': + // Note: these booleans are awkward because localstorage is fundamentally + // string-based. We also do exact equality on the strings later on. if (action.show) { - localStorage.removeItem(hideWidgetKey); + localStorage.setItem(hideWidgetKey, "false"); } else { // Store hidden state of widget // Don't show if previously hidden - localStorage.setItem(hideWidgetKey, true); + localStorage.setItem(hideWidgetKey, "true"); } break; From b4b0c4c6dfd944346e7ea82bc607e2f83fcf228a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 9 Apr 2020 15:14:07 -0600 Subject: [PATCH 03/27] Add comments to highlight where we'll need m.widget support For https://github.com/vector-im/riot-web/issues/13111 --- src/ScalarMessaging.js | 2 ++ src/TextForEvent.js | 1 + src/components/views/rooms/EventTile.js | 1 + .../views/settings/tabs/room/RolesRoomSettingsTab.js | 2 ++ src/stores/ActiveWidgetStore.js | 1 + src/utils/WidgetUtils.js | 7 +++++-- test/components/views/rooms/RoomSettings-test.js | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 2211e513c3..ca8ca103e1 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -172,6 +172,7 @@ Request: Response: [ { + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) type: "im.vector.modular.widgets", state_key: "wid1", content: { @@ -190,6 +191,7 @@ Example: room_id: "!foo:bar", response: [ { + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) type: "im.vector.modular.widgets", state_key: "wid1", content: { diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 6b1c1dcd2d..3607d7a676 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -603,6 +603,7 @@ const stateHandlers = { 'm.room.guest_access': textForGuestAccessEvent, 'm.room.related_groups': textForRelatedGroupsEvent, + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) 'im.vector.modular.widgets': textForWidgetEvent, }; diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index aed2d4b25b..75fbe5caa3 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -59,6 +59,7 @@ const stateEventTileTypes = { 'm.room.power_levels': 'messages.TextualEvent', 'm.room.pinned_events': 'messages.TextualEvent', 'm.room.server_acl': 'messages.TextualEvent', + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) 'im.vector.modular.widgets': 'messages.TextualEvent', 'm.room.tombstone': 'messages.TextualEvent', 'm.room.join_rules': 'messages.TextualEvent', diff --git a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js index a3a9cb78c5..b812bb6b68 100644 --- a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js @@ -33,6 +33,7 @@ const plEventsToLabels = { "m.room.tombstone": _td("Upgrade the room"), "m.room.encryption": _td("Enable room encryption"), + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) "im.vector.modular.widgets": _td("Modify widgets"), }; @@ -47,6 +48,7 @@ const plEventsToShow = { "m.room.tombstone": {isState: true}, "m.room.encryption": {isState: true}, + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) "im.vector.modular.widgets": {isState: true}, }; diff --git a/src/stores/ActiveWidgetStore.js b/src/stores/ActiveWidgetStore.js index 60ea3f9106..c6f8dc69b7 100644 --- a/src/stores/ActiveWidgetStore.js +++ b/src/stores/ActiveWidgetStore.js @@ -64,6 +64,7 @@ class ActiveWidgetStore extends EventEmitter { // Everything else relies on views listening for events and calling setters // on this class which is terrible. This store should just listen for events // and keep itself up to date. + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) if (ev.getType() !== 'im.vector.modular.widgets') return; if (ev.getStateKey() === this._persistentWidgetId) { diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 9fb6358c1f..6768119d8f 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -66,6 +66,7 @@ export default class WidgetUtils { return false; } + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) return room.currentState.maySendStateEvent('im.vector.modular.widgets', me); } @@ -180,6 +181,7 @@ export default class WidgetUtils { } const room = MatrixClientPeg.get().getRoom(roomId); + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) const startingWidgetEvents = room.currentState.getStateEvents('im.vector.modular.widgets'); if (eventsInIntendedState(startingWidgetEvents)) { resolve(); @@ -189,6 +191,7 @@ export default class WidgetUtils { function onRoomStateEvents(ev) { if (ev.getRoomId() !== roomId) return; + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) const currentWidgetEvents = room.currentState.getStateEvents('im.vector.modular.widgets'); if (eventsInIntendedState(currentWidgetEvents)) { @@ -268,8 +271,7 @@ export default class WidgetUtils { WidgetEchoStore.setRoomWidgetEcho(roomId, widgetId, content); const client = MatrixClientPeg.get(); - // TODO - Room widgets need to be moved to 'm.widget' state events - // https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) return client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).then(() => { return WidgetUtils.waitForRoomWidget(widgetId, roomId, addingWidget); }).finally(() => { @@ -283,6 +285,7 @@ export default class WidgetUtils { * @return {[object]} Array containing current / active room widgets */ static getRoomWidgets(room) { + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) const appsStateEvents = room.currentState.getStateEvents('im.vector.modular.widgets'); if (!appsStateEvents) { return []; diff --git a/test/components/views/rooms/RoomSettings-test.js b/test/components/views/rooms/RoomSettings-test.js index 5e21f729d0..b3790b2507 100644 --- a/test/components/views/rooms/RoomSettings-test.js +++ b/test/components/views/rooms/RoomSettings-test.js @@ -177,6 +177,7 @@ describe.skip('RoomSettings', () => { 'm.room.history_visibility': 50, 'm.room.power_levels': 50, 'm.room.topic': 50, + // TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111) 'im.vector.modular.widgets': 50, }, }, From 879b4e15e56aa54e621c069282e19162e9631578 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 9 Apr 2020 16:18:12 -0600 Subject: [PATCH 04/27] Use singular text on 'delete sessions' button for SSO Missed in https://github.com/matrix-org/matrix-react-sdk/pull/4357 Not a release blocker at this time. --- src/components/views/settings/DevicesPanel.js | 2 +- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/DevicesPanel.js b/src/components/views/settings/DevicesPanel.js index e097ef9e47..fe4a4abfdc 100644 --- a/src/components/views/settings/DevicesPanel.js +++ b/src/components/views/settings/DevicesPanel.js @@ -139,7 +139,7 @@ export default class DevicesPanel extends React.Component { body: _t("Click the button below to confirm deleting these sessions.", { count: numDevices, }), - continueText: _t("Delete sessions"), + continueText: _t("Delete sessions", {count: numDevices}), continueKind: "danger", }, }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 067d5d8eee..ae8ed90402 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -618,7 +618,8 @@ "Confirm deleting these sessions": "Confirm deleting these sessions", "Click the button below to confirm deleting these sessions.|other": "Click the button below to confirm deleting these sessions.", "Click the button below to confirm deleting these sessions.|one": "Click the button below to confirm deleting this session.", - "Delete sessions": "Delete sessions", + "Delete sessions|other": "Delete sessions", + "Delete sessions|one": "Delete session", "Authentication": "Authentication", "Delete %(count)s sessions|other": "Delete %(count)s sessions", "Delete %(count)s sessions|one": "Delete %(count)s session", From 740b6f6cac91d3beff5658b1411b33311e68e947 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 10 Apr 2020 09:30:19 +0100 Subject: [PATCH 05/27] Composer pills respect showPillAvatar setting Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/rooms/_BasicMessageComposer.scss | 42 ++++++++++--------- .../views/rooms/BasicMessageComposer.js | 28 +++++++++---- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/res/css/views/rooms/_BasicMessageComposer.scss b/res/css/views/rooms/_BasicMessageComposer.scss index cc76623a8c..e9013eb7b7 100644 --- a/res/css/views/rooms/_BasicMessageComposer.scss +++ b/res/css/views/rooms/_BasicMessageComposer.scss @@ -44,27 +44,29 @@ limitations under the License. outline: none; overflow-x: hidden; - span.mx_UserPill, span.mx_RoomPill { - padding-left: 21px; - position: relative; + &.mx_BasicMessageComposer_input_shouldShowPillAvatar { + span.mx_UserPill, span.mx_RoomPill { + padding-left: 21px; + position: relative; - // avatar psuedo element - &::before { - position: absolute; - left: 2px; - top: 2px; - content: var(--avatar-letter); - width: 16px; - height: 16px; - background: var(--avatar-background), $avatar-bg-color; - color: $avatar-initial-color; - background-repeat: no-repeat; - background-size: 16px; - border-radius: 8px; - text-align: center; - font-weight: normal; - line-height: $font-16px; - font-size: $font-10-4px; + // avatar psuedo element + &::before { + position: absolute; + left: 2px; + top: 2px; + content: var(--avatar-letter); + width: 16px; + height: 16px; + background: var(--avatar-background), $avatar-bg-color; + color: $avatar-initial-color; + background-repeat: no-repeat; + background-size: 16px; + border-radius: 8px; + text-align: center; + font-weight: normal; + line-height: $font-16px; + font-size: $font-10-4px; + } } } } diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index e3cffd59f8..880bc352de 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -84,6 +84,7 @@ export default class BasicMessageEditor extends React.Component { super(props); this.state = { autoComplete: null, + showPillAvatar: SettingsStore.getValue("Pill.shouldShowPillAvatar"), }; this._editorRef = null; this._autocompleteRef = null; @@ -92,6 +93,7 @@ export default class BasicMessageEditor extends React.Component { this._isIMEComposing = false; this._hasTextSelected = false; this._emoticonSettingHandle = null; + this._shouldShowPillAvatarSettingHandle = null; } componentDidUpdate(prevProps) { @@ -508,10 +510,15 @@ export default class BasicMessageEditor extends React.Component { this.setState({completionIndex}); } - _configureEmoticonAutoReplace() { + _configureEmoticonAutoReplace = () => { const shouldReplace = SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji'); this.props.model.setTransformCallback(shouldReplace ? this._replaceEmoticon : null); - } + }; + + _configureShouldShowPillAvatar = () => { + const showPillAvatar = SettingsStore.getValue("Pill.shouldShowPillAvatar"); + this.setState({ showPillAvatar }); + }; componentWillUnmount() { document.removeEventListener("selectionchange", this._onSelectionChange); @@ -519,15 +526,17 @@ export default class BasicMessageEditor extends React.Component { this._editorRef.removeEventListener("compositionstart", this._onCompositionStart, true); this._editorRef.removeEventListener("compositionend", this._onCompositionEnd, true); SettingsStore.unwatchSetting(this._emoticonSettingHandle); + SettingsStore.unwatchSetting(this._shouldShowPillAvatarSettingHandle); } componentDidMount() { const model = this.props.model; model.setUpdateCallback(this._updateEditorState); - this._emoticonSettingHandle = SettingsStore.watchSetting('MessageComposerInput.autoReplaceEmoji', null, () => { - this._configureEmoticonAutoReplace(); - }); + this._emoticonSettingHandle = SettingsStore.watchSetting('MessageComposerInput.autoReplaceEmoji', null, + this._configureEmoticonAutoReplace); this._configureEmoticonAutoReplace(); + this._shouldShowPillAvatarSettingHandle = SettingsStore.watchSetting("Pill.shouldShowPillAvatar", null, + this._configureShouldShowPillAvatar); const partCreator = model.partCreator; // TODO: does this allow us to get rid of EditorStateTransfer? // not really, but we could not serialize the parts, and just change the autoCompleter @@ -605,9 +614,12 @@ export default class BasicMessageEditor extends React.Component { /> ); } - const classes = classNames("mx_BasicMessageComposer", { + const wrapperClasses = classNames("mx_BasicMessageComposer", { "mx_BasicMessageComposer_input_error": this.state.showVisualBell, }); + const classes = classNames("mx_BasicMessageComposer_input", { + "mx_BasicMessageComposer_input_shouldShowPillAvatar": this.state.showPillAvatar, + }); const MessageComposerFormatBar = sdk.getComponent('rooms.MessageComposerFormatBar'); const shortcuts = { @@ -618,11 +630,11 @@ export default class BasicMessageEditor extends React.Component { const {completionIndex} = this.state; - return (
+ return (
{ autoComplete } this._formatBarRef = ref} onAction={this._onFormatAction} shortcuts={shortcuts} />
Date: Fri, 10 Apr 2020 13:59:01 +0100 Subject: [PATCH 06/27] Only send typing notification when composing commands which send messages Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/SlashCommands.tsx | 27 +++++++++++-------- .../views/rooms/BasicMessageComposer.js | 12 ++++++++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index d60434cf97..aac42b6740 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -914,7 +914,7 @@ export const Commands = [ // Command definitions for autocompletion ONLY: // /me is special because its not handled by SlashCommands.js and is instead done inside the Composer classes new Command({ - command: 'me', + command: "me", args: '', description: _td('Displays action'), category: CommandCategories.messages, @@ -931,16 +931,7 @@ Commands.forEach(cmd => { }); }); - -/** - * Process the given text for /commands and return a bound method to perform them. - * @param {string} roomId The room in which the command was performed. - * @param {string} input The raw text input by the user. - * @return {null|function(): Object} Function returning an object with the property 'error' if there was an error - * processing the command, or 'promise' if a request was sent out. - * Returns null if the input didn't match a command. - */ -export function getCommand(roomId, input) { +export function parseCommandString(input) { // trim any trailing whitespace, as it can confuse the parser for // IRC-style commands input = input.replace(/\s+$/, ''); @@ -956,6 +947,20 @@ export function getCommand(roomId, input) { cmd = input; } + return {cmd, args}; +} + +/** + * Process the given text for /commands and return a bound method to perform them. + * @param {string} roomId The room in which the command was performed. + * @param {string} input The raw text input by the user. + * @return {null|function(): Object} Function returning an object with the property 'error' if there was an error + * processing the command, or 'promise' if a request was sent out. + * Returns null if the input didn't match a command. + */ +export function getCommand(roomId, input) { + const {cmd, args} = parseCommandString(input); + if (CommandMap.has(cmd)) { return () => CommandMap.get(cmd).run(roomId, args, cmd); } diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index e3cffd59f8..bbfc2780e8 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -39,6 +39,7 @@ import EMOTICON_REGEX from 'emojibase-regex/emoticon'; import * as sdk from '../../../index'; import {Key} from "../../../Keyboard"; import {EMOTICON_TO_EMOJI} from "../../../emoji"; +import {CommandCategories, CommandMap, parseCommandString} from "../../../SlashCommands"; const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s$'); @@ -162,7 +163,16 @@ export default class BasicMessageEditor extends React.Component { } this.setState({autoComplete: this.props.model.autoComplete}); this.historyManager.tryPush(this.props.model, selection, inputType, diff); - TypingStore.sharedInstance().setSelfTyping(this.props.room.roomId, !this.props.model.isEmpty); + + let isTyping = !this.props.model.isEmpty; + // If the user is entering a command, only consider them typing if it is one which sends a message into the room + if (isTyping && this.props.model.parts[0].type === "command") { + const {cmd} = parseCommandString(this.props.model.parts[0].text); + if (CommandMap.get(cmd).category !== CommandCategories.messages) { + isTyping = false; + } + } + TypingStore.sharedInstance().setSelfTyping(this.props.room.roomId, isTyping); if (this.props.onChange) { this.props.onChange(); From 22558f090de18599cdac83d8ff3d19fa6498f22a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 10 Apr 2020 15:38:17 +0100 Subject: [PATCH 07/27] Reverse order of they match/they don't match buttons Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/verification/VerificationShowSas.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/verification/VerificationShowSas.js b/src/components/views/verification/VerificationShowSas.js index 5fd0dca267..0a8947f2c2 100644 --- a/src/components/views/verification/VerificationShowSas.js +++ b/src/components/views/verification/VerificationShowSas.js @@ -132,12 +132,12 @@ export default class VerificationShowSas extends React.Component { />; } else { confirm = - - { _t("They match") } - { _t("They don't match") } + + { _t("They match") } + ; } From 6d33138950d68843af1d9a756a3fd1df98cb71f6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 11 Apr 2020 16:41:07 +0100 Subject: [PATCH 08/27] op/deop return error if trying to affect an unknown user Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/SlashCommands.tsx | 8 +++++--- src/i18n/strings/en_EN.json | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index aac42b6740..71815dde8c 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -350,7 +350,7 @@ export const Commands = [ return success(cli.setRoomTopic(roomId, args)); } const room = cli.getRoom(roomId); - if (!room) return reject('Bad room ID: ' + roomId); + if (!room) return reject(_t("Failed to set topic")); const topicEvents = room.currentState.getStateEvents('m.room.topic', ''); const topic = topicEvents && topicEvents.getContent().topic; @@ -721,9 +721,10 @@ export const Commands = [ if (!isNaN(powerLevel)) { const cli = MatrixClientPeg.get(); const room = cli.getRoom(roomId); - if (!room) return reject('Bad room ID: ' + roomId); + if (!room) return reject(_t("Command failed")); const powerLevelEvent = room.currentState.getStateEvents('m.room.power_levels', ''); + if (!powerLevelEvent.getContent().users[args]) return reject(_t("Could not find user in room")); return success(cli.setPowerLevel(roomId, userId, powerLevel, powerLevelEvent)); } } @@ -742,9 +743,10 @@ export const Commands = [ if (matches) { const cli = MatrixClientPeg.get(); const room = cli.getRoom(roomId); - if (!room) return reject('Bad room ID: ' + roomId); + if (!room) return reject(_t("Command failed")); const powerLevelEvent = room.currentState.getStateEvents('m.room.power_levels', ''); + if (!powerLevelEvent.getContent().users[args]) return reject(_t("Could not find user in room")); return success(cli.setPowerLevel(roomId, args, undefined, powerLevelEvent)); } } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ae8ed90402..51a2a59672 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -177,6 +177,7 @@ "Changes your avatar in this current room only": "Changes your avatar in this current room only", "Changes your avatar in all rooms": "Changes your avatar in all rooms", "Gets or sets the room topic": "Gets or sets the room topic", + "Failed to set topic": "Failed to set topic", "This room has no topic.": "This room has no topic.", "Sets the room name": "Sets the room name", "Invites user with given id to current room": "Invites user with given id to current room", @@ -196,6 +197,8 @@ "Unignored user": "Unignored user", "You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s", "Define the power level of a user": "Define the power level of a user", + "Command failed": "Command failed", + "Could not find user in room": "Could not find user in room", "Deops user with given id": "Deops user with given id", "Opens the Developer Tools dialog": "Opens the Developer Tools dialog", "Adds a custom widget by URL to the room": "Adds a custom widget by URL to the room", From 7a936798b948d8207735c958b1cbffde19601bf1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 11 Apr 2020 16:42:14 +0100 Subject: [PATCH 09/27] Fix invalid commands when figuring out whether to send typing notification Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/BasicMessageComposer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index a9389400ef..2e4a966404 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -170,7 +170,7 @@ export default class BasicMessageEditor extends React.Component { // If the user is entering a command, only consider them typing if it is one which sends a message into the room if (isTyping && this.props.model.parts[0].type === "command") { const {cmd} = parseCommandString(this.props.model.parts[0].text); - if (CommandMap.get(cmd).category !== CommandCategories.messages) { + if (!CommandMap.has(cmd) || CommandMap.get(cmd).category !== CommandCategories.messages) { isTyping = false; } } From 3a0e1aeeaf75ce74f3b837ae720d21aa1ef8714c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 11 Apr 2020 18:09:28 +0100 Subject: [PATCH 10/27] Sort emoji by shortcodes for autocomplete so that :-1 and :+1 first results are correct Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/autocomplete/EmojiProvider.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/autocomplete/EmojiProvider.js b/src/autocomplete/EmojiProvider.js index 9373ed662e..76058b42b0 100644 --- a/src/autocomplete/EmojiProvider.js +++ b/src/autocomplete/EmojiProvider.js @@ -100,6 +100,10 @@ export default class EmojiProvider extends AutocompleteProvider { // then sort by score (Infinity if matchedString not in shortname) sorters.push((c) => score(matchedString, c.shortname)); + // then sort by max score of all shortcodes, trim off the `:` + sorters.push((c) => { + return Math.min.apply(null, c.emoji.shortcodes.map(s => score(matchedString.substring(1), s))); + }); // If the matchedString is not empty, sort by length of shortname. Example: // matchedString = ":bookmark" // completions = [":bookmark:", ":bookmark_tabs:", ...] From 7e996cb91c9d6af8bfffd1782b51c6bff75075da Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 11 Apr 2020 18:57:59 +0100 Subject: [PATCH 11/27] Add riot-desktop shortcuts for forward/back matching browsers&slack Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.js | 4 ++++ src/Keyboard.ts | 2 ++ src/components/structures/LoggedInView.js | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 5d809eb28f..7214031586 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -188,4 +188,8 @@ export default class BasePlatform { const callbackUrl = this.getSSOCallbackUrl(mxClient.getHomeserverUrl(), mxClient.getIdentityServerUrl()); window.location.href = mxClient.getSsoLoginUrl(callbackUrl.toString(), loginType); // redirect to SSO } + + onKeyDown(ev: KeyboardEvent): boolean { + return false; // no shortcuts implemented + } } diff --git a/src/Keyboard.ts b/src/Keyboard.ts index 23e2bbf0d6..7040898872 100644 --- a/src/Keyboard.ts +++ b/src/Keyboard.ts @@ -43,6 +43,8 @@ export const Key = { BACKTICK: "`", SPACE: " ", SLASH: "/", + SQUARE_BRACKET_LEFT: "[", + SQUARE_BRACKET_RIGHT: "]", A: "a", B: "b", C: "c", diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index d9980aeca6..fe59a6a8f1 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -40,6 +40,7 @@ import {Resizer, CollapseDistributor} from '../../resizer'; import MatrixClientContext from "../../contexts/MatrixClientContext"; import * as KeyboardShortcuts from "../../accessibility/KeyboardShortcuts"; import HomePage from "./HomePage"; +import PlatformPeg from "../../PlatformPeg"; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. // NB. this is just for server notices rather than pinned messages in general. @@ -407,6 +408,11 @@ const LoggedInView = createReactClass({ }); handled = true; } + break; + + default: + // if we do not have a handler for it, pass it to the platform which might + handled = PlatformPeg.get().onKeyDown(ev); } if (handled) { From 71b4aab5dcb9edfd5bc5834a3ade66efd4d58fa2 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 12 Apr 2020 00:12:58 +0100 Subject: [PATCH 12/27] Fix emoji tooltip flickering because onMouseOut&onMouseOver fired when moving between children Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/messages/_ReactionsRowButton.scss | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/res/css/views/messages/_ReactionsRowButton.scss b/res/css/views/messages/_ReactionsRowButton.scss index 941153ca5b..fe5b081042 100644 --- a/res/css/views/messages/_ReactionsRowButton.scss +++ b/res/css/views/messages/_ReactionsRowButton.scss @@ -34,12 +34,17 @@ limitations under the License. background-color: $reaction-row-button-selected-bg-color; border-color: $reaction-row-button-selected-border-color; } -} -.mx_ReactionsRowButton_content { - max-width: 100px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - padding-right: 4px; + // ignore mouse events for all children, treat it as one entire hoverable entity + * { + pointer-events: none; + } + + .mx_ReactionsRowButton_content { + max-width: 100px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + padding-right: 4px; + } } From 3e057070fd50391a1ec8453afd8af88ce14db49a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 12 Apr 2020 00:56:21 +0100 Subject: [PATCH 13/27] Fix width of MVideoBody in FilePanel Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- res/css/_components.scss | 1 + res/css/views/messages/_MVideoBody.scss | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 res/css/views/messages/_MVideoBody.scss diff --git a/res/css/_components.scss b/res/css/_components.scss index 8706772ad9..0ba2b609e8 100644 --- a/res/css/_components.scss +++ b/res/css/_components.scss @@ -133,6 +133,7 @@ @import "./views/messages/_MNoticeBody.scss"; @import "./views/messages/_MStickerBody.scss"; @import "./views/messages/_MTextBody.scss"; +@import "./views/messages/_MVideoBody.scss"; @import "./views/messages/_MessageActionBar.scss"; @import "./views/messages/_MessageTimestamp.scss"; @import "./views/messages/_MjolnirBody.scss"; diff --git a/res/css/views/messages/_MVideoBody.scss b/res/css/views/messages/_MVideoBody.scss new file mode 100644 index 0000000000..db044aba03 --- /dev/null +++ b/res/css/views/messages/_MVideoBody.scss @@ -0,0 +1,22 @@ +/* +Copyright 2020 New Vector Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +span.mx_MVideoBody { + video.mx_MVideoBody { + max-width: 100%; + height: auto; + } +} From 4fc88d69a325c7de018804cff2ba3d980fa8beeb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 12 Apr 2020 01:04:54 +0100 Subject: [PATCH 14/27] Remove unused react-addons-css-transition-group Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 1 - yarn.lock | 234 +++------------------------------------------------ 2 files changed, 12 insertions(+), 223 deletions(-) diff --git a/package.json b/package.json index 616f3f541e..7ba69c4272 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,6 @@ "qrcode-react": "^0.1.16", "qs": "^6.6.0", "react": "^16.9.0", - "react-addons-css-transition-group": "15.6.2", "react-beautiful-dnd": "^4.0.1", "react-dom": "^16.9.0", "react-focus-lock": "^2.2.1", diff --git a/yarn.lock b/yarn.lock index 538a049bff..c42828e461 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1496,11 +1496,6 @@ abab@^2.0.0: resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a" integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg== -abbrev@1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - acorn-globals@^4.1.0: version "4.3.4" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7" @@ -1634,19 +1629,11 @@ anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" -aproba@^1.0.3, aproba@^1.1.1: +aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== -are-we-there-yet@~1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" - integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== - dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" - argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -2283,11 +2270,6 @@ ccount@^1.0.0: resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.5.tgz#ac82a944905a65ce204eb03023157edf29425c17" integrity sha512-MOli1W+nfbPLlKEhInaxhRdp7KVLFxLN5ykwzHgLsLI3H3gs5jjFAK4Eoj3OzzcxCtumDaI8onoVDeQyWaNTkw== -chain-function@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.1.tgz#c63045e5b4b663fb86f1c6e186adaf1de402a1cc" - integrity sha512-SxltgMwL9uCko5/ZCLiyG2B7R9fY4pDZUw7hJ4MhirdjBLosoDqkWABi3XMucddHdLiFJMb7PD2MZifZriuMTg== - chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -2553,11 +2535,6 @@ console-browserify@^1.1.0: resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= - constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" @@ -2803,7 +2780,7 @@ debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@^3.1.0, debug@^3.2.6: +debug@^3.1.0: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== @@ -2879,11 +2856,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - des.js@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" @@ -2897,11 +2869,6 @@ detect-file@^1.0.0: resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detect-newline@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" @@ -2975,13 +2942,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dom-helpers@^3.2.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.4.0.tgz#e9b369700f959f62ecde5a6babde4bccd9169af8" - integrity sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA== - dependencies: - "@babel/runtime" "^7.1.2" - dom-serializer@0, dom-serializer@^0.2.1: version "0.2.2" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.2.2.tgz#1afb81f533717175d478655debc5e332d9f9bb51" @@ -3916,13 +3876,6 @@ from2@^2.1.0: inherits "^2.0.1" readable-stream "^2.0.0" -fs-minipass@^1.2.5: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - fs-readdir-recursive@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" @@ -3985,20 +3938,6 @@ fuse.js@^2.2.0: resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-2.7.4.tgz#96e420fde7ef011ac49c258a621314fe576536f9" integrity sha1-luQg/efvARrEnCWKYhMU/ldlNvk= -gauge@~2.7.3: - version "2.7.4" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" - gensync@^1.0.0-beta.1: version "1.0.0-beta.1" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" @@ -4196,11 +4135,6 @@ has-symbols@^1.0.0, has-symbols@^1.0.1: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= - has-value@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" @@ -4388,7 +4322,7 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -4405,13 +4339,6 @@ iferr@^0.1.5: resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= -ignore-walk@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" - integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== - dependencies: - minimatch "^3.0.4" - ignore@^4.0.3, ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -5975,21 +5902,6 @@ minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5, "minimist@~ 1.2.0": resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.2.1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - mississippi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" @@ -6014,7 +5926,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.3: +mkdirp@^0.5.1, mkdirp@^0.5.3: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -6091,15 +6003,6 @@ nearley@^2.7.10: randexp "0.4.6" semver "^5.4.1" -needle@^2.2.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.4.1.tgz#14af48732463d7475696f937626b1b993247a56a" - integrity sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - neo-async@^2.5.0, neo-async@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" @@ -6177,35 +6080,11 @@ node-notifier@^5.4.2: shellwords "^0.1.1" which "^1.3.0" -node-pre-gyp@*: - version "0.14.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" - integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-releases@^1.1.53: version "1.1.53" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.53.tgz#2d821bfa499ed7c5dffc5e2f28c88e78a08ee3f4" integrity sha512-wp8zyQVwef2hpZ/dJH7SfSrIPD6YoJz6BDQDpGEkcA0s3LpAQoxBIYmfIq6QAhC1DhwsyCgTaTTcONwX8qzCuQ== -nopt@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" - integrity sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg== - dependencies: - abbrev "1" - osenv "^0.1.4" - normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" @@ -6238,27 +6117,6 @@ normalize-selector@^0.2.0: resolved "https://registry.yarnpkg.com/normalize-selector/-/normalize-selector-0.2.0.tgz#d0b145eb691189c63a78d201dc4fdb1293ef0c03" integrity sha1-0LFF62kRicY6eNIB3E/bEpPvDAM= -npm-bundled@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" - integrity sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^1.1.6: - version "1.4.8" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" - integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-normalize-package-bin "^1.0.1" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -6266,16 +6124,6 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -npmlog@^4.0.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" - integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - nth-check@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c" @@ -6425,11 +6273,6 @@ os-browserify@^0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= - os-locale@^3.0.0, os-locale@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" @@ -6439,19 +6282,11 @@ os-locale@^3.0.0, os-locale@^3.1.0: lcid "^2.0.0" mem "^4.0.0" -os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: +os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" - integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -6923,7 +6758,7 @@ prop-types-exact@^1.2.0: object.assign "^4.1.0" reflect.ownkeys "^0.2.0" -prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: +prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== @@ -7096,7 +6931,7 @@ randomfill@^1.0.3: randombytes "^2.0.5" safe-buffer "^5.1.0" -rc@1.2.8, rc@^1.2.7, rc@^1.2.8: +rc@1.2.8, rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -7106,13 +6941,6 @@ rc@1.2.8, rc@^1.2.7, rc@^1.2.8: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-addons-css-transition-group@15.6.2: - version "15.6.2" - resolved "https://registry.yarnpkg.com/react-addons-css-transition-group/-/react-addons-css-transition-group-15.6.2.tgz#9e4376bcf40b5217d14ec68553081cee4b08a6d6" - integrity sha1-nkN2vPQLUhfRTsaFUwgc7ksIptY= - dependencies: - react-transition-group "^1.2.0" - react-beautiful-dnd@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/react-beautiful-dnd/-/react-beautiful-dnd-4.0.1.tgz#3b0a49bf6be75af351176c904f012611dd292b81" @@ -7200,17 +7028,6 @@ react-test-renderer@^16.0.0-0, react-test-renderer@^16.9.0: react-is "^16.8.6" scheduler "^0.19.1" -react-transition-group@^1.2.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-1.2.1.tgz#e11f72b257f921b213229a774df46612346c7ca6" - integrity sha512-CWaL3laCmgAFdxdKbhhps+c0HRGF4c+hdM4H23+FI1QBNUyx/AMeIJGWorehPNSaKnQNOAxL7PQmqMu78CDj3Q== - dependencies: - chain-function "^1.0.0" - dom-helpers "^3.2.0" - loose-envify "^1.3.1" - prop-types "^15.5.6" - warning "^3.0.0" - react@^16.9.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e" @@ -7254,7 +7071,7 @@ read-pkg@^4.0.1: parse-json "^4.0.0" pify "^3.0.0" -"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -7614,7 +7431,7 @@ rimraf@2.6.3: dependencies: glob "^7.1.3" -rimraf@^2.4.3, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3: +rimraf@^2.4.3, rimraf@^2.5.4, rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -7776,7 +7593,7 @@ serialize-javascript@^2.1.2: resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ== -set-blocking@^2.0.0, set-blocking@~2.0.0: +set-blocking@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= @@ -8112,7 +7929,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -8393,19 +8210,6 @@ tapable@^1.0.0, tapable@^1.1.3: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tar@^4.4.2: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" - terser-webpack-plugin@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c" @@ -8964,13 +8768,6 @@ walker@^1.0.7, walker@~1.0.5: dependencies: makeerror "1.0.x" -warning@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c" - integrity sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w= - dependencies: - loose-envify "^1.0.0" - watchpack@^1.6.0: version "1.6.1" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.1.tgz#280da0a8718592174010c078c7585a74cd8cd0e2" @@ -9128,13 +8925,6 @@ which@^1.2.14, which@^1.2.9, which@^1.3.0, which@^1.3.1: dependencies: isexe "^2.0.0" -wide-align@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== - dependencies: - string-width "^1.0.2 || 2" - word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" @@ -9219,7 +9009,7 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: +yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== From 379aeb667ce4a80941808091634186d7d1bac67c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 13 Apr 2020 14:13:27 +0100 Subject: [PATCH 15/27] Convert LoggedInView to a PureComponent class Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.js | 120 +++++++++++----------- 1 file changed, 59 insertions(+), 61 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index d9980aeca6..36beec3f6c 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -1,7 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd -Copyright 2017, 2018 New Vector Ltd +Copyright 2017, 2018, 2020 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,8 +17,7 @@ limitations under the License. */ import { MatrixClient } from 'matrix-js-sdk'; -import React, {createRef} from 'react'; -import createReactClass from 'create-react-class'; +import React, {createRef, PureComponent} from 'react'; import PropTypes from 'prop-types'; import { DragDropContext } from 'react-beautiful-dnd'; @@ -61,10 +60,10 @@ function canElementReceiveInput(el) { * * Components mounted below us can access the matrix client via the react context. */ -const LoggedInView = createReactClass({ - displayName: 'LoggedInView', +class LoggedInView extends PureComponent { + static displayName = 'LoggedInView'; - propTypes: { + static propTypes = { matrixClient: PropTypes.instanceOf(MatrixClient).isRequired, page_type: PropTypes.string.isRequired, onRoomCreated: PropTypes.func, @@ -77,25 +76,18 @@ const LoggedInView = createReactClass({ viaServers: PropTypes.arrayOf(PropTypes.string), // and lots and lots of other stuff. - }, + }; - getInitialState: function() { - return { + constructor(props, context) { + super(props, context); + + this.state = { // use compact timeline view useCompactLayout: SettingsStore.getValue('useCompactLayout'), // any currently active server notice events serverNoticeEvents: [], }; - }, - componentDidMount: function() { - this.resizer = this._createResizer(); - this.resizer.attach(); - this._loadResizerPreferences(); - }, - - // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs - UNSAFE_componentWillMount: function() { // stash the MatrixClient in case we log out before we are unmounted this._matrixClient = this.props.matrixClient; @@ -118,7 +110,13 @@ const LoggedInView = createReactClass({ fixupColorFonts(); this._roomView = createRef(); - }, + } + + componentDidMount() { + this.resizer = this._createResizer(); + this.resizer.attach(); + this._loadResizerPreferences(); + } componentDidUpdate(prevProps) { // attempt to guess when a banner was opened or closed @@ -130,9 +128,9 @@ const LoggedInView = createReactClass({ ) { this.props.resizeNotifier.notifyBannersChanged(); } - }, + } - componentWillUnmount: function() { + componentWillUnmount() { document.removeEventListener('keydown', this._onNativeKeyDown, false); this._matrixClient.removeListener("accountData", this.onAccountData); this._matrixClient.removeListener("sync", this.onSync); @@ -141,7 +139,7 @@ const LoggedInView = createReactClass({ this._sessionStoreToken.remove(); } this.resizer.detach(); - }, + } // Child components assume that the client peg will not be null, so give them some // sort of assurance here by only allowing a re-render if the client is truthy. @@ -149,22 +147,22 @@ const LoggedInView = createReactClass({ // This is required because `LoggedInView` maintains its own state and if this state // updates after the client peg has been made null (during logout), then it will // attempt to re-render and the children will throw errors. - shouldComponentUpdate: function() { + shouldComponentUpdate() { return Boolean(MatrixClientPeg.get()); - }, + } - canResetTimelineInRoom: function(roomId) { + canResetTimelineInRoom = (roomId) => { if (!this._roomView.current) { return true; } return this._roomView.current.canResetTimeline(); - }, + }; - _setStateFromSessionStore() { + _setStateFromSessionStore = () => { this.setState({ userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()), }); - }, + }; _createResizer() { const classNames = { @@ -193,7 +191,7 @@ const LoggedInView = createReactClass({ collapseConfig); resizer.setClassNames(classNames); return resizer; - }, + } _loadResizerPreferences() { let lhsSize = window.localStorage.getItem("mx_lhs_size"); @@ -203,9 +201,9 @@ const LoggedInView = createReactClass({ lhsSize = 350; } this.resizer.forHandleAt(0).resize(lhsSize); - }, + } - onAccountData: function(event) { + onAccountData = (event) => { if (event.getType() === "im.vector.web.settings") { this.setState({ useCompactLayout: event.getContent().useCompactLayout, @@ -214,9 +212,9 @@ const LoggedInView = createReactClass({ if (event.getType() === "m.ignored_user_list") { dis.dispatch({action: "ignore_state_changed"}); } - }, + }; - onSync: function(syncState, oldSyncState, data) { + onSync = (syncState, oldSyncState, data) => { const oldErrCode = ( this.state.syncErrorData && this.state.syncErrorData.error && @@ -238,16 +236,16 @@ const LoggedInView = createReactClass({ if (oldSyncState === 'PREPARED' && syncState === 'SYNCING') { this._updateServerNoticeEvents(); } - }, + }; - onRoomStateEvents: function(ev, state) { + onRoomStateEvents = (ev, state) => { const roomLists = RoomListStore.getRoomLists(); if (roomLists['m.server_notice'] && roomLists['m.server_notice'].some(r => r.roomId === ev.getRoomId())) { this._updateServerNoticeEvents(); } - }, + }; - _updateServerNoticeEvents: async function() { + _updateServerNoticeEvents = async () => { const roomLists = RoomListStore.getRoomLists(); if (!roomLists['m.server_notice']) return []; @@ -267,9 +265,9 @@ const LoggedInView = createReactClass({ this.setState({ serverNoticeEvents: pinnedEvents, }); - }, + }; - _onPaste: function(ev) { + _onPaste = (ev) => { let canReceiveInput = false; let element = ev.target; // test for all parents because the target can be a child of a contenteditable element @@ -283,7 +281,7 @@ const LoggedInView = createReactClass({ // so dispatch synchronously before paste happens dis.dispatch({action: 'focus_composer'}, true); } - }, + }; /* SOME HACKERY BELOW: @@ -307,22 +305,22 @@ const LoggedInView = createReactClass({ We also listen with a native listener on the document to get keydown events when no element is focused. Bubbling is irrelevant here as the target is the body element. */ - _onReactKeyDown: function(ev) { + _onReactKeyDown = (ev) => { // events caught while bubbling up on the root element // of this component, so something must be focused. this._onKeyDown(ev); - }, + }; - _onNativeKeyDown: function(ev) { + _onNativeKeyDown = (ev) => { // only pass this if there is no focused element. // if there is, _onKeyDown will be called by the // react keydown handler that respects the react bubbling order. if (ev.target === document.body) { this._onKeyDown(ev); } - }, + }; - _onKeyDown: function(ev) { + _onKeyDown = (ev) => { /* // Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers // Will need to find a better meta key if anyone actually cares about using this. @@ -432,19 +430,19 @@ const LoggedInView = createReactClass({ // that would prevent typing in the now-focussed composer } } - }, + }; /** * dispatch a page-up/page-down/etc to the appropriate component * @param {Object} ev The key event */ - _onScrollKeyPressed: function(ev) { + _onScrollKeyPressed = (ev) => { if (this._roomView.current) { this._roomView.current.handleScrollKey(ev); } - }, + }; - _onDragEnd: function(result) { + _onDragEnd = (result) => { // Dragged to an invalid destination, not onto a droppable if (!result.destination) { return; @@ -467,9 +465,9 @@ const LoggedInView = createReactClass({ } else if (dest.startsWith('room-sub-list-droppable_')) { this._onRoomTileEndDrag(result); } - }, + }; - _onRoomTileEndDrag: function(result) { + _onRoomTileEndDrag = (result) => { let newTag = result.destination.droppableId.split('_')[1]; let prevTag = result.source.droppableId.split('_')[1]; if (newTag === 'undefined') newTag = undefined; @@ -486,9 +484,9 @@ const LoggedInView = createReactClass({ prevTag, newTag, oldIndex, newIndex, ), true); - }, + }; - _onMouseDown: function(ev) { + _onMouseDown = (ev) => { // When the panels are disabled, clicking on them results in a mouse event // which bubbles to certain elements in the tree. When this happens, close // any settings page that is currently open (user/room/group). @@ -507,9 +505,9 @@ const LoggedInView = createReactClass({ }); } } - }, + }; - _onMouseUp: function(ev) { + _onMouseUp = (ev) => { if (!this.state.mouseDown) return; const deltaX = ev.pageX - this.state.mouseDown.x; @@ -528,13 +526,13 @@ const LoggedInView = createReactClass({ // Always clear the mouseDown state to ensure we don't accidentally // use stale values due to the mouseDown checks. this.setState({mouseDown: null}); - }, + }; - _setResizeContainerRef(div) { + _setResizeContainerRef = (div) => { this.resizeContainer = div; - }, + }; - render: function() { + render() { const LeftPanel = sdk.getComponent('structures.LeftPanel'); const RoomView = sdk.getComponent('structures.RoomView'); const UserView = sdk.getComponent('structures.UserView'); @@ -660,7 +658,7 @@ const LoggedInView = createReactClass({
); - }, -}); + } +} export default LoggedInView; From 368e3f9e85bf8d950ac8541ea0693859c57300b1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 13 Apr 2020 14:29:00 +0100 Subject: [PATCH 16/27] Convert LoggedInView to TypeScript Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../{LoggedInView.js => LoggedInView.tsx} | 89 +++++++++++++++---- 1 file changed, 71 insertions(+), 18 deletions(-) rename src/components/structures/{LoggedInView.js => LoggedInView.tsx} (91%) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.tsx similarity index 91% rename from src/components/structures/LoggedInView.js rename to src/components/structures/LoggedInView.tsx index 36beec3f6c..e09a5c9ac6 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.tsx @@ -16,9 +16,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixClient } from 'matrix-js-sdk'; -import React, {createRef, PureComponent} from 'react'; -import PropTypes from 'prop-types'; +import * as React from 'react'; +import * as PropTypes from 'prop-types'; +import { MatrixClient } from 'matrix-js-sdk/src/client'; +import { MatrixEvent } from 'matrix-js-sdk/src/models/event'; import { DragDropContext } from 'react-beautiful-dnd'; import {Key, isOnlyCtrlOrCmdKeyEvent, isOnlyCtrlOrCmdIgnoreShiftKeyEvent} from '../../Keyboard'; @@ -28,7 +29,7 @@ import { fixupColorFonts } from '../../utils/FontManager'; import * as sdk from '../../index'; import dis from '../../dispatcher'; import sessionStore from '../../stores/SessionStore'; -import {MatrixClientPeg} from '../../MatrixClientPeg'; +import {MatrixClientPeg, MatrixClientCreds} from '../../MatrixClientPeg'; import SettingsStore from "../../settings/SettingsStore"; import RoomListStore from "../../stores/RoomListStore"; @@ -39,6 +40,7 @@ import {Resizer, CollapseDistributor} from '../../resizer'; import MatrixClientContext from "../../contexts/MatrixClientContext"; import * as KeyboardShortcuts from "../../accessibility/KeyboardShortcuts"; import HomePage from "./HomePage"; +import ResizeNotifier from "../../utils/ResizeNotifier"; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. // NB. this is just for server notices rather than pinned messages in general. @@ -51,6 +53,52 @@ function canElementReceiveInput(el) { !!el.getAttribute("contenteditable"); } +interface IProps { + matrixClient: MatrixClient; + onRegistered: (credentials: MatrixClientCreds) => Promise; + viaServers?: string[]; + hideToSRUsers: boolean; + resizeNotifier: ResizeNotifier; + middleDisabled: boolean; + initialEventPixelOffset: number; + leftDisabled: boolean; + rightDisabled: boolean; + showCookieBar: boolean; + hasNewVersion: boolean; + userHasGeneratedPassword: boolean; + showNotifierToolbar: boolean; + page_type: string; + autoJoin: boolean; + thirdPartyInvite?: object; + roomOobData?: object; + currentRoomId: string; + ConferenceHandler?: object; + collapseLhs: boolean; + checkingForUpdate: boolean; + config: { + piwik: { + policyUrl: string; + }, + [key: string]: any, + }; + currentUserId?: string; + currentGroupId?: string; + currentGroupIsNew?: boolean; + version?: string; + newVersion?: string; + newVersionReleaseNotes?: string; +} +interface IState { + mouseDown?: { + x: number; + y: number; + }; + syncErrorData: any; + useCompactLayout: boolean; + serverNoticeEvents: MatrixEvent[]; + userHasGeneratedPassword: boolean; +} + /** * This is what our MatrixChat shows when we are logged in. The precise view is * determined by the page_type property. @@ -60,7 +108,7 @@ function canElementReceiveInput(el) { * * Components mounted below us can access the matrix client via the react context. */ -class LoggedInView extends PureComponent { +class LoggedInView extends React.PureComponent { static displayName = 'LoggedInView'; static propTypes = { @@ -78,10 +126,20 @@ class LoggedInView extends PureComponent { // and lots and lots of other stuff. }; + private readonly _matrixClient: MatrixClient; + private readonly _roomView: React.RefObject; + private readonly _resizeContainer: React.RefObject; + private readonly _sessionStore: sessionStore; + private readonly _sessionStoreToken: { remove: () => void }; + private resizer: Resizer; + constructor(props, context) { super(props, context); this.state = { + mouseDown: undefined, + syncErrorData: undefined, + userHasGeneratedPassword: false, // use compact timeline view useCompactLayout: SettingsStore.getValue('useCompactLayout'), // any currently active server notice events @@ -109,7 +167,8 @@ class LoggedInView extends PureComponent { fixupColorFonts(); - this._roomView = createRef(); + this._roomView = React.createRef(); + this._resizeContainer = React.createRef(); } componentDidMount() { @@ -118,12 +177,12 @@ class LoggedInView extends PureComponent { this._loadResizerPreferences(); } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps, prevState) { // attempt to guess when a banner was opened or closed if ( (prevProps.showCookieBar !== this.props.showCookieBar) || (prevProps.hasNewVersion !== this.props.hasNewVersion) || - (prevProps.userHasGeneratedPassword !== this.props.userHasGeneratedPassword) || + (prevState.userHasGeneratedPassword !== this.state.userHasGeneratedPassword) || (prevProps.showNotifierToolbar !== this.props.showNotifierToolbar) ) { this.props.resizeNotifier.notifyBannersChanged(); @@ -186,7 +245,7 @@ class LoggedInView extends PureComponent { }, }; const resizer = new Resizer( - this.resizeContainer, + this._resizeContainer.current, CollapseDistributor, collapseConfig); resizer.setClassNames(classNames); @@ -194,10 +253,8 @@ class LoggedInView extends PureComponent { } _loadResizerPreferences() { - let lhsSize = window.localStorage.getItem("mx_lhs_size"); - if (lhsSize !== null) { - lhsSize = parseInt(lhsSize, 10); - } else { + let lhsSize = parseInt(window.localStorage.getItem("mx_lhs_size"), 10); + if (isNaN(lhsSize)) { lhsSize = 350; } this.resizer.forHandleAt(0).resize(lhsSize); @@ -528,10 +585,6 @@ class LoggedInView extends PureComponent { this.setState({mouseDown: null}); }; - _setResizeContainerRef = (div) => { - this.resizeContainer = div; - }; - render() { const LeftPanel = sdk.getComponent('structures.LeftPanel'); const RoomView = sdk.getComponent('structures.RoomView'); @@ -645,7 +698,7 @@ class LoggedInView extends PureComponent { { topBar } -
+
Date: Mon, 13 Apr 2020 14:30:52 +0100 Subject: [PATCH 17/27] prefer protected over private so that the class can be extended Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index e09a5c9ac6..8497b9bc80 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -126,12 +126,12 @@ class LoggedInView extends React.PureComponent { // and lots and lots of other stuff. }; - private readonly _matrixClient: MatrixClient; - private readonly _roomView: React.RefObject; - private readonly _resizeContainer: React.RefObject; - private readonly _sessionStore: sessionStore; - private readonly _sessionStoreToken: { remove: () => void }; - private resizer: Resizer; + protected readonly _matrixClient: MatrixClient; + protected readonly _roomView: React.RefObject; + protected readonly _resizeContainer: React.RefObject; + protected readonly _sessionStore: sessionStore; + protected readonly _sessionStoreToken: { remove: () => void }; + protected resizer: Resizer; constructor(props, context) { super(props, context); From 46f7fadf3f23e3f4eaaf3a97124ec2fe8cc4ccd3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 13 Apr 2020 14:33:45 +0100 Subject: [PATCH 18/27] delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 8497b9bc80..0e2a74faae 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -315,8 +315,8 @@ class LoggedInView extends React.PureComponent { const pinnedEventIds = pinStateEvent.getContent().pinned.slice(0, MAX_PINNED_NOTICES_PER_ROOM); for (const eventId of pinnedEventIds) { const timeline = await this._matrixClient.getEventTimeline(room.getUnfilteredTimelineSet(), eventId, 0); - const ev = timeline.getEvents().find(ev => ev.getId() === eventId); - if (ev) pinnedEvents.push(ev); + const event = timeline.getEvents().find(ev => ev.getId() === eventId); + if (event) pinnedEvents.push(event); } } this.setState({ From 09d56e7bbc13461aeee7229de15e582c1eb4ee9d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Apr 2020 13:05:23 +0100 Subject: [PATCH 19/27] Fix create room dialog e2ee private room setting Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/CreateRoomDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index 88e90627e8..f18e28b85e 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -66,7 +66,7 @@ export default createReactClass({ } if (!this.state.isPublic && SettingsStore.isFeatureEnabled("feature_cross_signing")) { - createOpts.encryption = this.state.isEncrypted; + opts.encryption = this.state.isEncrypted; } return opts; From e114effcfad25efe3a2e16faf3a26a0c21ef82ff Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Apr 2020 13:07:44 +0100 Subject: [PATCH 20/27] make code more readable as per pr suggestion Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/autocomplete/EmojiProvider.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/autocomplete/EmojiProvider.js b/src/autocomplete/EmojiProvider.js index 76058b42b0..670776644e 100644 --- a/src/autocomplete/EmojiProvider.js +++ b/src/autocomplete/EmojiProvider.js @@ -101,9 +101,7 @@ export default class EmojiProvider extends AutocompleteProvider { // then sort by score (Infinity if matchedString not in shortname) sorters.push((c) => score(matchedString, c.shortname)); // then sort by max score of all shortcodes, trim off the `:` - sorters.push((c) => { - return Math.min.apply(null, c.emoji.shortcodes.map(s => score(matchedString.substring(1), s))); - }); + sorters.push((c) => Math.min(...c.emoji.shortcodes.map(s => score(matchedString.substring(1), s)))); // If the matchedString is not empty, sort by length of shortname. Example: // matchedString = ":bookmark" // completions = [":bookmark:", ":bookmark_tabs:", ...] From a7d95d396eb5e504bce352e36a40e45dd638b28a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Apr 2020 14:46:04 +0100 Subject: [PATCH 21/27] fix copyright Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- res/css/views/messages/_MVideoBody.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/css/views/messages/_MVideoBody.scss b/res/css/views/messages/_MVideoBody.scss index db044aba03..3b05c53f34 100644 --- a/res/css/views/messages/_MVideoBody.scss +++ b/res/css/views/messages/_MVideoBody.scss @@ -1,5 +1,5 @@ /* -Copyright 2020 New Vector Ltd. +Copyright 2020 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 50d6551c86d1a8f49830801d2988c964fa094d1f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Apr 2020 14:50:09 +0100 Subject: [PATCH 22/27] @replaceableComponent Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 0e2a74faae..ecf6a92c89 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -41,6 +41,7 @@ import MatrixClientContext from "../../contexts/MatrixClientContext"; import * as KeyboardShortcuts from "../../accessibility/KeyboardShortcuts"; import HomePage from "./HomePage"; import ResizeNotifier from "../../utils/ResizeNotifier"; +import { replaceableComponent } from '../../utils/replaceableComponent'; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. // NB. this is just for server notices rather than pinned messages in general. @@ -108,6 +109,7 @@ interface IState { * * Components mounted below us can access the matrix client via the react context. */ +@replaceableComponent("structures.LoggedInView") class LoggedInView extends React.PureComponent { static displayName = 'LoggedInView'; From 26569dea065ddb42877d8bece5db7162f7f45cf8 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Apr 2020 14:59:20 +0100 Subject: [PATCH 23/27] Revert "@replaceableComponent" This reverts commit 50d6551c Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index ecf6a92c89..0e2a74faae 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -41,7 +41,6 @@ import MatrixClientContext from "../../contexts/MatrixClientContext"; import * as KeyboardShortcuts from "../../accessibility/KeyboardShortcuts"; import HomePage from "./HomePage"; import ResizeNotifier from "../../utils/ResizeNotifier"; -import { replaceableComponent } from '../../utils/replaceableComponent'; // We need to fetch each pinned message individually (if we don't already have it) // so each pinned message may trigger a request. Limit the number per room for sanity. // NB. this is just for server notices rather than pinned messages in general. @@ -109,7 +108,6 @@ interface IState { * * Components mounted below us can access the matrix client via the react context. */ -@replaceableComponent("structures.LoggedInView") class LoggedInView extends React.PureComponent { static displayName = 'LoggedInView'; From 7b3c34bd129a77eaade524fa1ae458903b46dfc4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 14 Apr 2020 16:46:02 +0200 Subject: [PATCH 24/27] use js-sdk qr code generation --- .../VerificationQREmojiOptions.js | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/components/views/verification/VerificationQREmojiOptions.js b/src/components/views/verification/VerificationQREmojiOptions.js index d72c6951fe..89b3a596d7 100644 --- a/src/components/views/verification/VerificationQREmojiOptions.js +++ b/src/components/views/verification/VerificationQREmojiOptions.js @@ -20,8 +20,8 @@ import { _t } from '../../../languageHandler'; import AccessibleButton from "../elements/AccessibleButton"; import {replaceableComponent} from "../../../utils/replaceableComponent"; import VerificationQRCode from "../elements/crypto/VerificationQRCode"; -import {VerificationRequest} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest"; import Spinner from "../elements/Spinner"; +import {SCAN_QR_CODE_METHOD} from "matrix-js-sdk/src/crypto/verification/QRCode"; @replaceableComponent("views.verification.VerificationQREmojiOptions") export default class VerificationQREmojiOptions extends React.Component { @@ -31,31 +31,17 @@ export default class VerificationQREmojiOptions extends React.Component { onStartEmoji: PropTypes.func.isRequired, }; - constructor(props) { - super(props); - - this.state = { - qrProps: null, - }; - - this._prepareQrCode(props.request); - } - - async _prepareQrCode(request: VerificationRequest) { - try { - const props = await VerificationQRCode.getPropsForRequest(request); - this.setState({qrProps: props}); - } catch (e) { - console.error(e); - // We just won't show a QR code - } - } - render() { - let qrCode =
; - if (this.state.qrProps) { - qrCode = ; + const {request} = this.props; + const showQR = request.otherPartySupportsMethod(SCAN_QR_CODE_METHOD); + + let qrCode; + if (showQR) { + qrCode = ; + } else { + qrCode =
; } + return (
{_t("Verify this session by completing one of the following:")} From db09cadb667c158479c87b421cb95edc2042023e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 14 Apr 2020 17:19:15 +0200 Subject: [PATCH 25/27] remove spinner, change copy, add button placeholder --- res/css/_components.scss | 1 + .../structures/auth/_CompleteSecurity.scss | 1 + .../views/elements/_ButtonPlaceholder.scss | 24 +++++++++++++++++++ .../structures/auth/SetupEncryptionBody.js | 6 ++--- .../views/elements/ButtonPlaceholder.js | 19 +++++++++++++++ src/i18n/strings/en_EN.json | 4 ++-- 6 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 res/css/views/elements/_ButtonPlaceholder.scss create mode 100644 src/components/views/elements/ButtonPlaceholder.js diff --git a/res/css/_components.scss b/res/css/_components.scss index 8706772ad9..21df53d0b9 100644 --- a/res/css/_components.scss +++ b/res/css/_components.scss @@ -94,6 +94,7 @@ @import "./views/elements/_AccessibleButton.scss"; @import "./views/elements/_AddressSelector.scss"; @import "./views/elements/_AddressTile.scss"; +@import "./views/elements/_ButtonPlaceholder.scss"; @import "./views/elements/_DirectorySearchBox.scss"; @import "./views/elements/_Dropdown.scss"; @import "./views/elements/_EditableItemList.scss"; diff --git a/res/css/structures/auth/_CompleteSecurity.scss b/res/css/structures/auth/_CompleteSecurity.scss index 3050840fe8..80e7aaada0 100644 --- a/res/css/structures/auth/_CompleteSecurity.scss +++ b/res/css/structures/auth/_CompleteSecurity.scss @@ -44,6 +44,7 @@ limitations under the License. .mx_CompleteSecurity_actionRow { display: flex; justify-content: flex-end; + margin-top: $font-28px; .mx_AccessibleButton { margin-inline-start: 18px; diff --git a/res/css/views/elements/_ButtonPlaceholder.scss b/res/css/views/elements/_ButtonPlaceholder.scss new file mode 100644 index 0000000000..c9a8c1f794 --- /dev/null +++ b/res/css/views/elements/_ButtonPlaceholder.scss @@ -0,0 +1,24 @@ +/* +Copyright 2017 Vector Creations Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +.mx_ButtonPlaceholder { + font-size: $font-14px; + font-weight: 600; + padding: 7px 18px; + display: inline-block; + text-align: center; + color: $authpage-secondary-color; +} diff --git a/src/components/structures/auth/SetupEncryptionBody.js b/src/components/structures/auth/SetupEncryptionBody.js index c7c73cd616..a982957ed0 100644 --- a/src/components/structures/auth/SetupEncryptionBody.js +++ b/src/components/structures/auth/SetupEncryptionBody.js @@ -108,14 +108,13 @@ export default class SetupEncryptionBody extends React.Component { member={MatrixClientPeg.get().getUser(this.state.verificationRequest.otherUserId)} />; } else if (phase === PHASE_INTRO) { - const InlineSpinner = sdk.getComponent('elements.InlineSpinner'); + const ButtonPlaceholder = sdk.getComponent("elements.ButtonPlaceholder"); return (

{_t( - "Open an existing session & use it to verify this one, " + + "Use an existing session to verify this one, " + "granting it access to encrypted messages.", )}

-

{_t("Waiting…")}

{_t( "If you can’t access one, ", {}, { @@ -133,6 +132,7 @@ export default class SetupEncryptionBody extends React.Component { > {_t("Skip")} + {_t("Use your other device to continue…")}

); diff --git a/src/components/views/elements/ButtonPlaceholder.js b/src/components/views/elements/ButtonPlaceholder.js new file mode 100644 index 0000000000..9c40df9db6 --- /dev/null +++ b/src/components/views/elements/ButtonPlaceholder.js @@ -0,0 +1,19 @@ +/* +Copyright 2020 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export default function ButtonPlaceholder(props) { + return
{props.children}
; +} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ae8ed90402..a46c357a3e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2112,9 +2112,9 @@ "You can now close this window or log in to your new account.": "You can now close this window or log in to your new account.", "Registration Successful": "Registration Successful", "Create your account": "Create your account", - "Open an existing session & use it to verify this one, granting it access to encrypted messages.": "Open an existing session & use it to verify this one, granting it access to encrypted messages.", - "Waiting…": "Waiting…", + "Use an existing session to verify this one, granting it access to encrypted messages.": "Use an existing session to verify this one, granting it access to encrypted messages.", "If you can’t access one, ": "If you can’t access one, ", + "Use your other device to continue…": "Use your other device to continue…", "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.": "Your new session is now verified. It has access to your encrypted messages, and other users will see it as trusted.", "Your new session is now verified. Other users will see it as trusted.": "Your new session is now verified. Other users will see it as trusted.", "Without completing security on this session, it won’t have access to encrypted messages.": "Without completing security on this session, it won’t have access to encrypted messages.", From 368737cfd95f700f376453f1921b13cbc92005f2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 14 Apr 2020 17:41:06 +0200 Subject: [PATCH 26/27] fix copyright --- res/css/views/elements/_ButtonPlaceholder.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/css/views/elements/_ButtonPlaceholder.scss b/res/css/views/elements/_ButtonPlaceholder.scss index c9a8c1f794..858fcdecf6 100644 --- a/res/css/views/elements/_ButtonPlaceholder.scss +++ b/res/css/views/elements/_ButtonPlaceholder.scss @@ -1,5 +1,5 @@ /* -Copyright 2017 Vector Creations Ltd +Copyright 2020 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 24fe125cb63090ef5e14aae1a1551d38d1a7a899 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 14 Apr 2020 17:53:33 +0200 Subject: [PATCH 27/27] dont try to enable 4S if cross-signing is disabled --- src/verification.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/verification.js b/src/verification.js index 3170eb8825..e00e5e05fa 100644 --- a/src/verification.js +++ b/src/verification.js @@ -61,15 +61,18 @@ function UntrustedDeviceDialog(props) { } export async function verifyDevice(user, device) { - if (!await enable4SIfNeeded()) { - return; + const cli = MatrixClientPeg.get(); + // if cross-signing is not explicitly disabled, check if it should be enabled first. + if (cli.getCryptoTrustCrossSignedDevices()) { + if (!await enable4SIfNeeded()) { + return; + } } Modal.createTrackedDialog("Verification warning", "unverified session", UntrustedDeviceDialog, { user, device, onFinished: async (action) => { if (action === "sas") { - const cli = MatrixClientPeg.get(); const verificationRequestPromise = cli.legacyDeviceVerification( user.userId, device.deviceId, @@ -95,10 +98,13 @@ export async function verifyDevice(user, device) { } export async function legacyVerifyUser(user) { - if (!await enable4SIfNeeded()) { - return; - } const cli = MatrixClientPeg.get(); + // if cross-signing is not explicitly disabled, check if it should be enabled first. + if (cli.getCryptoTrustCrossSignedDevices()) { + if (!await enable4SIfNeeded()) { + return; + } + } const verificationRequestPromise = cli.requestVerification(user.userId); dis.dispatch({ action: "set_right_panel_phase",