From ceaa3aaca4a61046ac03f7dbb23d670b57c49d16 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 26 Sep 2018 02:04:55 +0100 Subject: [PATCH 01/11] Use createObjectURL instead of readAsDataURL for videos --- src/ContentMessages.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/ContentMessages.js b/src/ContentMessages.js index fd21977108..2308954846 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -148,29 +148,21 @@ function infoForImageFile(matrixClient, roomId, imageFile) { * @return {Promise} A promise that resolves with the video image element. */ function loadVideoElement(videoFile) { - const deferred = Promise.defer(); - // Load the file into an html element const video = document.createElement("video"); - const reader = new FileReader(); - reader.onload = function(e) { - video.src = e.target.result; - - // Once ready, returns its size - // Wait until we have enough data to thumbnail the first frame. - video.onloadeddata = function() { - deferred.resolve(video); - }; - video.onerror = function(e) { - deferred.reject(e); - }; + // Once ready, returns its size + // Wait until we have enough data to thumbnail the first frame. + video.onloadeddata = function() { + URL.revokeObjectURL(video.src); + deferred.resolve(video); }; - reader.onerror = function(e) { + video.onerror = function(e) { deferred.reject(e); }; - reader.readAsDataURL(videoFile); - + + // We don't use readAsDataURL because massive files and b64 don't mix. + video.src = URL.createObjectURL(videoFile); return deferred.promise; } From 41336a9de69b64372eff22730c9dc9ae89f425b2 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 26 Sep 2018 02:06:02 +0100 Subject: [PATCH 02/11] Oops, missing deferred --- src/ContentMessages.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ContentMessages.js b/src/ContentMessages.js index 2308954846..0a361ae5b9 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -148,6 +148,8 @@ function infoForImageFile(matrixClient, roomId, imageFile) { * @return {Promise} A promise that resolves with the video image element. */ function loadVideoElement(videoFile) { + const deferred = Promise.defer(); + // Load the file into an html element const video = document.createElement("video"); From d74efd09abd4a260ca36956279580e3b6af7b134 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 27 Sep 2018 16:11:57 -0600 Subject: [PATCH 03/11] Track how far the user travels before dismissing their user settings Fixes https://github.com/vector-im/riot-web/issues/7158 Because the onClick was on a fullpage div, the browser was firing it regardless of how far the mouse moved. The onClick event itself doesn't give us any sort of travel distance, or a start point we can use to determine if they clicked a scrollbar or something. This means we have to rely on good ol' fashioned mouse down and up events to see if the user moved their mouse during their click. If the user's click starts in a valid container, we record the coordinates. This is so we can easily identify when the user clicks inside something like the settings container itself. When the user releases their mouse, we determine how far they moved their mouse - if the distance is within some threshold (~5 pixels in this case) then we can count it as a click. Because we've already filtered on the component they started their click in, we can safely rely on the presence of coordinates as a flag that they are in the right container, combined with the fact that they can't stray too far before their click not counting anyways. --- src/components/structures/LoggedInView.js | 32 ++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 0c4688a411..180a348434 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -319,7 +319,7 @@ const LoggedInView = React.createClass({ ), true); }, - _onClick: function(ev) { + _onMouseDown: function(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). @@ -330,11 +330,37 @@ const LoggedInView = React.createClass({ targetClasses.has('mx_MatrixChat_middlePanel') || targetClasses.has('mx_RoomView') ) { - dis.dispatch({ action: 'close_settings' }); + this.setState({ + mouseDown: { + x: ev.pageX, + y: ev.pageY, + }, + }); } } }, + _onMouseUp: function(ev) { + if (!this.state.mouseDown) return; + + const deltaX = ev.pageX - this.state.mouseDown.x; + const deltaY = ev.pageY - this.state.mouseDown.y; + const distance = Math.sqrt((deltaX * deltaX) + (deltaY + deltaY)); + const maxRadius = 5; // People shouldn't be straying too far, hopefully + + // Note: we track how far the user moved their mouse to help + // combat against https://github.com/vector-im/riot-web/issues/7158 + + if (distance < maxRadius) { + // This is probably a real click, and not a drag + dis.dispatch({ action: 'close_settings' }); + } + + // Always clear the mouseDown state to ensure we don't accidentally + // use stale values due to the mouseDown checks. + this.setState({mouseDown: null}); + }, + render: function() { const LeftPanel = sdk.getComponent('structures.LeftPanel'); const RightPanel = sdk.getComponent('structures.RightPanel'); @@ -478,7 +504,7 @@ const LoggedInView = React.createClass({ } return ( -
+
{ topBar }
From e1f68551f1ff75b7658bad242b1f5e5fd7f2efb8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 2 Oct 2018 19:23:43 +0100 Subject: [PATCH 04/11] Fix error logging --- src/MatrixClientPeg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index f5872812de..9865044717 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -109,7 +109,7 @@ class MatrixClientPeg { await promise; } catch (err) { // log any errors when starting up the database (if one exists) - console.error(`Error starting matrixclient store: ${err}`); + console.error('Error starting matrixclient store', err); } // regardless of errors, start the client. If we did error out, we'll From 91e8ee98a1ce5e8e09f0170f0af5eaff46a9229b Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Tue, 2 Oct 2018 22:12:26 -0500 Subject: [PATCH 05/11] Fix brace style in TextForEvent.js Signed-off-by: Aaron Raimist --- src/TextForEvent.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 38d3b63e1a..96cccf07fb 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -248,8 +248,7 @@ function textForCanonicalAliasEvent(ev) { senderName: senderName, address: ev.getContent().alias, }); - } - else if (oldAlias) { + } else if (oldAlias) { return _t('%(senderName)s removed the main address for this room.', { senderName: senderName, }); From 259063eda6ef9b7651acc342a3275386b386a525 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 3 Oct 2018 10:39:09 +0100 Subject: [PATCH 06/11] Remove useless comment. --- src/ContentMessages.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ContentMessages.js b/src/ContentMessages.js index 0a361ae5b9..a0bf75bccf 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -153,7 +153,6 @@ function loadVideoElement(videoFile) { // Load the file into an html element const video = document.createElement("video"); - // Once ready, returns its size // Wait until we have enough data to thumbnail the first frame. video.onloadeddata = function() { URL.revokeObjectURL(video.src); From 1ec0f04baf5106de747bbc698d4044fe4fbf77e8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 3 Oct 2018 18:28:41 +0100 Subject: [PATCH 07/11] Remove old migration code ...as instructed! --- src/utils/createMatrixClient.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/utils/createMatrixClient.js b/src/utils/createMatrixClient.js index b83e254fad..54312695b6 100644 --- a/src/utils/createMatrixClient.js +++ b/src/utils/createMatrixClient.js @@ -48,9 +48,6 @@ export default function createMatrixClient(opts) { } if (indexedDB && localStorage) { - // FIXME: bodge to remove old database. Remove this after a few weeks. - indexedDB.deleteDatabase("matrix-js-sdk:default"); - storeOpts.store = new Matrix.IndexedDBStore({ indexedDB: indexedDB, dbName: "riot-web-sync", From fe788486b77762e065320bcbce548873811fe596 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 3 Oct 2018 19:34:06 +0100 Subject: [PATCH 08/11] Drop (IRC) suffix hacks --- src/autocomplete/UserProvider.js | 4 ++-- src/components/views/elements/Pill.js | 2 +- src/components/views/messages/SenderProfile.js | 3 --- src/components/views/rooms/MessageComposerInput.js | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js index 85837d5ebb..bdc1753da7 100644 --- a/src/autocomplete/UserProvider.js +++ b/src/autocomplete/UserProvider.js @@ -108,11 +108,11 @@ export default class UserProvider extends AutocompleteProvider { // Don't search if the query is a single "@" if (fullMatch && fullMatch !== '@') { completions = this.matcher.match(fullMatch).map((user) => { - const displayName = (user.name || user.userId || '').replace(' (IRC)', ''); // FIXME when groups are done + const displayName = (user.name || user.userId || ''); // FIXME when groups are done return { // Length of completion should equal length of text in decorator. draft-js // relies on the length of the entity === length of the text in the decoration. - completion: user.rawDisplayName.replace(' (IRC)', ''), + completion: user.rawDisplayName, suffix: range.start === 0 ? ': ' : ' ', href: makeUserPermalink(user.userId), component: ( diff --git a/src/components/views/elements/Pill.js b/src/components/views/elements/Pill.js index e14d6c37c9..e37e45838a 100644 --- a/src/components/views/elements/Pill.js +++ b/src/components/views/elements/Pill.js @@ -229,7 +229,7 @@ const Pill = React.createClass({ if (member) { userId = member.userId; member.rawDisplayName = member.rawDisplayName || ''; - linkText = member.rawDisplayName.replace(' (IRC)', ''); // FIXME when groups are done + linkText = member.rawDisplayName, if (this.props.shouldShowPillAvatar) { avatar = ; } diff --git a/src/components/views/messages/SenderProfile.js b/src/components/views/messages/SenderProfile.js index 5ca2fc6ed8..620f66bb03 100644 --- a/src/components/views/messages/SenderProfile.js +++ b/src/components/views/messages/SenderProfile.js @@ -111,9 +111,6 @@ export default React.createClass({ this.state.userGroups, this.state.relatedGroups, ); - // Backwards-compatible replacing of "(IRC)" with AS user flair - name = displayedGroups.length > 0 ? name.replace(' (IRC)', '') : name; - flair = Date: Wed, 3 Oct 2018 19:39:47 +0100 Subject: [PATCH 09/11] The comment can go --- src/autocomplete/UserProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js index 24dfa8be3e..e9cbf7945b 100644 --- a/src/autocomplete/UserProvider.js +++ b/src/autocomplete/UserProvider.js @@ -105,7 +105,7 @@ export default class UserProvider extends AutocompleteProvider { // Don't search if the query is a single "@" if (fullMatch && fullMatch !== '@') { completions = this.matcher.match(fullMatch).map((user) => { - const displayName = (user.name || user.userId || ''); // FIXME when groups are done + const displayName = (user.name || user.userId || ''); return { // Length of completion should equal length of text in decorator. draft-js // relies on the length of the entity === length of the text in the decoration. From 8ceca3abe943486c3dc6548c199b215d49a6f8ac Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 4 Oct 2018 10:34:34 +0100 Subject: [PATCH 10/11] Update Pill.js Commas are not semicolons --- src/components/views/elements/Pill.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/Pill.js b/src/components/views/elements/Pill.js index 25b40d186d..af7e8c4ae3 100644 --- a/src/components/views/elements/Pill.js +++ b/src/components/views/elements/Pill.js @@ -234,7 +234,7 @@ const Pill = React.createClass({ if (member) { userId = member.userId; member.rawDisplayName = member.rawDisplayName || ''; - linkText = member.rawDisplayName, + linkText = member.rawDisplayName; if (this.props.shouldShowPillAvatar) { avatar = ; } From a81589ffb5a717de82db35e03b47786ce0fe5d1a Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 5 Oct 2018 12:15:03 +0100 Subject: [PATCH 11/11] Silence bluebird warnings --- src/components/structures/MatrixChat.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 3450626c54..3f213c5a83 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -48,6 +48,10 @@ import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; import { startAnyRegistrationFlow } from "../../Registration.js"; import { messageForSyncError } from '../../utils/ErrorUtils'; +// Disable warnings for now: we use deprecated bluebird functions +// and need to migrate, but they spam the console with warnings. +Promise.config({warnings: false}); + /** constants for MatrixChat.state.view */ const VIEWS = { // a special initial state which is only used at startup, while we are