From 17262ad80d4a7596c698f6c13caa2842903e36bc Mon Sep 17 00:00:00 2001 From: Pablo Saavedra Date: Mon, 8 May 2017 12:18:31 +0200 Subject: [PATCH 01/28] Added TextInputWithCheckbox dialog --- src/component-index.js | 2 + src/components/structures/MatrixChat.js | 15 ++- .../dialogs/TextInputWithCheckboxDialog.js | 108 ++++++++++++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 src/components/views/dialogs/TextInputWithCheckboxDialog.js diff --git a/src/component-index.js b/src/component-index.js index d6873c6dfd..ed538a6fcb 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -99,6 +99,8 @@ import views$dialogs$SetDisplayNameDialog from './components/views/dialogs/SetDi views$dialogs$SetDisplayNameDialog && (module.exports.components['views.dialogs.SetDisplayNameDialog'] = views$dialogs$SetDisplayNameDialog); import views$dialogs$TextInputDialog from './components/views/dialogs/TextInputDialog'; views$dialogs$TextInputDialog && (module.exports.components['views.dialogs.TextInputDialog'] = views$dialogs$TextInputDialog); +import views$dialogs$TextInputWithCheckboxDialog from './components/views/dialogs/TextInputWithCheckboxDialog'; +views$dialogs$TextInputWithCheckboxDialog && (module.exports.components['views.dialogs.TextInputWithCheckboxDialog'] = views$dialogs$TextInputWithCheckboxDialog); import views$dialogs$UnknownDeviceDialog from './components/views/dialogs/UnknownDeviceDialog'; views$dialogs$UnknownDeviceDialog && (module.exports.components['views.dialogs.UnknownDeviceDialog'] = views$dialogs$UnknownDeviceDialog); import views$elements$AccessibleButton from './components/views/elements/AccessibleButton'; diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index b449ff3094..d87ca203ce 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -191,6 +191,10 @@ module.exports = React.createClass({ return this.props.config.default_is_url || "https://vector.im"; }, + getDefaultFederate() { + return this.props.config.default_federate && true; + }, + componentWillMount: function() { SdkConfig.put(this.props.config); @@ -501,15 +505,20 @@ module.exports = React.createClass({ //this._setPage(PageTypes.CreateRoom); //this.notifyNewScreen('new'); - var TextInputDialog = sdk.getComponent("dialogs.TextInputDialog"); - Modal.createDialog(TextInputDialog, { + var TextInputWithCheckboxDialog = sdk.getComponent("dialogs.TextInputWithCheckboxDialog"); + Modal.createDialog(TextInputWithCheckboxDialog, { title: "Create Room", description: "Room name (optional)", button: "Create Room", - onFinished: (should_create, name) => { + check: this.getDefaultFederate(), + checkLabel: "Federate room in domain " + MatrixClientPeg.get().getDomain(), + onFinished: (should_create, name, isFederate) => { if (should_create) { const createOpts = {}; if (name) createOpts.name = name; + if (isFederate) { + createOpts.creation_content = {"m.federate": isFederate} + } createRoom({createOpts}).done(); } } diff --git a/src/components/views/dialogs/TextInputWithCheckboxDialog.js b/src/components/views/dialogs/TextInputWithCheckboxDialog.js new file mode 100644 index 0000000000..916de16af5 --- /dev/null +++ b/src/components/views/dialogs/TextInputWithCheckboxDialog.js @@ -0,0 +1,108 @@ +/* +Copyright 2015, 2016 OpenMarket 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. +*/ + +import React from 'react'; +import sdk from '../../../index'; + +export default React.createClass({ + displayName: 'TextInputWithCheckboxDialog', + propTypes: { + title: React.PropTypes.string, + description: React.PropTypes.oneOfType([ + React.PropTypes.element, + React.PropTypes.string, + ]), + value: React.PropTypes.string, + button: React.PropTypes.string, + focus: React.PropTypes.bool, + checkLabel: React.PropTypes.string, + check: React.PropTypes.bool, + onFinished: React.PropTypes.func.isRequired, + }, + + getDefaultProps: function() { + return { + title: "", + value: "", + description: "", + button: "OK", + focus: true, + checkLabel: "", + check: true, + }; + }, + + getInitialState: function() { + return { + isChecked: this.props.check, + }; + }, + + componentDidMount: function() { + if (this.props.focus) { + // Set the cursor at the end of the text input + this.refs.textinput.value = this.props.value; + } + }, + + onOk: function() { + this.props.onFinished(true, this.refs.textinput.value, this.state.isChecked); + }, + + onCancel: function() { + this.props.onFinished(false); + }, + + _onToggle: function(keyName, checkedValue, uncheckedValue, ev) { + console.log("Checkbox toggle: %s %s", keyName, ev.target.checked); + var state = {}; + state[keyName] = ev.target.checked ? checkedValue : uncheckedValue; + this.setState(state); + }, + + render: function() { + const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + return ( + +
+
+ +
+
+ +
+ +
+
+ + +
+
+ ); + }, +}); From 4b4b7302331b195e199e44bd2abddbf1a2c68b29 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 2 Aug 2017 13:41:26 +0100 Subject: [PATCH 02/28] fix and i18n the impl Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 24 ++++++++------ .../dialogs/TextInputWithCheckboxDialog.js | 33 +++++++------------ src/i18n/strings/en_EN.json | 2 ++ 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 50ee9963a6..22119585d9 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -214,10 +214,6 @@ module.exports = React.createClass({ return this.props.config.default_is_url || "https://vector.im"; }, - getDefaultFederate() { - return this.props.config.default_federate && true; - }, - componentWillMount: function() { SdkConfig.put(this.props.config); @@ -790,19 +786,27 @@ module.exports = React.createClass({ dis.dispatch({action: 'view_set_mxid'}); return; } + // Dialog shows inverse of m.federate (noFederate) strict false check to skip undefined check (default = true) + const defaultNoFederate = this.props.config.default_federate === false; const TextInputWithCheckboxDialog = sdk.getComponent("dialogs.TextInputWithCheckboxDialog"); Modal.createDialog(TextInputWithCheckboxDialog, { title: _t('Create Room'), description: _t('Room name (optional)'), button: _t('Create Room'), - // TODO i18n below. - check: this.getDefaultFederate(), - checkLabel: 'Federate room in domain ' + MatrixClientPeg.get().getDomain(), - onFinished: (shouldCreate, name, federate) => { + check: defaultNoFederate, + checkLabel: + {_t('Block users on other matrix homeservers from joining this room')} +
+ ({_t('This setting cannot be changed later!')}) +
, + onFinished: (shouldCreate, name, noFederate) => { if (shouldCreate) { - const createOpts = {}; + const createOpts = { + creation_content: { + "m.federate": !noFederate, + }, + }; if (name) createOpts.name = name; - if (federate) createOpts.creation_content = {"m.federate": federate}; createRoom({createOpts}).done(); } }, diff --git a/src/components/views/dialogs/TextInputWithCheckboxDialog.js b/src/components/views/dialogs/TextInputWithCheckboxDialog.js index 916de16af5..613fab4cdb 100644 --- a/src/components/views/dialogs/TextInputWithCheckboxDialog.js +++ b/src/components/views/dialogs/TextInputWithCheckboxDialog.js @@ -16,6 +16,7 @@ limitations under the License. import React from 'react'; import sdk from '../../../index'; +import { _t } from '../../../languageHandler'; export default React.createClass({ displayName: 'TextInputWithCheckboxDialog', @@ -28,7 +29,10 @@ export default React.createClass({ value: React.PropTypes.string, button: React.PropTypes.string, focus: React.PropTypes.bool, - checkLabel: React.PropTypes.string, + checkLabel: React.PropTypes.oneOfType([ + React.PropTypes.element, + React.PropTypes.string, + ]), check: React.PropTypes.bool, onFinished: React.PropTypes.func.isRequired, }, @@ -38,16 +42,9 @@ export default React.createClass({ title: "", value: "", description: "", - button: "OK", focus: true, checkLabel: "", - check: true, - }; - }, - - getInitialState: function() { - return { - isChecked: this.props.check, + check: false, }; }, @@ -59,20 +56,13 @@ export default React.createClass({ }, onOk: function() { - this.props.onFinished(true, this.refs.textinput.value, this.state.isChecked); + this.props.onFinished(true, this.refs.textinput.value, this.refs.checkbox.value); }, onCancel: function() { this.props.onFinished(false); }, - _onToggle: function(keyName, checkedValue, uncheckedValue, ev) { - console.log("Checkbox toggle: %s %s", keyName, ev.target.checked); - var state = {}; - state[keyName] = ev.target.checked ? checkedValue : uncheckedValue; - this.setState(state); - }, - render: function() { const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); return ( @@ -87,16 +77,15 @@ export default React.createClass({
+
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 87eb189ad0..f7fb221072 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -146,6 +146,7 @@ "Microphone": "Microphone", "Camera": "Camera", "Advanced": "Advanced", + "Advanced options": "Advanced options", "Algorithm": "Algorithm", "Hide removed messages": "Hide removed messages", "Always show message timestamps": "Always show message timestamps", From 415693bd834b14b946e492c9914782632e4cfe0b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 14:02:31 -0600 Subject: [PATCH 06/28] Support editing power levels of events. Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 0fea50d2fa..b2d8aa7fe5 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -364,6 +364,11 @@ module.exports = React.createClass({ var powerLevels = this.props.room.currentState.getStateEvents('m.room.power_levels', ''); powerLevels = powerLevels ? powerLevels.getContent() : {}; + for (let key of Object.keys(this.refs).filter(k => k.startsWith("event_levels_"))) { + const eventType = key.substring("event_levels_".length); + powerLevels.events[eventType] = parseInt(this.refs[key].getValue()); + } + var newPowerLevels = { ban: parseInt(this.refs.ban.getValue()), kick: parseInt(this.refs.kick.getValue()), @@ -883,7 +888,8 @@ module.exports = React.createClass({ return (
{ _t('To send events of type') } { event_type }, { _t('you must be a') } - +
); })} From 2e1b2178a1f12be3c9a0da8054d15b5220e51903 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 14:35:49 -0600 Subject: [PATCH 07/28] Remove assumptions on how languages work in the power levels section This does mean that the strings will need to be re-translated, but now they may be more accurate because the comma is not assumed in the code. Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 14 +++++++------- src/i18n/strings/de_DE.json | 6 ------ src/i18n/strings/el.json | 7 ------- src/i18n/strings/en_EN.json | 14 +++++++------- src/i18n/strings/en_US.json | 14 +++++++------- src/i18n/strings/es.json | 7 ------- src/i18n/strings/eu.json | 7 ------- src/i18n/strings/fr.json | 7 ------- src/i18n/strings/hu.json | 7 ------- src/i18n/strings/ko.json | 7 ------- src/i18n/strings/lv.json | 7 ------- src/i18n/strings/nl.json | 7 ------- src/i18n/strings/pl.json | 7 ------- src/i18n/strings/pt.json | 7 ------- src/i18n/strings/pt_BR.json | 7 ------- src/i18n/strings/ru.json | 7 ------- src/i18n/strings/th.json | 6 ------ src/i18n/strings/tr.json | 7 ------- src/i18n/strings/zh_Hant.json | 7 ------- 19 files changed, 21 insertions(+), 131 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index b2d8aa7fe5..942da9ba06 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -860,34 +860,34 @@ module.exports = React.createClass({
- { _t('To send messages') }, { _t('you must be a') } + { _t('To send messages, you must be a') }
- { _t('To invite users into the room') }, { _t('you must be a') } + { _t('To invite users into the room, you must be a') }
- { _t('To configure the room') }, { _t('you must be a') } + { _t('To configure the room, you must be a') }
- { _t('To kick users') }, { _t('you must be a') } + { _t('To kick users, you must be a') }
- { _t('To ban users') }, { _t('you must be a') } + { _t('To ban users, you must be a') }
- { _t('To remove other users\' messages') }, { _t('you must be a') } + { _t('To remove other users\' messages, you must be a') }
{Object.keys(events_levels).map(function(event_type, i) { return (
- { _t('To send events of type') } { event_type }, { _t('you must be a') } + { _tJsx("To send events of type , you must be a", //, () => { event_type }) }
diff --git a/src/i18n/strings/de_DE.json b/src/i18n/strings/de_DE.json index aa114e241d..1a05530890 100644 --- a/src/i18n/strings/de_DE.json +++ b/src/i18n/strings/de_DE.json @@ -212,11 +212,7 @@ "This is a preview of this room. Room interactions have been disabled": "Dies ist eine Vorschau dieses Raumes. Raum-Interaktionen wurden deaktiviert", "This room is not accessible by remote Matrix servers": "Remote-Matrix-Server können auf diesen Raum nicht zugreifen", "This room's internal ID is": "Die interne ID dieses Raumes ist", - "To ban users": "Um Benutzer zu verbannen", - "To configure the room": "Um den Raum zu konfigurieren", - "To invite users into the room": "Um Nutzer in den Raum einzuladen", "to join the discussion": "um an der Diskussion teilzunehmen", - "To kick users": "Um Benutzer zu kicken", "Admin": "Administrator", "Server may be unavailable, overloaded, or you hit a bug.": "Server ist nicht verfügbar, überlastet oder du bist auf einen Fehler gestoßen.", "Could not connect to the integration server": "Konnte keine Verbindung zum Integrations-Server herstellen", @@ -227,7 +223,6 @@ "Can't connect to homeserver - please check your connectivity and ensure your": "Die Verbindung mit dem Homeserver ist fehlgeschlagen. Bitte überprüfe deine Verbindung und stelle sicher, dass dein(e) ", "tag as": "kennzeichne als", "To reset your password, enter the email address linked to your account": "Um dein Passwort zurückzusetzen, gib bitte die mit deinem Account verknüpfte E-Mail-Adresse ein", - "To send messages": "Um Nachrichten zu senden", "turned on end-to-end encryption (algorithm": "aktivierte Ende-zu-Ende-Verschlüsselung (Algorithmus", "Unable to add email address": "E-Mail-Adresse konnte nicht hinzugefügt werden", "Unable to remove contact information": "Die Kontakt-Informationen konnten nicht gelöscht werden", @@ -412,7 +407,6 @@ "to tag direct chat": "als Direkt-Chat markieren", "You're not in any rooms yet! Press": "Du bist noch keinem Raum beigetreten! Drücke", "click to reveal": "anzeigen", - "To remove other users' messages": "Um Nachrichten anderer Nutzer zu verbergen", "You are trying to access %(roomName)s.": "Du versuchst, auf den Raum \"%(roomName)s\" zuzugreifen.", "Monday": "Montag", "Tuesday": "Dienstag", diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json index bc45e6da9e..048de7e73f 100644 --- a/src/i18n/strings/el.json +++ b/src/i18n/strings/el.json @@ -344,14 +344,8 @@ "This room": "Αυτό το δωμάτιο", "This room's internal ID is": "Το εσωτερικό αναγνωριστικό του δωματίου είναι", "times": "φορές", - "To ban users": "Για αποκλεισμό χρηστών", "to browse the directory": "για περιήγηση στο ευρετήριο", - "To configure the room": "Για ρύθμιση του δωματίου", - "To invite users into the room": "Για πρόσκληση χρηστών στο δωμάτιο", - "To remove other users' messages": "Για αφαίρεση μηνυμάτων άλλων χρηστών", "to restore": "για επαναφορά", - "To send events of type": "Για αποστολή συμβάντων τύπου", - "To send messages": "Για αποστολή μηνυμάτων", "Turn Markdown off": "Απενεργοποίηση Markdown", "Turn Markdown on": "Ενεργοποίηση Markdown", "Unable to add email address": "Αδυναμία προσθήκης διεύθυνσης ηλ. αλληλογραφίας", @@ -574,7 +568,6 @@ "Some of your messages have not been sent.": "Μερικά από τα μηνύματα σας δεν έχουν αποσταλεί.", "This room is not recognised.": "Αυτό το δωμάτιο δεν αναγνωρίζεται.", "to favourite": "στα αγαπημένα", - "To kick users": "Για να διώξετε χρήστες", "to make a room or": "για δημιουργία ενός δωματίου ή", "to start a chat with someone": "για να ξεκινήσετε μια συνομιλία με κάποιον", "Unable to capture screen": "Αδυναμία σύλληψης οθόνης", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 87fd6d4364..8873b54091 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -448,21 +448,14 @@ "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "This room's internal ID is": "This room's internal ID is", "times": "times", - "To ban users": "To ban users", "to browse the directory": "to browse the directory", - "To configure the room": "To configure the room", "to demote": "to demote", "to favourite": "to favourite", "To get started, please pick a username!": "To get started, please pick a username!", - "To invite users into the room": "To invite users into the room", - "To kick users": "To kick users", "To link to a room it must have an address.": "To link to a room it must have an address.", "to make a room or": "to make a room or", - "To remove other users' messages": "To remove other users' messages", "To reset your password, enter the email address linked to your account": "To reset your password, enter the email address linked to your account", "to restore": "to restore", - "To send events of type": "To send events of type", - "To send messages": "To send messages", "to start a chat with someone": "to start a chat with someone", "to tag direct chat": "to tag direct chat", "To use it, just wait for autocomplete results to load and tab through them.": "To use it, just wait for autocomplete results to load and tab through them.", @@ -832,6 +825,13 @@ "Join an existing group": "Join an existing group", "To join an existing group you'll have to know its group identifier; this will look something like +example:matrix.org.": "To join an existing group you'll have to know its group identifier; this will look something like +example:matrix.org.", "Featured Rooms:": "Featured Rooms:", + "To send messages, you must be a": "To send messages, you must be a", + "To invite users into the room, you must be a": "To invite users into the room, you must be a", + "To configure the room, you must be a": "To configure the room, you must be a", + "To kick users, you must be a": "To kick users, you must be a", + "To ban users, you must be a": "To ban users, you must be a", + "To remove other users' messages, you must be a": "To remove other users' messages, you must be a", + "To send events of type , you must be a": "To send events of type , you must be a", "Error whilst fetching joined groups": "Error whilst fetching joined groups", "Featured Users:": "Featured Users:", "Edit Group": "Edit Group", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 928f1a9d0f..c3b3b6a1bc 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -393,21 +393,14 @@ "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", "This room's internal ID is": "This room's internal ID is", "times": "times", - "To ban users": "To ban users", "to browse the directory": "to browse the directory", - "To configure the room": "To configure the room", "to demote": "to demote", "to favourite": "to favorite", - "To invite users into the room": "To invite users into the room", "to join the discussion": "to join the discussion", - "To kick users": "To kick users", "To link to a room it must have": "To link to a room it must have", "to make a room or": "to make a room or", - "To remove other users' messages": "To remove other users' messages", "To reset your password, enter the email address linked to your account": "To reset your password, enter the email address linked to your account", "to restore": "to restore", - "To send events of type": "To send events of type", - "To send messages": "To send messages", "to start a chat with someone": "to start a chat with someone", "to tag direct chat": "to tag direct chat", "To use it, just wait for autocomplete results to load and tab through them.": "To use it, just wait for autocomplete results to load and tab through them.", @@ -656,6 +649,13 @@ "Verify...": "Verify...", "ex. @bob:example.com": "ex. @bob:example.com", "Add User": "Add User", + "To send messages, you must be a": "To send messages, you must be a", + "To invite users into the room, you must be a": "To invite users into the room, you must be a", + "To configure the room, you must be a": "To configure the room, you must be a", + "To kick users, you must be a": "To kick users, you must be a", + "To ban users, you must be a": "To ban users, you must be a", + "To remove other users' messages, you must be a": "To remove other users' messages, you must be a", + "To send events of type , you must be a": "To send events of type , you must be a", "This Home Server would like to make sure you are not a robot": "This Home Server would like to make sure you are not a robot", "Sign in with CAS": "Sign in with CAS", "Custom Server Options": "Custom Server Options", diff --git a/src/i18n/strings/es.json b/src/i18n/strings/es.json index bc2391a5c7..9838b915a4 100644 --- a/src/i18n/strings/es.json +++ b/src/i18n/strings/es.json @@ -470,16 +470,11 @@ "This room is not accessible by remote Matrix servers": "Esta sala no es accesible por otros servidores Matrix", "This room's internal ID is": "El ID interno de la sala es", "times": "veces", - "To ban users": "Expulsar usuarios", "to browse the directory": "navegar el directorio", - "To configure the room": "Configurar la sala", "to demote": "degradar", "to favourite": "marcar como favorito", - "To invite users into the room": "Invitar usuarios a la sala", - "To kick users": "Patear usuarios", "To link to a room it must have an address.": "Para enlazar una sala, debe tener una dirección.", "to make a room or": "hacer una sala o", - "To remove other users' messages": "Eliminar los mensajes de otros usuarios", "To reset your password, enter the email address linked to your account": "Para reiniciar su contraseña, introduzca el e-mail asociado a su cuenta", "to restore": "restaurar", "Cancel": "Cancelar", @@ -505,8 +500,6 @@ "Authentication check failed: incorrect password?": "La verificación de la autentificación ha fallado: ¿El password es el correcto?", "And %(count)s more...": "Y %(count)s más...", "Press to start a chat with someone": "Pulsa para empezar a charlar con alguien", - "To send events of type": "Para enviar eventos de tipo", - "To send messages": "Para enviar mensajes", "to start a chat with someone": "para empezar a charlar con alguien", "to tag direct chat": "para etiquetar como charla directa", "Add a widget": "Añadir widget", diff --git a/src/i18n/strings/eu.json b/src/i18n/strings/eu.json index 9f3d06ec52..fb2ec9f7b7 100644 --- a/src/i18n/strings/eu.json +++ b/src/i18n/strings/eu.json @@ -464,20 +464,13 @@ "This room is not accessible by remote Matrix servers": "Gela hau ez dago eskuragarri urruneko zerbitzarietan", "This room's internal ID is": "Gela honen barne ID-a:", "times": "aldi", - "To ban users": "Erabiltzaileak debekatzea", "to browse the directory": "direktorioa arakatzea", - "To configure the room": "Gela konfiguratzea", "to demote": "mailaz jaistea", "to favourite": "gogoko egitea", - "To invite users into the room": "Erabiltzaileak gela honetara gonbidatzea", - "To kick users": "Erabiltzaileak kaleratzea", "To link to a room it must have an address.": "Gelara estekatzeko honek helbide bat izan behar du.", "to make a room or": "gela bat egitea edo", - "To remove other users' messages": "Beste erabiltzaileen mezuak kentzea", "To reset your password, enter the email address linked to your account": "Zure pasahitza berrezartzeko, sartu zure kontuarekin lotutako e-mail helbidea", "to restore": "berreskuratzea", - "To send events of type": "Mota honetako gertaerak bidaltzea:", - "To send messages": "Mezuak bidaltzea", "to start a chat with someone": "norbaitekin txat bat hastea", "to tag direct chat": "txat zuzena etiketatzea", "To use it, just wait for autocomplete results to load and tab through them.": "Erabiltzeko, itxaron osatze automatikoaren emaitzak kargatu arte eta gero tabuladorearekin hautatu.", diff --git a/src/i18n/strings/fr.json b/src/i18n/strings/fr.json index 585e47f5a3..8ab78d0436 100644 --- a/src/i18n/strings/fr.json +++ b/src/i18n/strings/fr.json @@ -354,21 +354,14 @@ "This room is not accessible by remote Matrix servers": "Ce salon n’est pas accessible par les serveurs Matrix distants", "This room's internal ID is": "L'identifiant interne de ce salon est", "times": "fois", - "To ban users": "Pour bannir des utilisateurs", "to browse the directory": "pour parcourir le répertoire", - "To configure the room": "Pour configurer le salon", "to demote": "pour réduire la priorité", "to favourite": "pour marquer comme favori", - "To invite users into the room": "Pour inviter des utilisateurs dans le salon", "to join the discussion": "pour rejoindre la discussion", - "To kick users": "Pour expulser des utilisateurs", "To link to a room it must have": "Pour avoir un lien vers un salon, il doit avoir", "to make a room or": "pour créer un salon ou", - "To remove other users' messages": "Pour supprimer les messages des autres utilisateurs", "To reset your password, enter the email address linked to your account": "Pour réinitialiser votre mot de passe, merci d’entrer l’adresse e-mail liée à votre compte", "to restore": "pour restaurer", - "To send events of type": "Pour envoyer des évènements du type", - "To send messages": "Pour envoyer des messages", "to start a chat with someone": "pour démarrer une discussion avec quelqu’un", "to tag direct chat": "pour marquer comme conversation directe", "To use it, just wait for autocomplete results to load and tab through them.": "Pour l’utiliser, attendez simplement que les résultats de l’auto-complétion s’affichent et défilez avec la touche Tab.", diff --git a/src/i18n/strings/hu.json b/src/i18n/strings/hu.json index 2c34e05b1a..fb295535ca 100644 --- a/src/i18n/strings/hu.json +++ b/src/i18n/strings/hu.json @@ -432,19 +432,12 @@ "This room is not accessible by remote Matrix servers": "Ez a szoba távoli Matrix szerverről nem érhető el", "This room's internal ID is": "A szoba belső azonosítója:", "times": "alkalommal", - "To ban users": "Felhasználó kizárásához", "to browse the directory": "a könyvtárban való kereséshez", - "To configure the room": "A szoba beállításához", "to favourite": "kedvencekhez", - "To invite users into the room": "Felhasználó szobába való meghívásához", - "To kick users": "Felhasználó kirúgásához", "To link to a room it must have an address.": "Szobához való kötéshez szükséges egy cím.", "to make a room or": "szoba létrehozásához vagy", - "To remove other users' messages": "Más felhasználók üzeneteinek törléséhez", "To reset your password, enter the email address linked to your account": "A jelszó alaphelyzetbe állításához add meg a fiókodhoz kötött e-mail címet", "to restore": "visszaállításhoz", - "To send events of type": "Az alábbi típusú üzenetek küldéséhez", - "To send messages": "Üzenetek küldéséhez", "to start a chat with someone": "csevegés indításához valakivel", "to tag direct chat": "megjelölni közvetlen csevegésnek", "To use it, just wait for autocomplete results to load and tab through them.": "A használatához csak várd meg az automatikus kiegészítéshez a találatok betöltését és TAB-bal választhatsz közülük.", diff --git a/src/i18n/strings/ko.json b/src/i18n/strings/ko.json index 8b6e233437..96655ccf4f 100644 --- a/src/i18n/strings/ko.json +++ b/src/i18n/strings/ko.json @@ -434,20 +434,13 @@ "This room is not accessible by remote Matrix servers": "이 방은 원격 매트릭스 서버에 접근할 수 없어요", "This room's internal ID is": "방의 내부 ID", "times": "번", - "To ban users": "사용자를 차단하기", "to browse the directory": "목록에서 찾으려면", - "To configure the room": "방을 구성하기", "to demote": "우선순위 낮추기", "to favourite": "즐겨찾기", - "To invite users into the room": "방으로 사용자를 초대하기", - "To kick users": "사용자를 내쫓기", "To link to a room it must have an address.": "방에 연결하려면 주소가 있어야 해요.", "to make a room or": "방을 만들거나 혹은", - "To remove other users' messages": "다른 사용자의 메시지를 지우기", "To reset your password, enter the email address linked to your account": "비밀번호을 다시 설정하려면, 계정과 연결한 이메일 주소를 입력해주세요", "to restore": "복구하려면", - "To send events of type": "유형 이벤트 보내기", - "To send messages": "메시지 보내기", "to start a chat with someone": "다른 사람과 이야기하기", "to tag direct chat": "직접 이야기를 지정하려면", "To use it, just wait for autocomplete results to load and tab through them.": "이 기능을 사용하시려면, 자동완성 결과가 나오길 기다리신 뒤에 탭으로 움직여주세요.", diff --git a/src/i18n/strings/lv.json b/src/i18n/strings/lv.json index 5f58fd9515..fea8065a5f 100644 --- a/src/i18n/strings/lv.json +++ b/src/i18n/strings/lv.json @@ -502,20 +502,13 @@ "This room is not accessible by remote Matrix servers": "Šī istaba nav pieejama no attālinātajiem Matrix serveriem", "This room's internal ID is": "Šīs istabas iekšējais ID ir", "times": "reizes", - "To ban users": "lai banotu lietotājus", "to browse the directory": "lai pārlūkotu katalogu", - "To configure the room": "Lai konfigurētu istabu", "to demote": "lai samazinātu", "to favourite": "lai pievienotu favorītiem", - "To invite users into the room": "Lai uzaicinātu lietotājus uz istabu", - "To kick users": "Lai \"iespertu\" (kicks) lietotājiem", "To link to a room it must have an address.": "Lai ieliktu saiti uz istabu, tai ir jābūt piešķirtai adresei.", "to make a room or": "lai izveidotu istabu vai", - "To remove other users' messages": "Lai dzēstu citu lietotāju ziņas", "To reset your password, enter the email address linked to your account": "Lai atiestatītu savu paroli, ievadi tavam kontam piesaistīto epasta adresi", "to restore": "lai atjaunotu", - "To send events of type": "Lai sūtītu sekojošā tipa notikumus", - "To send messages": "Lai nosūtītu ziņas", "to start a chat with someone": "lai uzstāktu čatu ar kādu", "to tag direct chat": "lai pieliktu birku tiešajam čatam", "To use it, just wait for autocomplete results to load and tab through them.": "Lai to izmantotu, vienkārši gaidi, kamēr ielādējas automātiski ieteiktie rezultāti, un pārvietojies caur tiem.", diff --git a/src/i18n/strings/nl.json b/src/i18n/strings/nl.json index f770e335cf..10f7f4900e 100644 --- a/src/i18n/strings/nl.json +++ b/src/i18n/strings/nl.json @@ -459,20 +459,13 @@ "This room is not accessible by remote Matrix servers": "Deze ruimte is niet toegankelijk voor afgelegen Matrix-servers", "This room's internal ID is": "Het interne ID van deze ruimte is", "times": "keer", - "To ban users": "om gebruikers te verbannen", "to browse the directory": "om de catalogus door te bladeren", - "To configure the room": "Om de ruimte te configureren", "to demote": "om te degraderen", "to favourite": "om aan favorieten toe te voegen", - "To invite users into the room": "Om gebruikers in deze ruimte toe te voegen", - "To kick users": "Om gebruikers er uit te zetten", "To link to a room it must have an address.": "Om naar een ruimte te linken moet het een adres hebben.", "to make a room or": "om een ruimte te maken of", - "To remove other users' messages": "Om berichten van anderen gebruikers te verwijderen", "To reset your password, enter the email address linked to your account": "Voer het e-mailadres dat met je account verbonden is in om je wachtwoord opnieuw in te stellen", "to restore": "om te herstellen", - "To send events of type": "Om een bepaalde soort gebeurtenissen te sturen", - "To send messages": "Om berichten te versturen", "to start a chat with someone": "om een gesprek met iemand te starten", "to tag direct chat": "als directe chat etiketteren", "To use it, just wait for autocomplete results to load and tab through them.": "Om het te gebruiken, wacht tot de automatisch aangevulde resultaten geladen zijn en tab er doorheen.", diff --git a/src/i18n/strings/pl.json b/src/i18n/strings/pl.json index bd1e4c5c24..0805c8fb66 100644 --- a/src/i18n/strings/pl.json +++ b/src/i18n/strings/pl.json @@ -515,20 +515,13 @@ "This room is not accessible by remote Matrix servers": "Ten pokój nie jest dostępny na zdalnych serwerach Matrix", "This room's internal ID is": "Wewnętrzne ID tego pokoju to", "times": "razy", - "To ban users": "Żeby zablokować użytkowników", "to browse the directory": "żeby przeglądać katalog", - "To configure the room": "Żeby skonfigurować pokój", "to demote": "żeby zmniejszyć priorytet", "To get started, please pick a username!": "Aby rozpocząć, wybierz nazwę użytkownika!", - "To invite users into the room": "Żeby zaprosić użytkowników do pokoju", - "To kick users": "Żeby usuwać użytkowników", "to make a room or": "żeby utworzyć pokój lub", - "To remove other users' messages": "Żeby usuwać wiadomości innych użytkowników", "To reset your password, enter the email address linked to your account": "Aby zresetować swoje hasło, wpisz adres e-mail powiązany z twoim kontem", "to restore": "żeby przywrócić", - "To send messages": "Żeby wysyłać wiadomości", "to start a chat with someone": "żeby zacząć rozmowę z kimś", - "To send events of type": "Żeby wysyłać wydarzenia typu", "to tag direct chat": "żeby oznaczyć rozmowę bezpośrednią", "Turn Markdown off": "Wyłącz Markdown", "Turn Markdown on": "Włącz Markdown", diff --git a/src/i18n/strings/pt.json b/src/i18n/strings/pt.json index ba4968b7ad..a1e4cce4e9 100644 --- a/src/i18n/strings/pt.json +++ b/src/i18n/strings/pt.json @@ -215,16 +215,10 @@ "This room is not accessible by remote Matrix servers": "Esta sala não é acessível para servidores Matrix remotos", "This room's internal ID is": "O ID interno desta sala é", "times": "vezes", - "To ban users": "Para banir usuárias/os", - "To configure the room": "Para poder configurar a sala", - "To invite users into the room": "Para convidar usuárias/os para esta sala", "to join the discussion": "para se juntar à conversa", - "To kick users": "Para poder remover pessoas da sala", "To link to a room it must have": "Para fazer um link para uma sala, ela deve ter", "To redact messages": "Para poder apagar mensagens", "To reset your password, enter the email address linked to your account": "Para redefinir sua senha, entre com o email da sua conta", - "To send events of type": "Para enviar eventos do tipo", - "To send messages": "Para enviar mensagens", "turned on end-to-end encryption (algorithm": "acionou a encriptação ponta-a-ponta (algoritmo", "Unable to add email address": "Não foi possível adicionar endereço de email", "Unable to remove contact information": "Não foi possível remover informação de contato", @@ -365,7 +359,6 @@ "to demote": "para reduzir prioridade", "to favourite": "para favoritar", "to make a room or": "para criar uma sala ou", - "To remove other users' messages": "Para apagar mensagens de outras pessoas", "to restore": "para restaurar", "to start a chat with someone": "para iniciar uma conversa com alguém", "to tag direct chat": "para marcar a conversa como pessoal", diff --git a/src/i18n/strings/pt_BR.json b/src/i18n/strings/pt_BR.json index af4804bd85..0cefe77aa6 100644 --- a/src/i18n/strings/pt_BR.json +++ b/src/i18n/strings/pt_BR.json @@ -215,16 +215,10 @@ "This room is not accessible by remote Matrix servers": "Esta sala não é acessível para servidores Matrix remotos", "This room's internal ID is": "O ID interno desta sala é", "times": "vezes", - "To ban users": "Para banir usuárias/os", - "To configure the room": "Para poder configurar a sala", - "To invite users into the room": "Para convidar usuárias/os para esta sala", "to join the discussion": "para se juntar à conversa", - "To kick users": "Para poder remover pessoas da sala", "To link to a room it must have": "Para fazer um link para uma sala, ela deve ter", "To redact messages": "Para poder apagar mensagens", "To reset your password, enter the email address linked to your account": "Para redefinir sua senha, entre com o email da sua conta", - "To send events of type": "Para enviar eventos do tipo", - "To send messages": "Para enviar mensagens", "turned on end-to-end encryption (algorithm": "acionou a encriptação ponta-a-ponta (algoritmo", "Unable to add email address": "Não foi possível adicionar endereço de email", "Unable to remove contact information": "Não foi possível remover informação de contato", @@ -364,7 +358,6 @@ "to demote": "para reduzir prioridade", "to favourite": "para favoritar", "to make a room or": "para criar uma sala ou", - "To remove other users' messages": "Para apagar mensagens de outras pessoas", "to restore": "para restaurar", "to start a chat with someone": "para iniciar uma conversa com alguém", "to tag direct chat": "para marcar a conversa como pessoal", diff --git a/src/i18n/strings/ru.json b/src/i18n/strings/ru.json index cfab960e32..3ff06070c3 100644 --- a/src/i18n/strings/ru.json +++ b/src/i18n/strings/ru.json @@ -155,8 +155,6 @@ "Start Chat": "Начать чат", "tag as": "tag as", "These are experimental features that may break in unexpected ways. Use with caution": "These are experimental features that may break in unexpected ways. Use with caution", - "To send events of type": "Чтобы отправить тип события", - "To send messages": "Чтобы отправить сообщения", "turned on end-to-end encryption (algorithm": "turned on end-to-end encryption (algorithm", "Unable to add email address": "Не удается добавить адрес электронной почты", "Unable to remove contact information": "Не удалось удалить контактную информацию", @@ -596,15 +594,10 @@ "The visibility of existing history will be unchanged": "Видимость существующей истории не изменится", "this invitation?": "это приглашение?", "This room is not accessible by remote Matrix servers": "Это комната недоступна с удаленных серверов Matrix", - "To ban users": "Для блокировки пользователей", "to browse the directory": "для просмотра каталога", - "To configure the room": "Для настройки комнаты", - "To invite users into the room": "Чтобы приглашать пользователей в комнату", "to join the discussion": "присоединиться к дискуссии", - "To kick users": "Чтобы удалять пользователей", "To link to a room it must have": "Для создания ссылки на комнату она должна иметь", "to make a room or": "чтобы создать комнату или", - "To remove other users' messages": "Чтобы удалить сообщения других пользователей", "To reset your password, enter the email address linked to your account": "Чтобы сбросить пароль, введите адрес электронной почты, связанный с вашей учетной записью", "Tried to load a specific point in this room's timeline, but you do not have permission to view the message in question.": "Попытка загрузить выбранный интервал истории чата этой комнаты не удалась, так как у вас нет разрешений на просмотр.", "Tried to load a specific point in this room's timeline, but was unable to find it.": "Попытка загрузить выбранный интервал истории чата этой комнаты не удалась, так как запрошенный элемент не найден.", diff --git a/src/i18n/strings/th.json b/src/i18n/strings/th.json index d45cb86986..9ff6e5b151 100644 --- a/src/i18n/strings/th.json +++ b/src/i18n/strings/th.json @@ -323,7 +323,6 @@ "The phone number entered looks invalid": "ดูเหมือนว่าหมายเลขโทรศัพท์ที่กรอกรมาไม่ถูกต้อง", "The email address linked to your account must be entered.": "กรุณากรอกที่อยู่อีเมลที่เชื่อมกับบัญชีของคุณ", "The file '%(fileName)s' exceeds this home server's size limit for uploads": "ไฟล์ '%(fileName)s' มีขนาดใหญ่เกินจำกัดของเซิร์ฟเวอร์บ้าน", - "To send messages": "เพื่อส่งข้อความ", "to start a chat with someone": "เพื่อเริ่มแชทกับผู้อื่น", "to tag direct chat": "เพื่อแทกว่าแชทตรง", "Turn Markdown off": "ปิด markdown", @@ -488,13 +487,8 @@ "Otherwise, click here to send a bug report.": "หรือคลิกที่นี่เพื่อรายงานจุดบกพร่อง", "Power level must be positive integer.": "ระดับอำนาจต้องเป็นจำนวนเต็มบวก", "%(roomName)s does not exist.": "ไม่มีห้อง %(roomName)s อยู่จริง", - "To ban users": "จะแบนผู้ใช้ได้", - "To configure the room": "จะตั้งค่าห้องนี้ได้", "to browse the directory": "เพื่อเรียกดูไดเรกทอรี", - "To invite users into the room": "จะเชิญผู้ใช้เข้าห้องได้", - "To kick users": "จะเตะผู้ใช้ได้", "To link to a room it must have an address.": "ห้องต้องมีที่อยู่ก่อน ถึงจะลิงก์ได้", - "To remove other users' messages": "จะลบข้อความของผู้ใช้อื่นได้", "Enter passphrase": "กรอกรหัสผ่าน", "Seen by %(userName)s at %(dateTime)s": "%(userName)s เห็นแล้วเมื่อเวลา %(dateTime)s", "to restore": "เพื่อกู้คืน", diff --git a/src/i18n/strings/tr.json b/src/i18n/strings/tr.json index 23d4e284bc..5c1017d177 100644 --- a/src/i18n/strings/tr.json +++ b/src/i18n/strings/tr.json @@ -415,20 +415,13 @@ "This room is not accessible by remote Matrix servers": "Bu oda uzak Matrix Sunucuları tarafından erişilebilir değil", "This room's internal ID is": "Bu odanın Dahili ID'si", "times": "kere", - "To ban users": "Kullanıcıları yasaklamak(Ban) için", "to browse the directory": "Dizine göz atmak için", - "To configure the room": "Odayı yapılandırmak için", "to demote": "indirgemek için", "to favourite": "favorilemek", - "To invite users into the room": "Kullanıcıları odaya davet etmek", - "To kick users": "Kullanıcıları atmak", "To link to a room it must have an address.": "Bir odaya bağlanmak için oda bir adrese sahip olmalı.", "to make a room or": "bir oda oluşturmak için ya da", - "To remove other users' messages": "Diğer kullanıcıların mesajlarını silmek için", "To reset your password, enter the email address linked to your account": "Parolanızı sıfırlamak için hesabınıza bağlı e-posta adresinizi girin", "to restore": "yenilemek için", - "To send events of type": "Tip olayını göndermek için", - "To send messages": "Mesaj göndermek için", "to start a chat with someone": "birisiyle sohbet başlatmak için", "to tag direct chat": "doğrudan sohbeti etiketlemek için", "To use it, just wait for autocomplete results to load and tab through them.": "Kullanmak için , otomatik tamamlama sonuçlarının yüklenmesini ve bitmesini bekleyin.", diff --git a/src/i18n/strings/zh_Hant.json b/src/i18n/strings/zh_Hant.json index 596bc55a01..cad8834052 100644 --- a/src/i18n/strings/zh_Hant.json +++ b/src/i18n/strings/zh_Hant.json @@ -483,20 +483,13 @@ "This room is not accessible by remote Matrix servers": "此房間無法被遠端的 Matrix 伺服器存取", "This room's internal ID is": "此房間的內部 ID 為", "times": "次數", - "To ban users": "要禁止使用者", "to browse the directory": "要瀏覽目錄", - "To configure the room": "要設定房間", "to demote": "要降級", "to favourite": "到喜歡", - "To invite users into the room": "要邀請使用者進入此房間", - "To kick users": "要踢出使用者", "To link to a room it must have an address.": "要連結到房間,它必須有地址。", "to make a room or": "要開房間或", - "To remove other users' messages": "要移除其他使用者的訊息", "To reset your password, enter the email address linked to your account": "要重設您的密碼,輸入連結到您的帳號的電子郵件地址", "to restore": "要復原", - "To send events of type": "要傳送活動類型", - "To send messages": "要傳送訊息", "to start a chat with someone": "要開始與某人聊天", "to tag direct chat": "要標記直接聊天", "To use it, just wait for autocomplete results to load and tab through them.": "要使用它,只要等待自動完成的結果載入並在它們上面按 Tab。", From 614cf950b63fc64a15f51bf1324eb99bc764eda9 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 14:45:00 -0600 Subject: [PATCH 08/28] Supply user-friendly labels for common events Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 15 ++++++++++++++- src/i18n/strings/en_EN.json | 5 +++++ src/i18n/strings/en_US.json | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 942da9ba06..412f67fc23 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -35,6 +35,16 @@ function parseIntWithDefault(val, def) { return isNaN(res) ? def : res; } +const plEventsToLabels = { + // These will be translated for us later. + // TODO: _td() these when https://github.com/matrix-org/matrix-react-sdk/pull/1421 lands + "m.room.avatar": "To change the room's avatar, you must be a", + "m.room.name": "To change the room's name, you must be a", + "m.room.canonical_alias": "To change the room's main address, you must be a", + "m.room.history_visibility": "To change the room's history visibility, you must be a", + "m.room.power_levels": "To change the permissions in the room, you must be a", +}; + const BannedUser = React.createClass({ propTypes: { canUnban: React.PropTypes.bool, @@ -885,9 +895,12 @@ module.exports = React.createClass({ {Object.keys(events_levels).map(function(event_type, i) { + let label = plEventsToLabels[event_type]; + if (label) label = _t(label); + else label = _tJsx("To send events of type , you must be a", //, () => { event_type }); return (
- { _tJsx("To send events of type , you must be a", //, () => { event_type }) } + { label }
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8873b54091..6309e60e82 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -832,6 +832,11 @@ "To ban users, you must be a": "To ban users, you must be a", "To remove other users' messages, you must be a": "To remove other users' messages, you must be a", "To send events of type , you must be a": "To send events of type , you must be a", + "To change the room's avatar, you must be a": "To change the room's avatar, you must be a", + "To change the room's name, you must be a": "To change the room's name, you must be a", + "To change the room's main address, you must be a": "To change the room's main address, you must be a", + "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", + "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", "Error whilst fetching joined groups": "Error whilst fetching joined groups", "Featured Users:": "Featured Users:", "Edit Group": "Edit Group", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index c3b3b6a1bc..7f99f7789c 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -656,6 +656,11 @@ "To ban users, you must be a": "To ban users, you must be a", "To remove other users' messages, you must be a": "To remove other users' messages, you must be a", "To send events of type , you must be a": "To send events of type , you must be a", + "To change the room's avatar, you must be a": "To change the room's avatar, you must be a", + "To change the room's name, you must be a": "To change the room's name, you must be a", + "To change the room's main address, you must be a": "To change the room's main address, you must be a", + "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", + "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", "This Home Server would like to make sure you are not a robot": "This Home Server would like to make sure you are not a robot", "Sign in with CAS": "Sign in with CAS", "Custom Server Options": "Custom Server Options", From 8ab3d94c1ce3b972a77da331d910189256503996 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 15:11:48 -0600 Subject: [PATCH 09/28] Always show common events in the PL section of room settings Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 412f67fc23..59b05dc4ac 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -45,6 +45,15 @@ const plEventsToLabels = { "m.room.power_levels": "To change the permissions in the room, you must be a", }; +const plEventsToShow = { + // If an event is listed here, it will be shown in the PL settings. Defaults will be calculated. + "m.room.avatar": {isState: true}, + "m.room.name": {isState: true}, + "m.room.canonical_alias": {isState: true}, + "m.room.history_visibility": {isState: true}, + "m.room.power_levels": {isState: true}, +} + const BannedUser = React.createClass({ propTypes: { canUnban: React.PropTypes.bool, @@ -556,6 +565,14 @@ module.exports = React.createClass({ this.forceUpdate(); }, + _populateDefaultPlEvents: function(eventsSection, stateLevel, eventsLevel) { + for (let desiredEvent of Object.keys(plEventsToShow)) { + if (!(desiredEvent in eventsSection)) { + eventsSection[desiredEvent] = (plEventsToShow[desiredEvent].isState ? stateLevel : eventsLevel); + } + } + }, + _renderEncryptionSection: function() { var cli = MatrixClientPeg.get(); var roomState = this.props.room.currentState; @@ -626,6 +643,8 @@ module.exports = React.createClass({ var state_level = power_level_event ? parseIntWithDefault(power_levels.state_default, 50) : 0; var default_user_level = parseIntWithDefault(power_levels.users_default, 0); + this._populateDefaultPlEvents(events_levels, state_level, send_level); + var current_user_level = user_levels[user_id]; if (current_user_level === undefined) { current_user_level = default_user_level; From 8ee9d39ffa19adb7182d8e61a9831bf2975cea52 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 15:12:05 -0600 Subject: [PATCH 10/28] Expose option for m.room.topic power level Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 2 ++ src/i18n/strings/en_EN.json | 1 + src/i18n/strings/en_US.json | 1 + 3 files changed, 4 insertions(+) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 59b05dc4ac..f1dcfbfc64 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -43,6 +43,7 @@ const plEventsToLabels = { "m.room.canonical_alias": "To change the room's main address, you must be a", "m.room.history_visibility": "To change the room's history visibility, you must be a", "m.room.power_levels": "To change the permissions in the room, you must be a", + "m.room.topic": "To change the topic, you must be a", }; const plEventsToShow = { @@ -52,6 +53,7 @@ const plEventsToShow = { "m.room.canonical_alias": {isState: true}, "m.room.history_visibility": {isState: true}, "m.room.power_levels": {isState: true}, + "m.room.topic": {isState: true}, } const BannedUser = React.createClass({ diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6309e60e82..ee1bed814a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -837,6 +837,7 @@ "To change the room's main address, you must be a": "To change the room's main address, you must be a", "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", + "To change the topic, you must be a": "To change the topic, you must be a", "Error whilst fetching joined groups": "Error whilst fetching joined groups", "Featured Users:": "Featured Users:", "Edit Group": "Edit Group", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 7f99f7789c..a1dd9d53cc 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -661,6 +661,7 @@ "To change the room's main address, you must be a": "To change the room's main address, you must be a", "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", + "To change the topic, you must be a": "To change the topic, you must be a", "This Home Server would like to make sure you are not a robot": "This Home Server would like to make sure you are not a robot", "Sign in with CAS": "Sign in with CAS", "Custom Server Options": "Custom Server Options", From 20798dd2fa161d4e24229ef0f8fbf33e3ac08e06 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 15:22:37 -0600 Subject: [PATCH 11/28] Expose power level setting for widgets Fixes https://github.com/vector-im/riot-web/issues/4866 Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 4 ++++ src/i18n/strings/en_EN.json | 1 + src/i18n/strings/en_US.json | 1 + 3 files changed, 6 insertions(+) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index f1dcfbfc64..e3fe50713b 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -44,6 +44,8 @@ const plEventsToLabels = { "m.room.history_visibility": "To change the room's history visibility, you must be a", "m.room.power_levels": "To change the permissions in the room, you must be a", "m.room.topic": "To change the topic, you must be a", + + "im.vector.modular.widgets": "To modify widgets in the room, you must be a", }; const plEventsToShow = { @@ -54,6 +56,8 @@ const plEventsToShow = { "m.room.history_visibility": {isState: true}, "m.room.power_levels": {isState: true}, "m.room.topic": {isState: true}, + + "im.vector.modular.widgets": {isState: true}, } const BannedUser = React.createClass({ diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ee1bed814a..792626ca7c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -838,6 +838,7 @@ "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", "To change the topic, you must be a": "To change the topic, you must be a", + "To modify widgets in the room, you must be a": "To modify widgets in the room, you must be a", "Error whilst fetching joined groups": "Error whilst fetching joined groups", "Featured Users:": "Featured Users:", "Edit Group": "Edit Group", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index a1dd9d53cc..8a78a18407 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -662,6 +662,7 @@ "To change the room's history visibility, you must be a": "To change the room's history visibility, you must be a", "To change the permissions in the room, you must be a": "To change the permissions in the room, you must be a", "To change the topic, you must be a": "To change the topic, you must be a", + "To modify widgets in the room, you must be a": "To modify widgets in the room, you must be a", "This Home Server would like to make sure you are not a robot": "This Home Server would like to make sure you are not a robot", "Sign in with CAS": "Sign in with CAS", "Custom Server Options": "Custom Server Options", From 38de4ae1524bb34e3d54b0c12f802ac2f4c95097 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 5 Oct 2017 08:00:22 +0100 Subject: [PATCH 12/28] delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/CreateRoomDialog.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index 20eeb5b591..d5a99dd4bf 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -48,21 +48,21 @@ export default React.createClass({ >
- +
- +
-
+
{ _t('Advanced options') }
- +
From c115980f21c83c598786f4deed375a1b469b6b53 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 5 Oct 2017 08:08:39 +0100 Subject: [PATCH 13/28] remove redundant&stale onKeyDown 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 d5a99dd4bf..f7be47b3eb 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -51,7 +51,7 @@ export default React.createClass({
- +

From a8231f7bf9b8a0d3bdaf7fc1d6ce6ee1d61df4dc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 5 Oct 2017 08:26:57 +0100 Subject: [PATCH 14/28] Remove redundant stale onKeyDown Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/TextInputDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/TextInputDialog.js b/src/components/views/dialogs/TextInputDialog.js index c924da7745..5ea4191e5e 100644 --- a/src/components/views/dialogs/TextInputDialog.js +++ b/src/components/views/dialogs/TextInputDialog.js @@ -68,7 +68,7 @@ export default React.createClass({
- +
From 917957c1dcb8911c2013fa8862a885a26227f3c1 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 5 Oct 2017 14:30:04 +0100 Subject: [PATCH 15/28] Modify the group store to include group rooms and modify components to use this new part of the store such that feedback can be given when adding or removing a room from the room list. --- .../views/dialogs/AddressPickerDialog.js | 42 ++++++++----------- src/components/views/groups/GroupRoomList.js | 39 +++++++++-------- src/components/views/groups/GroupRoomTile.js | 5 ++- src/stores/GroupStore.js | 26 +++++++++++- src/stores/GroupStoreCache.js | 1 + 5 files changed, 68 insertions(+), 45 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 6a027ac034..2637f9d466 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -23,6 +23,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg'; import AccessibleButton from '../elements/AccessibleButton'; import Promise from 'bluebird'; import { addressTypes, getAddressType } from '../../../UserAddress.js'; +import GroupStoreCache from '../../../stores/GroupStoreCache'; const TRUNCATE_QUERY_LIST = 40; const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200; @@ -241,32 +242,25 @@ module.exports = React.createClass({ _doNaiveGroupRoomSearch: function(query) { const lowerCaseQuery = query.toLowerCase(); - MatrixClientPeg.get().getGroupRooms(this.props.groupId).then((resp) => { - const results = []; - resp.chunk.forEach((r) => { - const nameMatch = (r.name || '').toLowerCase().includes(lowerCaseQuery); - const topicMatch = (r.topic || '').toLowerCase().includes(lowerCaseQuery); - const aliasMatch = (r.canonical_alias || '').toLowerCase().includes(lowerCaseQuery); - if (!(nameMatch || topicMatch || aliasMatch)) { - return; - } - results.push({ - room_id: r.room_id, - avatar_url: r.avatar_url, - name: r.name || r.canonical_alias, - }); - }); - this._processResults(results, query); - }).catch((err) => { - console.error('Error whilst searching group users: ', err); - this.setState({ - searchError: err.errcode ? err.message : _t('Something went wrong!'), - }); - }).done(() => { - this.setState({ - busy: false, + const groupStore = GroupStoreCache.getGroupStore(MatrixClientPeg.get(), this.props.groupId); + const results = []; + groupStore.getGroupRooms().forEach((r) => { + const nameMatch = (r.name || '').toLowerCase().includes(lowerCaseQuery); + const topicMatch = (r.topic || '').toLowerCase().includes(lowerCaseQuery); + const aliasMatch = (r.canonical_alias || '').toLowerCase().includes(lowerCaseQuery); + if (!(nameMatch || topicMatch || aliasMatch)) { + return; + } + results.push({ + room_id: r.room_id, + avatar_url: r.avatar_url, + name: r.name || r.canonical_alias, }); }); + this._processResults(results, query); + this.setState({ + busy: false, + }); }, _doRoomSearch: function(query) { diff --git a/src/components/views/groups/GroupRoomList.js b/src/components/views/groups/GroupRoomList.js index 39ff3e4a07..4ff68a7f4d 100644 --- a/src/components/views/groups/GroupRoomList.js +++ b/src/components/views/groups/GroupRoomList.js @@ -17,6 +17,7 @@ import React from 'react'; import { _t } from '../../../languageHandler'; import sdk from '../../../index'; import { groupRoomFromApiObject } from '../../../groups'; +import GroupStoreCache from '../../../stores/GroupStoreCache'; import GeminiScrollbar from 'react-gemini-scrollbar'; import PropTypes from 'prop-types'; import {MatrixClient} from 'matrix-js-sdk'; @@ -34,7 +35,6 @@ export default React.createClass({ getInitialState: function() { return { - fetching: false, rooms: null, truncateAt: INITIAL_LOAD_NUM_ROOMS, searchQuery: "", @@ -43,21 +43,29 @@ export default React.createClass({ componentWillMount: function() { this._unmounted = false; + this._initGroupStore(this.props.groupId); + }, + + _initGroupStore: function(groupId) { + this._groupStore = GroupStoreCache.getGroupStore(this.context.matrixClient, groupId); + this._groupStore.on('update', () => { + this._fetchRooms(); + }); + this._groupStore.on('error', (err) => { + console.error('Error in group store (listened to by GroupRoomList)', err); + this.setState({ + rooms: null, + }); + }); this._fetchRooms(); }, _fetchRooms: function() { - this.setState({fetching: true}); - this.context.matrixClient.getGroupRooms(this.props.groupId).then((result) => { - this.setState({ - rooms: result.chunk.map((apiRoom) => { - return groupRoomFromApiObject(apiRoom); - }), - fetching: false, - }); - }).catch((e) => { - this.setState({fetching: false}); - console.error("Failed to get group room list: ", e); + if (this._unmounted) return; + this.setState({ + rooms: this._groupStore.getGroupRooms().map((apiRoom) => { + return groupRoomFromApiObject(apiRoom); + }), }); }, @@ -110,12 +118,7 @@ export default React.createClass({ }, render: function() { - if (this.state.fetching) { - const Spinner = sdk.getComponent("elements.Spinner"); - return (
- -
); - } else if (this.state.rooms === null) { + if (this.state.rooms === null) { return null; } diff --git a/src/components/views/groups/GroupRoomTile.js b/src/components/views/groups/GroupRoomTile.js index b6bdb9735b..bb0fdb03f4 100644 --- a/src/components/views/groups/GroupRoomTile.js +++ b/src/components/views/groups/GroupRoomTile.js @@ -21,6 +21,7 @@ import PropTypes from 'prop-types'; import sdk from '../../../index'; import dis from '../../../dispatcher'; import { GroupRoomType } from '../../../groups'; +import GroupStoreCache from '../../../stores/GroupStoreCache'; import Modal from '../../../Modal'; const GroupRoomTile = React.createClass({ @@ -49,10 +50,10 @@ const GroupRoomTile = React.createClass({ removeRoomFromGroup: function() { const groupId = this.props.groupId; + const groupStore = GroupStoreCache.getGroupStore(this.context.matrixClient, groupId); const roomName = this.state.name; const roomId = this.props.groupRoom.roomId; - this.context.matrixClient - .removeRoomFromGroup(groupId, roomId) + groupStore.removeRoomFromGroup(roomId) .catch((err) => { console.error(`Error whilst removing ${roomId} from ${groupId}`, err); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); diff --git a/src/stores/GroupStore.js b/src/stores/GroupStore.js index 941f4c8ec2..73118993f9 100644 --- a/src/stores/GroupStore.js +++ b/src/stores/GroupStore.js @@ -26,7 +26,9 @@ export default class GroupStore extends EventEmitter { this.groupId = groupId; this._matrixClient = matrixClient; this._summary = {}; + this._rooms = []; this._fetchSummary(); + this._fetchRooms(); } _fetchSummary() { @@ -38,6 +40,15 @@ export default class GroupStore extends EventEmitter { }); } + _fetchRooms() { + this._matrixClient.getGroupRooms(this.groupId).then((resp) => { + this._rooms = resp.chunk; + this._notifyListeners(); + }).catch((err) => { + this.emit('error', err); + }); + } + _notifyListeners() { this.emit('update'); } @@ -46,9 +57,22 @@ export default class GroupStore extends EventEmitter { return this._summary; } + getGroupRooms() { + return this._rooms; + } + addRoomToGroup(roomId) { return this._matrixClient - .addRoomToGroup(this.groupId, roomId); + .addRoomToGroup(this.groupId, roomId) + .then(this._fetchRooms.bind(this)); + } + + removeRoomFromGroup(roomId) { + return this._matrixClient + .removeRoomFromGroup(this.groupId, roomId) + // Room might be in the summary, refresh just in case + .then(this._fetchSummary.bind(this)) + .then(this._fetchRooms.bind(this)); } addRoomToGroupSummary(roomId, categoryId) { diff --git a/src/stores/GroupStoreCache.js b/src/stores/GroupStoreCache.js index bf340521b5..551b155615 100644 --- a/src/stores/GroupStoreCache.js +++ b/src/stores/GroupStoreCache.js @@ -28,6 +28,7 @@ class GroupStoreCache { // referencing it. this.groupStore = new GroupStore(matrixClient, groupId); } + this.groupStore._fetchSummary(); return this.groupStore; } } From 6a4e3792d4aa563c521eadfd1bc858a343894742 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 6 Oct 2017 12:07:38 +0100 Subject: [PATCH 16/28] split handlers into state and non-states Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index a21eb5c251..fa8efe028f 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -291,12 +291,15 @@ function textForWidgetEvent(event) { const handlers = { 'm.room.message': textForMessageEvent, - 'm.room.name': textForRoomNameEvent, - 'm.room.topic': textForTopicEvent, - 'm.room.member': textForMemberEvent, 'm.call.invite': textForCallInviteEvent, 'm.call.answer': textForCallAnswerEvent, 'm.call.hangup': textForCallHangupEvent, +}; + +const stateHandlers = { + 'm.room.name': textForRoomNameEvent, + 'm.room.topic': textForTopicEvent, + 'm.room.member': textForMemberEvent, 'm.room.third_party_invite': textForThreePidInviteEvent, 'm.room.history_visibility': textForHistoryVisibilityEvent, 'm.room.encryption': textForEncryptionEvent, @@ -307,8 +310,8 @@ const handlers = { module.exports = { textForEvent: function(ev) { - const hdlr = handlers[ev.getType()]; - if (!hdlr) return ''; - return hdlr(ev); + const handler = ev.isState() ? stateHandlers[ev.getType()] : handlers[ev.getType()]; + if (handler) return handler(ev); + return ''; }, }; From 91ba939e23eef52634a5618041008cbe30c73e2b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 6 Oct 2017 12:10:07 +0100 Subject: [PATCH 17/28] tiny bit of de-lint for consistency Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index fa8efe028f..ccb4c29a9c 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -243,7 +243,7 @@ function textForPowerEvent(event) { if (to !== from) { diff.push( _t('%(userId)s from %(fromPowerLevel)s to %(toPowerLevel)s', { - userId: userId, + userId, fromPowerLevel: Roles.textualPowerLevel(from, userDefault), toPowerLevel: Roles.textualPowerLevel(to, userDefault), }), @@ -254,7 +254,7 @@ function textForPowerEvent(event) { return ''; } return _t('%(senderName)s changed the power level of %(powerLevelDiffText)s.', { - senderName: senderName, + senderName, powerLevelDiffText: diff.join(", "), }); } From 152499a17d0683a565608a7f019ae99740a29b97 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 6 Oct 2017 12:16:54 +0100 Subject: [PATCH 18/28] DRY map lookup Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index ccb4c29a9c..6345403f09 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -310,7 +310,7 @@ const stateHandlers = { module.exports = { textForEvent: function(ev) { - const handler = ev.isState() ? stateHandlers[ev.getType()] : handlers[ev.getType()]; + const handler = (ev.isState() ? stateHandlers : handlers)[ev.getType()]; if (handler) return handler(ev); return ''; }, From 92be3af990ecd96cfa1bbef3bc2cdab3554b819b Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 Oct 2017 19:16:42 +0100 Subject: [PATCH 19/28] Make it clearer which HS you're logging into Otherwise there's no indication without clicking 'custom server' --- src/components/structures/login/Login.js | 1 + src/components/views/elements/Dropdown.js | 10 ++++++++++ src/components/views/login/PasswordLogin.js | 14 +++++++++++++- src/i18n/strings/en_EN.json | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js index a6c0a70c66..b88aa094dc 100644 --- a/src/components/structures/login/Login.js +++ b/src/components/structures/login/Login.js @@ -290,6 +290,7 @@ module.exports = React.createClass({ onPhoneNumberChanged={this.onPhoneNumberChanged} onForgotPasswordClick={this.props.onForgotPasswordClick} loginIncorrect={this.state.loginIncorrect} + hsUrl={this.state.enteredHomeserverUrl} /> ); case 'm.login.cas': diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index c049c38a68..1b2117bb6a 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -26,6 +26,12 @@ class MenuOption extends React.Component { this._onClick = this._onClick.bind(this); } + getDefaultProps() { + return { + disabled: false, + } + } + _onMouseEnter() { this.props.onMouseEnter(this.props.dropdownKey); } @@ -153,6 +159,8 @@ export default class Dropdown extends React.Component { } _onInputClick(ev) { + if (this.props.disabled) return; + if (!this.state.expanded) { this.setState({ expanded: true, @@ -329,4 +337,6 @@ Dropdown.propTypes = { // in the dropped-down menu. getShortOption: React.PropTypes.func, value: React.PropTypes.string, + // negative for consistency with HTML + disabled: React.PropTypes.bool, } diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 9f855616fc..4e37e30f65 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -186,6 +186,17 @@ class PasswordLogin extends React.Component { const loginField = this.renderLoginField(this.state.loginType); + let matrixIdText = ''; + if (this.props.hsUrl) { + try { + const parsedHsUrl = new URL(this.props.hsUrl); + matrixIdText = _t('%(serverName)s Matrix ID', {serverName: parsedHsUrl.hostname}); + } catch (e) { + console.log(e); + // pass + } + } + return (
@@ -194,8 +205,9 @@ class PasswordLogin extends React.Component { - { _t('my Matrix ID') } + {matrixIdText} { _t('Email address') } { _t('Phone') } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6acaba9fae..8ec975987c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -906,5 +906,6 @@ "Related Groups": "Related Groups", "Related groups for this room:": "Related groups for this room:", "This room has no related groups": "This room has no related groups", - "New group ID (e.g. +foo:%(localDomain)s)": "New group ID (e.g. +foo:%(localDomain)s)" + "New group ID (e.g. +foo:%(localDomain)s)": "New group ID (e.g. +foo:%(localDomain)s)", + "%(serverName)s Matrix ID": "%(serverName)s Matrix ID" } From 80ad7d4ad670f23e8c7ae3e6d8146df5f50541f9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 Oct 2017 19:27:51 +0100 Subject: [PATCH 20/28] Update translations --- src/i18n/strings/de_DE.json | 2 +- src/i18n/strings/el.json | 1 - src/i18n/strings/en_EN.json | 1 - src/i18n/strings/en_US.json | 1 - src/i18n/strings/es.json | 2 +- src/i18n/strings/eu.json | 1 - src/i18n/strings/fi.json | 2 +- src/i18n/strings/fr.json | 2 +- src/i18n/strings/hu.json | 2 +- src/i18n/strings/id.json | 1 - src/i18n/strings/ko.json | 1 - src/i18n/strings/lv.json | 2 +- src/i18n/strings/nl.json | 2 +- src/i18n/strings/pl.json | 2 +- src/i18n/strings/pt.json | 1 - src/i18n/strings/pt_BR.json | 1 - src/i18n/strings/ru.json | 2 +- src/i18n/strings/sv.json | 2 +- src/i18n/strings/th.json | 1 - src/i18n/strings/tr.json | 1 - src/i18n/strings/zh_Hans.json | 1 - src/i18n/strings/zh_Hant.json | 1 - 22 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/i18n/strings/de_DE.json b/src/i18n/strings/de_DE.json index aa114e241d..71adaba704 100644 --- a/src/i18n/strings/de_DE.json +++ b/src/i18n/strings/de_DE.json @@ -146,7 +146,7 @@ "Members only": "Nur Mitglieder", "Mobile phone number": "Mobiltelefonnummer", "Moderator": "Moderator", - "my Matrix ID": "meiner Matrix-ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix-ID", "Never send encrypted messages to unverified devices from this device": "Niemals verschlüsselte Nachrichten an unverifizierte Geräte von diesem Gerät aus versenden", "Never send encrypted messages to unverified devices in this room from this device": "Niemals verschlüsselte Nachrichten an unverifizierte Geräte in diesem Raum von diesem Gerät aus senden", "New password": "Neues Passwort", diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json index bc45e6da9e..2a51f6cae5 100644 --- a/src/i18n/strings/el.json +++ b/src/i18n/strings/el.json @@ -188,7 +188,6 @@ "Failure to create room": "Δεν ήταν δυνατή η δημιουργία δωματίου", "Join Room": "Είσοδος σε δωμάτιο", "Moderator": "Συντονιστής", - "my Matrix ID": "το Matrix ID μου", "Name": "Όνομα", "New address (e.g. #foo:%(localDomain)s)": "Νέα διεύθυνση (e.g. #όνομα:%(localDomain)s)", "New password": "Νέος κωδικός πρόσβασης", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8ec975987c..37c7655ed6 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -295,7 +295,6 @@ "Moderator": "Moderator", "Must be viewing a room": "Must be viewing a room", "Mute": "Mute", - "my Matrix ID": "my Matrix ID", "Name": "Name", "Never send encrypted messages to unverified devices from this device": "Never send encrypted messages to unverified devices from this device", "Never send encrypted messages to unverified devices in this room": "Never send encrypted messages to unverified devices in this room", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 928f1a9d0f..3954b2b6fa 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -262,7 +262,6 @@ "Moderator": "Moderator", "Must be viewing a room": "Must be viewing a room", "Mute": "Mute", - "my Matrix ID": "my Matrix ID", "Name": "Name", "Never send encrypted messages to unverified devices from this device": "Never send encrypted messages to unverified devices from this device", "Never send encrypted messages to unverified devices in this room": "Never send encrypted messages to unverified devices in this room", diff --git a/src/i18n/strings/es.json b/src/i18n/strings/es.json index bc2391a5c7..68f27c23e9 100644 --- a/src/i18n/strings/es.json +++ b/src/i18n/strings/es.json @@ -379,7 +379,7 @@ "Moderator": "Moderador", "Must be viewing a room": "Debe estar viendo una sala", "Mute": "Silenciar", - "my Matrix ID": "Mi ID de Matrix", + "%(serverName)s Matrix ID": "%(serverName)s ID de Matrix", "Name": "Nombre", "Never send encrypted messages to unverified devices from this device": "No enviar nunca mensajes cifrados, desde este dispositivo, a dispositivos sin verificar", "Never send encrypted messages to unverified devices in this room": "No enviar nunca mensajes cifrados a dispositivos no verificados, en esta sala", diff --git a/src/i18n/strings/eu.json b/src/i18n/strings/eu.json index 9f3d06ec52..9ef02d7b9b 100644 --- a/src/i18n/strings/eu.json +++ b/src/i18n/strings/eu.json @@ -346,7 +346,6 @@ "Missing room_id in request": "Gelaren ID-a falta da eskaeran", "Missing user_id in request": "Erabiltzailearen ID-a falta da eskaeran", "Mobile phone number": "Mugikorraren telefono zenbakia", - "my Matrix ID": "Nire Matrix ID-a", "Never send encrypted messages to unverified devices in this room": "Ez bidali inoiz zifratutako mezuak egiaztatu gabeko gailuetara gela honetan", "Never send encrypted messages to unverified devices in this room from this device": "Ez bidali inoiz zifratutako mezuak egiaztatu gabeko gailuetara gela honetan gailu honetatik", "New address (e.g. #foo:%(localDomain)s)": "Helbide berria (adib. #foo:%(localDomain)s)", diff --git a/src/i18n/strings/fi.json b/src/i18n/strings/fi.json index a59e5b1edd..7ffbf39e8e 100644 --- a/src/i18n/strings/fi.json +++ b/src/i18n/strings/fi.json @@ -245,7 +245,7 @@ "Mobile phone number": "Matkapuhelinnumero", "Mobile phone number (optional)": "Matkapuhelinnumero (valinnainen)", "Moderator": "Moderaattori", - "my Matrix ID": "minun Matrix tunniste", + "%(serverName)s Matrix ID": "%(serverName)s Matrix tunniste", "Name": "Nimi", "New password": "Uusi salasana", "New passwords don't match": "Uudet salasanat eivät täsmää", diff --git a/src/i18n/strings/fr.json b/src/i18n/strings/fr.json index 585e47f5a3..51c496ab96 100644 --- a/src/i18n/strings/fr.json +++ b/src/i18n/strings/fr.json @@ -224,7 +224,7 @@ "Mobile phone number": "Numéro de téléphone mobile", "Moderator": "Modérateur", "Must be viewing a room": "Doit être en train de visualiser un salon", - "my Matrix ID": "mon identifiant Matrix", + "%(serverName)s Matrix ID": "%(serverName)s identifiant Matrix", "Name": "Nom", "Never send encrypted messages to unverified devices from this device": "Ne jamais envoyer de message chiffré aux appareils non-vérifiés depuis cet appareil", "Never send encrypted messages to unverified devices in this room": "Ne jamais envoyer de message chiffré aux appareils non-vérifiés dans ce salon", diff --git a/src/i18n/strings/hu.json b/src/i18n/strings/hu.json index 2c34e05b1a..edf0a83ac6 100644 --- a/src/i18n/strings/hu.json +++ b/src/i18n/strings/hu.json @@ -293,7 +293,7 @@ "Mobile phone number (optional)": "Mobill telefonszám (opcionális)", "Moderator": "Moderátor", "Must be viewing a room": "Meg kell nézni a szobát", - "my Matrix ID": "Matrix azonosítóm", + "%(serverName)s Matrix ID": "%(serverName)s Matrix azonosítóm", "Name": "Név", "Never send encrypted messages to unverified devices from this device": "Soha ne küldj titkosított üzenetet ellenőrizetlen eszközre erről az eszközről", "Never send encrypted messages to unverified devices in this room": "Soha ne küldj titkosított üzenetet ebből a szobából ellenőrizetlen eszközre", diff --git a/src/i18n/strings/id.json b/src/i18n/strings/id.json index dc057c2a95..27bcc41dc8 100644 --- a/src/i18n/strings/id.json +++ b/src/i18n/strings/id.json @@ -78,7 +78,6 @@ "Members only": "Hanya anggota", "Mobile phone number": "Nomor telpon seluler", "Mute": "Bisu", - "my Matrix ID": "ID Matrix saya", "Name": "Nama", "New password": "Password Baru", "New passwords don't match": "Password baru tidak cocok", diff --git a/src/i18n/strings/ko.json b/src/i18n/strings/ko.json index 8b6e233437..5933b6abc2 100644 --- a/src/i18n/strings/ko.json +++ b/src/i18n/strings/ko.json @@ -293,7 +293,6 @@ "Mobile phone number (optional)": "휴대 전화번호 (선택)", "Moderator": "조정자", "Must be viewing a room": "방을 둘러봐야만 해요", - "my Matrix ID": "내 매트릭스 ID", "Name": "이름", "Never send encrypted messages to unverified devices from this device": "이 장치에서 인증받지 않은 장치로 암호화한 메시지를 보내지 마세요", "Never send encrypted messages to unverified devices in this room": "이 방에서 인증받지 않은 장치로 암호화한 메시지를 보내지 마세요", diff --git a/src/i18n/strings/lv.json b/src/i18n/strings/lv.json index 5f58fd9515..424a831ac5 100644 --- a/src/i18n/strings/lv.json +++ b/src/i18n/strings/lv.json @@ -274,7 +274,7 @@ "Moderator": "Moderators", "Must be viewing a room": "Jāapskata istaba", "Mute": "Apklusināt", - "my Matrix ID": "mans Matrix ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix ID", "Name": "Vārds", "Never send encrypted messages to unverified devices from this device": "Nekad nesūti no šīs ierīces šifrētas ziņas uz neverificētām ierīcēm", "Never send encrypted messages to unverified devices in this room": "Nekad nesūti šifrētas ziņas uz neverificētām ierīcēm šajā istabā", diff --git a/src/i18n/strings/nl.json b/src/i18n/strings/nl.json index f770e335cf..67fa97a5d7 100644 --- a/src/i18n/strings/nl.json +++ b/src/i18n/strings/nl.json @@ -126,7 +126,7 @@ "disabled": "uitgeschakeld", "Moderator": "Moderator", "Must be viewing a room": "Moet een ruimte weergeven", - "my Matrix ID": "mijn Matrix-ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix-ID", "Name": "Naam", "New password": "Nieuw wachtwoord", "none": "geen", diff --git a/src/i18n/strings/pl.json b/src/i18n/strings/pl.json index bd1e4c5c24..a3e2af956f 100644 --- a/src/i18n/strings/pl.json +++ b/src/i18n/strings/pl.json @@ -363,7 +363,7 @@ "Mobile phone number": "Numer telefonu komórkowego", "Mobile phone number (optional)": "Numer telefonu komórkowego (opcjonalne)", "Moderator": "Moderator", - "my Matrix ID": "mój Matrix ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix ID", "Name": "Imię", "Never send encrypted messages to unverified devices from this device": "Nigdy nie wysyłaj zaszyfrowanych wiadomości do niezweryfikowanych urządzeń z tego urządzenia", "Never send encrypted messages to unverified devices in this room": "Nigdy nie wysyłaj zaszyfrowanych wiadomości do niezweryfikowanych urządzeń w tym pokoju", diff --git a/src/i18n/strings/pt.json b/src/i18n/strings/pt.json index ba4968b7ad..1bf7fd00b1 100644 --- a/src/i18n/strings/pt.json +++ b/src/i18n/strings/pt.json @@ -127,7 +127,6 @@ "Members only": "Apenas integrantes da sala", "Mobile phone number": "Telefone celular", "Moderator": "Moderador/a", - "my Matrix ID": "com meu ID do Matrix", "Name": "Nome", "Never send encrypted messages to unverified devices from this device": "Nunca envie mensagens criptografada para um dispositivo não verificado a partir deste dispositivo", "Never send encrypted messages to unverified devices in this room from this device": "Nunca envie mensagens criptografadas para dispositivos não verificados nesta sala a partir deste dispositivo", diff --git a/src/i18n/strings/pt_BR.json b/src/i18n/strings/pt_BR.json index af4804bd85..116142c29c 100644 --- a/src/i18n/strings/pt_BR.json +++ b/src/i18n/strings/pt_BR.json @@ -127,7 +127,6 @@ "Members only": "Apenas integrantes da sala", "Mobile phone number": "Telefone celular", "Moderator": "Moderador/a", - "my Matrix ID": "com meu ID do Matrix", "Name": "Nome", "Never send encrypted messages to unverified devices from this device": "Nunca envie mensagens criptografada para um dispositivo não verificado a partir deste dispositivo", "Never send encrypted messages to unverified devices in this room from this device": "Nunca envie mensagens criptografadas para dispositivos não verificados nesta sala a partir deste dispositivo", diff --git a/src/i18n/strings/ru.json b/src/i18n/strings/ru.json index cfab960e32..8dc2d80001 100644 --- a/src/i18n/strings/ru.json +++ b/src/i18n/strings/ru.json @@ -117,7 +117,7 @@ "Members only": "Только участники", "Mobile phone number": "Номер мобильного телефона", "Moderator": "Модератор", - "my Matrix ID": "мой Matrix ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix ID", "Name": "Имя", "Never send encrypted messages to unverified devices from this device": "Никогда не отправлять зашифрованные сообщения на непроверенные устройства с этого устройства", "Never send encrypted messages to unverified devices in this room from this device": "Никогда не отправлять зашифрованные сообщения на непроверенные устройства в этой комнате с этого устройства", diff --git a/src/i18n/strings/sv.json b/src/i18n/strings/sv.json index fb7257ecf9..fd15771cec 100644 --- a/src/i18n/strings/sv.json +++ b/src/i18n/strings/sv.json @@ -273,7 +273,7 @@ "Moderator": "Moderator", "Must be viewing a room": "Du måste ha ett öppet rum", "Mute": "Dämpa", - "my Matrix ID": "mitt Matrix-ID", + "%(serverName)s Matrix ID": "%(serverName)s Matrix-ID", "Name": "Namn", "Never send encrypted messages to unverified devices from this device": "Skicka aldrig krypterade meddelanden till overifierade enheter från den här enheten", "Never send encrypted messages to unverified devices in this room": "Skicka aldrig krypterade meddelanden till overifierade enheter i det här rummet", diff --git a/src/i18n/strings/th.json b/src/i18n/strings/th.json index d45cb86986..47a5fd3049 100644 --- a/src/i18n/strings/th.json +++ b/src/i18n/strings/th.json @@ -219,7 +219,6 @@ "Markdown is enabled": "เปิดใช้งาน Markdown แล้ว", "Missing user_id in request": "ไม่พบ user_id ในคำขอ", "Moderator": "ผู้ช่วยดูแล", - "my Matrix ID": "Matrix ID ของฉัน", "New address (e.g. #foo:%(localDomain)s)": "ที่อยู่ใหม่ (เช่น #foo:%(localDomain)s)", "New password": "รหัสผ่านใหม่", "New passwords don't match": "รหัสผ่านใหม่ไม่ตรงกัน", diff --git a/src/i18n/strings/tr.json b/src/i18n/strings/tr.json index 23d4e284bc..6e8e4f25f8 100644 --- a/src/i18n/strings/tr.json +++ b/src/i18n/strings/tr.json @@ -269,7 +269,6 @@ "Moderator": "Moderatör", "Must be viewing a room": "Bir oda görüntülemeli olmalı", "Mute": "Sessiz", - "my Matrix ID": "Benim Matrix ID'm", "Name": "İsim", "Never send encrypted messages to unverified devices from this device": "Bu cihazdan doğrulanmamış cihazlara asla şifrelenmiş mesajlar göndermeyin", "Never send encrypted messages to unverified devices in this room": "Bu odada doğrulanmamış cihazlara asla şifreli mesajlar göndermeyin", diff --git a/src/i18n/strings/zh_Hans.json b/src/i18n/strings/zh_Hans.json index 69ba19ca27..f185640572 100644 --- a/src/i18n/strings/zh_Hans.json +++ b/src/i18n/strings/zh_Hans.json @@ -289,7 +289,6 @@ "Mobile phone number (optional)": "手机号码 (可选)", "Moderator": "管理员", "Mute": "静音", - "my Matrix ID": "我的 Matrix ID", "Name": "姓名", "Never send encrypted messages to unverified devices from this device": "不要从此设备向未验证的设备发送消息", "Never send encrypted messages to unverified devices in this room": "不要在此聊天室里向未验证的设备发送消息", diff --git a/src/i18n/strings/zh_Hant.json b/src/i18n/strings/zh_Hant.json index 596bc55a01..49890005a1 100644 --- a/src/i18n/strings/zh_Hant.json +++ b/src/i18n/strings/zh_Hant.json @@ -403,7 +403,6 @@ "Mobile phone number (optional)": "行動電話號碼(選擇性)", "Moderator": "仲裁者", "Must be viewing a room": "必須檢視房間", - "my Matrix ID": "我的 Matrix ID", "Name": "名稱", "Never send encrypted messages to unverified devices from this device": "從不自此裝置傳送加密的訊息到未驗證的裝置", "Never send encrypted messages to unverified devices in this room": "從不在此房間傳送加密的訊息到未驗證的裝置", From fa24b4bd2de325154cc32d0237b9fe5904c794cd Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Oct 2017 09:48:12 +0100 Subject: [PATCH 21/28] Remove this log - it's not an error worth logging --- src/components/views/login/PasswordLogin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 4e37e30f65..7e78de3f54 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -192,7 +192,6 @@ class PasswordLogin extends React.Component { const parsedHsUrl = new URL(this.props.hsUrl); matrixIdText = _t('%(serverName)s Matrix ID', {serverName: parsedHsUrl.hostname}); } catch (e) { - console.log(e); // pass } } From 0f84216a9fea9c0cf38d6ae1ab30e0062bf707a1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Oct 2017 14:05:34 +0100 Subject: [PATCH 22/28] Grey out login form when no valid HS --- src/components/views/elements/Dropdown.js | 1 + src/components/views/login/CountryDropdown.js | 3 +- src/components/views/login/PasswordLogin.js | 46 +++++++++++++------ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index 1b2117bb6a..0fb5a37414 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -302,6 +302,7 @@ export default class Dropdown extends React.Component { const dropdownClasses = { mx_Dropdown: true, + mx_Dropdown_disabled: this.props.disabled, }; if (this.props.className) { dropdownClasses[this.props.className] = true; diff --git a/src/components/views/login/CountryDropdown.js b/src/components/views/login/CountryDropdown.js index 7024db339c..56ab962d98 100644 --- a/src/components/views/login/CountryDropdown.js +++ b/src/components/views/login/CountryDropdown.js @@ -123,7 +123,7 @@ export default class CountryDropdown extends React.Component { return {options} ; @@ -137,4 +137,5 @@ CountryDropdown.propTypes = { showPrefix: React.PropTypes.bool, onOptionChange: React.PropTypes.func.isRequired, value: React.PropTypes.string, + disabled: React.PropTypes.bool, }; diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 7e78de3f54..d532c400bc 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -116,11 +116,17 @@ class PasswordLogin extends React.Component { this.props.onPasswordChanged(ev.target.value); } - renderLoginField(loginType) { + renderLoginField(loginType, disabled) { + const classes = { + mx_Login_field: true, + mx_Login_field_disabled: disabled, + }; + switch(loginType) { case PasswordLogin.LOGIN_FIELD_EMAIL: + classes.mx_Login_email = true; return ; case PasswordLogin.LOGIN_FIELD_MXID: + classes.mx_Login_username = true; return ; case PasswordLogin.LOGIN_FIELD_PHONE: const CountryDropdown = sdk.getComponent('views.login.CountryDropdown'); + classes.mx_Login_phoneNumberField = true; + classes.mx_Login_field_has_prefix = true; return
; } @@ -177,15 +190,6 @@ class PasswordLogin extends React.Component { ); } - const pwFieldClass = classNames({ - mx_Login_field: true, - error: this.props.loginIncorrect, - }); - - const Dropdown = sdk.getComponent('elements.Dropdown'); - - const loginField = this.renderLoginField(this.state.loginType); - let matrixIdText = ''; if (this.props.hsUrl) { try { @@ -196,6 +200,16 @@ class PasswordLogin extends React.Component { } } + const pwFieldClass = classNames({ + mx_Login_field: true, + mx_Login_field_disabled: matrixIdText === '', + error: this.props.loginIncorrect, + }); + + const Dropdown = sdk.getComponent('elements.Dropdown'); + + const loginField = this.renderLoginField(this.state.loginType, matrixIdText === ''); + return (
@@ -215,10 +229,12 @@ class PasswordLogin extends React.Component { {this._passwordField = e;}} type="password" name="password" value={this.state.password} onChange={this.onPasswordChanged} - placeholder={ _t('Password') } /> + placeholder={ _t('Password') } + disabled={matrixIdText === ''} + />
{forgotPasswordJsx} - +
); From 0ab5b1a6af3598c52102bcea24029244c398e54d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 11 Oct 2017 08:50:28 -0600 Subject: [PATCH 23/28] _td translatable strings Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index b3b27875a0..e6d3bc7d71 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -17,7 +17,7 @@ limitations under the License. import Promise from 'bluebird'; import React from 'react'; -import { _t, _tJsx } from '../../../languageHandler'; +import { _t, _tJsx, _td } from '../../../languageHandler'; import MatrixClientPeg from '../../../MatrixClientPeg'; import SdkConfig from '../../../SdkConfig'; import sdk from '../../../index'; @@ -37,15 +37,14 @@ function parseIntWithDefault(val, def) { const plEventsToLabels = { // These will be translated for us later. - // TODO: _td() these when https://github.com/matrix-org/matrix-react-sdk/pull/1421 lands - "m.room.avatar": "To change the room's avatar, you must be a", - "m.room.name": "To change the room's name, you must be a", - "m.room.canonical_alias": "To change the room's main address, you must be a", - "m.room.history_visibility": "To change the room's history visibility, you must be a", - "m.room.power_levels": "To change the permissions in the room, you must be a", - "m.room.topic": "To change the topic, you must be a", + "m.room.avatar": _td("To change the room's avatar, you must be a"), + "m.room.name": _td("To change the room's name, you must be a"), + "m.room.canonical_alias": _td("To change the room's main address, you must be a"), + "m.room.history_visibility": _td("To change the room's history visibility, you must be a"), + "m.room.power_levels": _td("To change the permissions in the room, you must be a"), + "m.room.topic": _td("To change the topic, you must be a"), - "im.vector.modular.widgets": "To modify widgets in the room, you must be a", + "im.vector.modular.widgets": _td("To modify widgets in the room, you must be a"), }; const plEventsToShow = { From 060bf3bdf64a7e23c24d19f35c0e2f4f3910afe2 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 11 Oct 2017 16:02:01 +0100 Subject: [PATCH 24/28] Remove inline CSS --- src/components/views/elements/Flair.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/Flair.js b/src/components/views/elements/Flair.js index 84c0c2a187..ceab20bf19 100644 --- a/src/components/views/elements/Flair.js +++ b/src/components/views/elements/Flair.js @@ -265,7 +265,7 @@ export default class Flair extends React.Component { return ; }); return ( - + { avatars } ); From d1fdd208097142b9bfdbbf2fc115b271af2bf2bf Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 29 Sep 2017 16:04:12 -0600 Subject: [PATCH 25/28] Show who banned the user on hover Fixes https://github.com/vector-im/riot-web/issues/5039 Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 10 +++++++--- src/i18n/strings/en_EN.json | 1 + src/i18n/strings/en_US.json | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 031e089c4e..05116bc097 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -39,6 +39,7 @@ const BannedUser = React.createClass({ propTypes: { canUnban: React.PropTypes.bool, member: React.PropTypes.object.isRequired, // js-sdk RoomMember + by: React.PropTypes.object.isRequired, // js-sdk RoomMember reason: React.PropTypes.string, }, @@ -77,8 +78,10 @@ const BannedUser = React.createClass({ return (
  • { unbanButton } - {this.props.member.name} {this.props.member.userId} - {this.props.reason ? " " +_t('Reason') + ": " + this.props.reason : ""} + + {this.props.member.name} {this.props.member.userId} + {this.props.reason ? " " +_t('Reason') + ": " + this.props.reason : ""} +
  • ); }, @@ -670,8 +673,9 @@ module.exports = React.createClass({
      {banned.map(function(member) { const banEvent = member.events.member.getContent(); + const bannedBy = self.props.room.getMember(member.events.member.getSender()); return ( - + ); })}
    diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index cf2be3c2f8..9e5524d80c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -808,6 +808,7 @@ "This will allow you to reset your password and receive notifications.": "This will allow you to reset your password and receive notifications.", "To return to your account in future you need to set a password": "To return to your account in future you need to set a password", "Skip": "Skip", + "Banned by %(displayName)s (%(userId)s)": "Banned by %(displayName)s (%(userId)s)", "Start verification": "Start verification", "Share without verifying": "Share without verifying", "Ignore request": "Ignore request", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 3954b2b6fa..93b3e88332 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -607,6 +607,7 @@ "Desktop specific": "Desktop specific", "Analytics": "Analytics", "Opt out of analytics": "Opt out of analytics", + "Banned by %(displayName)s (%(userId)s)": "Banned by %(displayName)s (%(userId)s)", "Options": "Options", "Riot collects anonymous analytics to allow us to improve the application.": "Riot collects anonymous analytics to allow us to improve the application.", "Passphrases must match": "Passphrases must match", From 8a2813ac08e212fef2aa62b14ff7d800f7ab2923 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 11 Oct 2017 09:05:54 -0600 Subject: [PATCH 26/28] Fallback to MXID instead of relying on the user being in the room Signed-off-by: Travis Ralston --- src/components/views/rooms/RoomSettings.js | 8 +++++--- src/i18n/strings/en_EN.json | 2 +- src/i18n/strings/en_US.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 05116bc097..b62b72bf18 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -39,7 +39,7 @@ const BannedUser = React.createClass({ propTypes: { canUnban: React.PropTypes.bool, member: React.PropTypes.object.isRequired, // js-sdk RoomMember - by: React.PropTypes.object.isRequired, // js-sdk RoomMember + by: React.PropTypes.string.isRequired, reason: React.PropTypes.string, }, @@ -78,7 +78,7 @@ const BannedUser = React.createClass({ return (
  • { unbanButton } - + {this.props.member.name} {this.props.member.userId} {this.props.reason ? " " +_t('Reason') + ": " + this.props.reason : ""} @@ -673,7 +673,9 @@ module.exports = React.createClass({
      {banned.map(function(member) { const banEvent = member.events.member.getContent(); - const bannedBy = self.props.room.getMember(member.events.member.getSender()); + const sender = self.props.room.getMember(member.events.member.getSender()); + let bannedBy = member.events.member.getSender(); // start by falling back to mxid + if (sender) bannedBy = sender.name; return ( ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9e5524d80c..f6edae19a9 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -808,7 +808,7 @@ "This will allow you to reset your password and receive notifications.": "This will allow you to reset your password and receive notifications.", "To return to your account in future you need to set a password": "To return to your account in future you need to set a password", "Skip": "Skip", - "Banned by %(displayName)s (%(userId)s)": "Banned by %(displayName)s (%(userId)s)", + "Banned by %(displayName)s": "Banned by %(displayName)s", "Start verification": "Start verification", "Share without verifying": "Share without verifying", "Ignore request": "Ignore request", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 93b3e88332..fccf387f30 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -607,7 +607,7 @@ "Desktop specific": "Desktop specific", "Analytics": "Analytics", "Opt out of analytics": "Opt out of analytics", - "Banned by %(displayName)s (%(userId)s)": "Banned by %(displayName)s (%(userId)s)", + "Banned by %(displayName)s": "Banned by %(displayName)s", "Options": "Options", "Riot collects anonymous analytics to allow us to improve the application.": "Riot collects anonymous analytics to allow us to improve the application.", "Passphrases must match": "Passphrases must match", From d3f9a3aeb55aaf6a746a12d9d6f9a27df54654fe Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 11 Oct 2017 17:56:17 +0100 Subject: [PATCH 27/28] Run eslint --fix Fixing 1000s of lint issues. Some rules cannot be `--fix`ed but this goes some way to linting the entire codebase. --- src/CallHandler.js | 89 ++--- src/ContentMessages.js | 53 ++- src/HtmlUtils.js | 65 ++-- src/ImageUtils.js | 7 +- src/Login.js | 16 +- src/Markdown.js | 6 +- src/MatrixClientPeg.js | 8 +- src/Modal.js | 22 +- src/Notifier.js | 4 +- src/Presence.js | 14 +- src/RichText.js | 34 +- src/Rooms.js | 3 +- src/ScalarAuthClient.js | 14 +- src/ScalarMessaging.js | 21 +- src/Tinter.js | 83 +++-- src/Unread.js | 19 +- src/Velociraptor.js | 32 +- src/VelocityBounce.js | 4 +- src/WhoIsTyping.js | 16 +- .../views/dialogs/EncryptedEventDialog.js | 38 +-- src/autocomplete/Autocompleter.js | 2 +- src/autocomplete/Components.js | 18 +- src/autocomplete/DuckDuckGoProvider.js | 6 +- src/autocomplete/EmojiProvider.js | 7 +- src/autocomplete/UserProvider.js | 6 +- src/components/structures/ContextualMenu.js | 34 +- src/components/structures/CreateRoom.js | 70 ++-- src/components/structures/FilePanel.js | 35 +- src/components/structures/InteractiveAuth.js | 8 +- src/components/structures/LoggedInView.js | 17 +- src/components/structures/MessagePanel.js | 102 +++--- .../structures/NotificationPanel.js | 31 +- src/components/structures/RoomStatusBar.js | 64 ++-- src/components/structures/RoomView.js | 322 +++++++++--------- src/components/structures/ScrollPanel.js | 65 ++-- src/components/structures/TimelinePanel.js | 185 +++++----- src/components/structures/UploadBar.js | 32 +- .../structures/login/ForgotPassword.js | 82 +++-- src/components/structures/login/Login.js | 40 +-- .../structures/login/PostRegistration.js | 22 +- .../structures/login/Registration.js | 30 +- src/components/views/avatars/BaseAvatar.js | 53 ++- src/components/views/avatars/MemberAvatar.js | 16 +- .../views/create_room/CreateRoomButton.js | 4 +- src/components/views/create_room/Presets.js | 14 +- src/components/views/create_room/RoomAlias.js | 26 +- .../views/dialogs/ChatCreateOrReuseDialog.js | 4 +- .../views/dialogs/DeactivateAccountDialog.js | 20 +- .../views/dialogs/InteractiveAuthDialog.js | 8 +- .../views/dialogs/UnknownDeviceDialog.js | 34 +- .../views/elements/AccessibleButton.js | 2 +- src/components/views/elements/ActionButton.js | 4 +- .../views/elements/AddressSelector.js | 34 +- src/components/views/elements/AddressTile.js | 10 +- .../views/elements/CreateRoomButton.js | 2 +- .../views/elements/DeviceVerifyButtons.js | 18 +- .../views/elements/DirectorySearchBox.js | 2 +- src/components/views/elements/Dropdown.js | 26 +- src/components/views/elements/EditableText.js | 29 +- .../views/elements/EditableTextContainer.js | 10 +- src/components/views/elements/HomeButton.js | 2 +- .../views/elements/LanguageDropdown.js | 10 +- .../views/elements/MemberEventListSummary.js | 46 ++- .../views/elements/PowerSelector.js | 39 +-- src/components/views/elements/ProgressBar.js | 10 +- .../views/elements/RoomDirectoryButton.js | 2 +- .../views/elements/SettingsButton.js | 2 +- .../views/elements/StartChatButton.js | 2 +- src/components/views/elements/TintableSvg.js | 18 +- src/components/views/elements/UserSelector.js | 14 +- src/components/views/login/CaptchaForm.js | 25 +- src/components/views/login/CasLogin.js | 4 +- src/components/views/login/CountryDropdown.js | 8 +- .../views/login/CustomServerDialog.js | 24 +- .../login/InteractiveAuthEntryComponents.js | 36 +- src/components/views/login/LoginHeader.js | 4 +- src/components/views/login/PasswordLogin.js | 14 +- .../views/login/RegistrationForm.js | 60 ++-- src/components/views/login/ServerConfig.js | 57 ++-- src/components/views/messages/MAudioBody.js | 13 +- src/components/views/messages/MFileBody.js | 27 +- src/components/views/messages/MImageBody.js | 12 +- src/components/views/messages/MVideoBody.js | 19 +- src/components/views/messages/MessageEvent.js | 16 +- .../views/messages/RoomAvatarEvent.js | 28 +- src/components/views/messages/TextualBody.js | 92 +++-- src/components/views/messages/TextualEvent.js | 10 +- .../views/room_settings/AliasSettings.js | 81 +++-- .../views/room_settings/ColorSettings.js | 52 +-- .../views/room_settings/UrlPreviewSettings.js | 83 +++-- src/components/views/rooms/Autocomplete.js | 6 +- src/components/views/rooms/AuxPanel.js | 20 +- src/components/views/rooms/EntityTile.js | 61 ++-- src/components/views/rooms/EventTile.js | 147 ++++---- .../views/rooms/LinkPreviewWidget.js | 48 +-- .../views/rooms/MemberDeviceInfo.js | 16 +- src/components/views/rooms/MemberInfo.js | 201 ++++++----- src/components/views/rooms/MemberList.js | 77 ++--- src/components/views/rooms/MemberTile.js | 34 +- src/components/views/rooms/MessageComposer.js | 38 +-- .../views/rooms/MessageComposerInput.js | 13 +- src/components/views/rooms/PresenceLabel.js | 29 +- .../views/rooms/ReadReceiptMarker.js | 32 +- src/components/views/rooms/RoomList.js | 271 +++++++-------- src/components/views/rooms/RoomNameEditor.js | 22 +- src/components/views/rooms/RoomPreviewBar.js | 66 ++-- src/components/views/rooms/RoomSettings.js | 279 ++++++++------- src/components/views/rooms/RoomTile.js | 99 +++--- src/components/views/rooms/RoomTopicEditor.js | 14 +- .../views/rooms/SearchResultTile.js | 26 +- .../views/rooms/SearchableEntityList.js | 57 ++-- .../views/rooms/TopUnreadMessagesBar.js | 8 +- src/components/views/rooms/UserTile.js | 32 +- .../views/settings/AddPhoneNumber.js | 22 +- src/components/views/settings/ChangeAvatar.js | 50 +-- .../views/settings/ChangeDisplayName.js | 19 +- .../views/settings/ChangePassword.js | 20 +- src/components/views/settings/DevicesPanel.js | 20 +- .../views/settings/DevicesPanelEntry.js | 16 +- .../settings/EnableNotificationsButton.js | 14 +- src/languageHandler.js | 32 +- src/linkify-matrix.js | 75 ++-- src/ratelimitedfunc.js | 12 +- src/utils/DecryptFile.js | 6 +- src/utils/Receipt.js | 6 +- test/all-tests.js | 2 +- .../structures/MessagePanel-test.js | 74 ++-- .../components/structures/ScrollPanel-test.js | 54 +-- .../structures/TimelinePanel-test.js | 116 +++---- test/components/stub-component.js | 6 +- .../dialogs/InteractiveAuthDialog-test.js | 20 +- .../elements/MemberEventListSummary-test.js | 74 ++-- .../views/rooms/MessageComposerInput-test.js | 2 +- test/mock-clock.js | 64 ++-- test/skinned-sdk.js | 8 +- test/test-utils.js | 37 +- 136 files changed, 2540 insertions(+), 2657 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 8331d579df..a9539d40e1 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -63,23 +63,22 @@ import dis from './dispatcher'; global.mxCalls = { //room_id: MatrixCall }; -var calls = global.mxCalls; -var ConferenceHandler = null; +const calls = global.mxCalls; +let ConferenceHandler = null; -var audioPromises = {}; +const audioPromises = {}; function play(audioId) { // TODO: Attach an invisible element for this instead // which listens? - var audio = document.getElementById(audioId); + const audio = document.getElementById(audioId); if (audio) { if (audioPromises[audioId]) { audioPromises[audioId] = audioPromises[audioId].then(()=>{ audio.load(); return audio.play(); }); - } - else { + } else { audioPromises[audioId] = audio.play(); } } @@ -88,12 +87,11 @@ function play(audioId) { function pause(audioId) { // TODO: Attach an invisible element for this instead // which listens? - var audio = document.getElementById(audioId); + const audio = document.getElementById(audioId); if (audio) { if (audioPromises[audioId]) { audioPromises[audioId] = audioPromises[audioId].then(()=>audio.pause()); - } - else { + } else { // pause doesn't actually return a promise, but might as well do this for symmetry with play(); audioPromises[audioId] = audio.pause(); } @@ -125,38 +123,32 @@ function _setCallListeners(call) { if (newState === "ringing") { _setCallState(call, call.roomId, "ringing"); pause("ringbackAudio"); - } - else if (newState === "invite_sent") { + } else if (newState === "invite_sent") { _setCallState(call, call.roomId, "ringback"); play("ringbackAudio"); - } - else if (newState === "ended" && oldState === "connected") { + } else if (newState === "ended" && oldState === "connected") { _setCallState(undefined, call.roomId, "ended"); pause("ringbackAudio"); play("callendAudio"); - } - else if (newState === "ended" && oldState === "invite_sent" && + } else if (newState === "ended" && oldState === "invite_sent" && (call.hangupParty === "remote" || (call.hangupParty === "local" && call.hangupReason === "invite_timeout") )) { _setCallState(call, call.roomId, "busy"); pause("ringbackAudio"); play("busyAudio"); - var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, { title: _t('Call Timeout'), description: _t('The remote side failed to pick up') + '.', }); - } - else if (oldState === "invite_sent") { + } else if (oldState === "invite_sent") { _setCallState(call, call.roomId, "stop_ringback"); pause("ringbackAudio"); - } - else if (oldState === "ringing") { + } else if (oldState === "ringing") { _setCallState(call, call.roomId, "stop_ringing"); pause("ringbackAudio"); - } - else if (newState === "connected") { + } else if (newState === "connected") { _setCallState(call, call.roomId, "connected"); pause("ringbackAudio"); } @@ -165,14 +157,13 @@ function _setCallListeners(call) { function _setCallState(call, roomId, status) { console.log( - "Call state in %s changed to %s (%s)", roomId, status, (call ? call.call_state : "-") + "Call state in %s changed to %s (%s)", roomId, status, (call ? call.call_state : "-"), ); calls[roomId] = call; if (status === "ringing") { play("ringAudio"); - } - else if (call && call.call_state === "ringing") { + } else if (call && call.call_state === "ringing") { pause("ringAudio"); } @@ -192,14 +183,12 @@ function _onAction(payload) { _setCallState(newCall, newCall.roomId, "ringback"); if (payload.type === 'voice') { newCall.placeVoiceCall(); - } - else if (payload.type === 'video') { + } else if (payload.type === 'video') { newCall.placeVideoCall( payload.remote_element, - payload.local_element + payload.local_element, ); - } - else if (payload.type === 'screensharing') { + } else if (payload.type === 'screensharing') { const screenCapErrorString = PlatformPeg.get().screenCaptureErrorString(); if (screenCapErrorString) { _setCallState(undefined, newCall.roomId, "ended"); @@ -213,10 +202,9 @@ function _onAction(payload) { } newCall.placeScreenSharingCall( payload.remote_element, - payload.local_element + payload.local_element, ); - } - else { + } else { console.error("Unknown conf call type: %s", payload.type); } } @@ -255,21 +243,19 @@ function _onAction(payload) { description: _t('You cannot place a call with yourself.'), }); return; - } - else if (members.length === 2) { + } else if (members.length === 2) { console.log("Place %s call in %s", payload.type, payload.room_id); const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id, { forceTURN: UserSettingsStore.getLocalSetting('webRtcForceTURN', false), }); placeCall(call); - } - else { // > 2 + } else { // > 2 dis.dispatch({ action: "place_conference_call", room_id: payload.room_id, type: payload.type, remote_element: payload.remote_element, - local_element: payload.local_element + local_element: payload.local_element, }); } break; @@ -280,15 +266,13 @@ function _onAction(payload) { Modal.createTrackedDialog('Call Handler', 'Conference call unsupported client', ErrorDialog, { description: _t('Conference calls are not supported in this client'), }); - } - else if (!MatrixClientPeg.get().supportsVoip()) { + } else if (!MatrixClientPeg.get().supportsVoip()) { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Call Handler', 'VoIP is unsupported', ErrorDialog, { title: _t('VoIP is unsupported'), description: _t('You cannot place VoIP calls in this browser.'), }); - } - else if (MatrixClientPeg.get().isRoomEncrypted(payload.room_id)) { + } else if (MatrixClientPeg.get().isRoomEncrypted(payload.room_id)) { // Conference calls are implemented by sending the media to central // server which combines the audio from all the participants together // into a single stream. This is incompatible with end-to-end encryption @@ -299,16 +283,15 @@ function _onAction(payload) { Modal.createTrackedDialog('Call Handler', 'Conference calls unsupported e2e', ErrorDialog, { description: _t('Conference calls are not supported in encrypted rooms'), }); - } - else { - var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + } else { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); Modal.createTrackedDialog('Call Handler', 'Conference calling in development', QuestionDialog, { title: _t('Warning!'), description: _t('Conference calling is in development and may not be reliable.'), - onFinished: confirm=>{ + onFinished: (confirm)=>{ if (confirm) { ConferenceHandler.createNewMatrixCall( - MatrixClientPeg.get(), payload.room_id + MatrixClientPeg.get(), payload.room_id, ).done(function(call) { placeCall(call); }, function(err) { @@ -357,7 +340,7 @@ function _onAction(payload) { _setCallState(calls[payload.room_id], payload.room_id, "connected"); dis.dispatch({ action: "view_room", - room_id: payload.room_id + room_id: payload.room_id, }); break; } @@ -368,9 +351,9 @@ if (!global.mxCallHandler) { dis.register(_onAction); } -var callHandler = { +const callHandler = { getCallForRoom: function(roomId) { - var call = module.exports.getCall(roomId); + let call = module.exports.getCall(roomId); if (call) return call; if (ConferenceHandler) { @@ -386,8 +369,8 @@ var callHandler = { }, getAnyActiveCall: function() { - var roomsWithCalls = Object.keys(calls); - for (var i = 0; i < roomsWithCalls.length; i++) { + const roomsWithCalls = Object.keys(calls); + for (let i = 0; i < roomsWithCalls.length; i++) { if (calls[roomsWithCalls[i]] && calls[roomsWithCalls[i]].call_state !== "ended") { return calls[roomsWithCalls[i]]; @@ -402,7 +385,7 @@ var callHandler = { getConferenceHandler: function() { return ConferenceHandler; - } + }, }; // Only things in here which actually need to be global are the // calls list (done separately) and making sure we only register diff --git a/src/ContentMessages.js b/src/ContentMessages.js index 93057fafed..00728061a2 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -17,14 +17,14 @@ limitations under the License. 'use strict'; import Promise from 'bluebird'; -var extend = require('./extend'); -var dis = require('./dispatcher'); -var MatrixClientPeg = require('./MatrixClientPeg'); -var sdk = require('./index'); +const extend = require('./extend'); +const dis = require('./dispatcher'); +const MatrixClientPeg = require('./MatrixClientPeg'); +const sdk = require('./index'); import { _t } from './languageHandler'; -var Modal = require('./Modal'); +const Modal = require('./Modal'); -var encrypt = require("browser-encrypt-attachment"); +const encrypt = require("browser-encrypt-attachment"); // Polyfill for Canvas.toBlob API using Canvas.toDataURL require("blueimp-canvas-to-blob"); @@ -54,8 +54,8 @@ const MAX_HEIGHT = 600; function createThumbnail(element, inputWidth, inputHeight, mimeType) { const deferred = Promise.defer(); - var targetWidth = inputWidth; - var targetHeight = inputHeight; + let targetWidth = inputWidth; + let targetHeight = inputHeight; if (targetHeight > MAX_HEIGHT) { targetWidth = Math.floor(targetWidth * (MAX_HEIGHT / targetHeight)); targetHeight = MAX_HEIGHT; @@ -81,7 +81,7 @@ function createThumbnail(element, inputWidth, inputHeight, mimeType) { w: inputWidth, h: inputHeight, }, - thumbnail: thumbnail + thumbnail: thumbnail, }); }, mimeType); @@ -129,12 +129,12 @@ function loadImageElement(imageFile) { * @return {Promise} A promise that resolves with the attachment info. */ function infoForImageFile(matrixClient, roomId, imageFile) { - var thumbnailType = "image/png"; + let thumbnailType = "image/png"; if (imageFile.type == "image/jpeg") { thumbnailType = "image/jpeg"; } - var imageInfo; + let imageInfo; return loadImageElement(imageFile).then(function(img) { return createThumbnail(img, img.width, img.height, thumbnailType); }).then(function(result) { @@ -191,7 +191,7 @@ function loadVideoElement(videoFile) { function infoForVideoFile(matrixClient, roomId, videoFile) { const thumbnailType = "image/jpeg"; - var videoInfo; + let videoInfo; return loadVideoElement(videoFile).then(function(video) { return createThumbnail(video, video.videoWidth, video.videoHeight, thumbnailType); }).then(function(result) { @@ -286,7 +286,7 @@ class ContentMessages { body: file.name || 'Attachment', info: { size: file.size, - } + }, }; // if we have a mime type for the file, add it to the message metadata @@ -297,10 +297,10 @@ class ContentMessages { const def = Promise.defer(); if (file.type.indexOf('image/') == 0) { content.msgtype = 'm.image'; - infoForImageFile(matrixClient, roomId, file).then(imageInfo=>{ + infoForImageFile(matrixClient, roomId, file).then((imageInfo)=>{ extend(content.info, imageInfo); def.resolve(); - }, error=>{ + }, (error)=>{ console.error(error); content.msgtype = 'm.file'; def.resolve(); @@ -310,10 +310,10 @@ class ContentMessages { def.resolve(); } else if (file.type.indexOf('video/') == 0) { content.msgtype = 'm.video'; - infoForVideoFile(matrixClient, roomId, file).then(videoInfo=>{ + infoForVideoFile(matrixClient, roomId, file).then((videoInfo)=>{ extend(content.info, videoInfo); def.resolve(); - }, error=>{ + }, (error)=>{ content.msgtype = 'm.file'; def.resolve(); }); @@ -331,7 +331,7 @@ class ContentMessages { this.inprogress.push(upload); dis.dispatch({action: 'upload_started'}); - var error; + let error; function onProgress(ev) { upload.total = ev.total; @@ -355,11 +355,11 @@ class ContentMessages { }, function(err) { error = err; if (!upload.canceled) { - var desc = _t('The file \'%(fileName)s\' failed to upload', {fileName: upload.fileName}) + '.'; + let desc = _t('The file \'%(fileName)s\' failed to upload', {fileName: upload.fileName}) + '.'; if (err.http_status == 413) { desc = _t('The file \'%(fileName)s\' exceeds this home server\'s size limit for uploads', {fileName: upload.fileName}); } - var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Upload failed', '', ErrorDialog, { title: _t('Upload Failed'), description: desc, @@ -367,8 +367,8 @@ class ContentMessages { } }).finally(() => { const inprogressKeys = Object.keys(this.inprogress); - for (var i = 0; i < this.inprogress.length; ++i) { - var k = inprogressKeys[i]; + for (let i = 0; i < this.inprogress.length; ++i) { + const k = inprogressKeys[i]; if (this.inprogress[k].promise === upload.promise) { this.inprogress.splice(k, 1); break; @@ -376,8 +376,7 @@ class ContentMessages { } if (error) { dis.dispatch({action: 'upload_failed', upload: upload}); - } - else { + } else { dis.dispatch({action: 'upload_finished', upload: upload}); } }); @@ -389,9 +388,9 @@ class ContentMessages { cancelUpload(promise) { const inprogressKeys = Object.keys(this.inprogress); - var upload; - for (var i = 0; i < this.inprogress.length; ++i) { - var k = inprogressKeys[i]; + let upload; + for (let i = 0; i < this.inprogress.length; ++i) { + const k = inprogressKeys[i]; if (this.inprogress[k].promise === promise) { upload = this.inprogress[k]; break; diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index ee2bcd2b0f..5620bc06df 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -17,10 +17,10 @@ limitations under the License. 'use strict'; -var React = require('react'); -var sanitizeHtml = require('sanitize-html'); -var highlight = require('highlight.js'); -var linkifyMatrix = require('./linkify-matrix'); +const React = require('react'); +const sanitizeHtml = require('sanitize-html'); +const highlight = require('highlight.js'); +const linkifyMatrix = require('./linkify-matrix'); import escape from 'lodash/escape'; import emojione from 'emojione'; import classNames from 'classnames'; @@ -66,8 +66,7 @@ function unicodeToImage(str) { if ( (typeof unicodeChar === 'undefined') || (unicodeChar === '') || (!(unicodeChar in emojione.jsEscapeMap)) ) { // if the unicodeChar doesnt exist just return the entire match return unicodeChar; - } - else { + } else { // get the unicode codepoint from the actual char unicode = emojione.jsEscapeMap[unicodeChar]; @@ -183,21 +182,19 @@ const sanitizeHtmlParams = { if (attribs.href) { attribs.target = '_blank'; // by default - var m; + let m; // FIXME: horrible duplication with linkify-matrix m = attribs.href.match(linkifyMatrix.VECTOR_URL_PATTERN); if (m) { attribs.href = m[1]; delete attribs.target; - } - else { + } else { m = attribs.href.match(linkifyMatrix.MATRIXTO_URL_PATTERN); if (m) { - var entity = m[1]; + const entity = m[1]; if (entity[0] === '@') { attribs.href = '#/user/' + entity; - } - else if (entity[0] === '#' || entity[0] === '!') { + } else if (entity[0] === '#' || entity[0] === '!') { attribs.href = '#/room/' + entity; } delete attribs.target; @@ -205,7 +202,7 @@ const sanitizeHtmlParams = { } } attribs.rel = 'noopener'; // https://mathiasbynens.github.io/rel-noopener/ - return { tagName: tagName, attribs : attribs }; + return { tagName: tagName, attribs: attribs }; }, 'img': function(tagName, attribs) { // Strip out imgs that aren't `mxc` here instead of using allowedSchemesByTag @@ -224,7 +221,7 @@ const sanitizeHtmlParams = { 'code': function(tagName, attribs) { if (typeof attribs.class !== 'undefined') { // Filter out all classes other than ones starting with language- for syntax highlighting. - let classes = attribs.class.split(/\s+/).filter(function(cl) { + const classes = attribs.class.split(/\s+/).filter(function(cl) { return cl.startsWith('language-'); }); attribs.class = classes.join(' '); @@ -287,11 +284,11 @@ class BaseHighlighter { * TextHighlighter). */ applyHighlights(safeSnippet, safeHighlights) { - var lastOffset = 0; - var offset; - var nodes = []; + let lastOffset = 0; + let offset; + let nodes = []; - var safeHighlight = safeHighlights[0]; + const safeHighlight = safeHighlights[0]; while ((offset = safeSnippet.toLowerCase().indexOf(safeHighlight.toLowerCase(), lastOffset)) >= 0) { // handle preamble if (offset > lastOffset) { @@ -301,7 +298,7 @@ class BaseHighlighter { // do highlight. use the original string rather than safeHighlight // to preserve the original casing. - var endOffset = offset + safeHighlight.length; + const endOffset = offset + safeHighlight.length; nodes.push(this._processSnippet(safeSnippet.substring(offset, endOffset), true)); lastOffset = endOffset; @@ -319,8 +316,7 @@ class BaseHighlighter { if (safeHighlights[1]) { // recurse into this range to check for the next set of highlight matches return this.applyHighlights(safeSnippet, safeHighlights.slice(1)); - } - else { + } else { // no more highlights to be found, just return the unhighlighted string return [this._processSnippet(safeSnippet, false)]; } @@ -341,7 +337,7 @@ class HtmlHighlighter extends BaseHighlighter { return snippet; } - var span = "" + let span = "" + snippet + ""; if (this.highlightLink) { @@ -366,15 +362,15 @@ class TextHighlighter extends BaseHighlighter { * returns a React node */ _processSnippet(snippet, highlight) { - var key = this._key++; + const key = this._key++; - var node = - + let node = + { snippet } ; if (highlight && this.highlightLink) { - node = {node}; + node = { node }; } return node; @@ -393,20 +389,20 @@ class TextHighlighter extends BaseHighlighter { export function bodyToHtml(content, highlights, opts) { opts = opts || {}; - var isHtml = (content.format === "org.matrix.custom.html"); - let body = isHtml ? content.formatted_body : escape(content.body); + const isHtml = (content.format === "org.matrix.custom.html"); + const body = isHtml ? content.formatted_body : escape(content.body); let bodyHasEmoji = false; - var safeBody; + let safeBody; // XXX: We sanitize the HTML whilst also highlighting its text nodes, to avoid accidentally trying // to highlight HTML tags themselves. However, this does mean that we don't highlight textnodes which // are interrupted by HTML tags (not that we did before) - e.g. foobar won't get highlighted // by an attempt to search for 'foobar'. Then again, the search query probably wouldn't work either try { if (highlights && highlights.length > 0) { - var highlighter = new HtmlHighlighter("mx_EventTile_searchHighlight", opts.highlightLink); - var safeHighlights = highlights.map(function(highlight) { + const highlighter = new HtmlHighlighter("mx_EventTile_searchHighlight", opts.highlightLink); + const safeHighlights = highlights.map(function(highlight) { return sanitizeHtml(highlight, sanitizeHtmlParams); }); // XXX: hacky bodge to temporarily apply a textFilter to the sanitizeHtmlParams structure. @@ -417,16 +413,15 @@ export function bodyToHtml(content, highlights, opts) { safeBody = sanitizeHtml(body, sanitizeHtmlParams); bodyHasEmoji = containsEmoji(body); if (bodyHasEmoji) safeBody = unicodeToImage(safeBody); - } - finally { + } finally { delete sanitizeHtmlParams.textFilter; } let emojiBody = false; if (bodyHasEmoji) { EMOJI_REGEX.lastIndex = 0; - let contentBodyTrimmed = content.body !== undefined ? content.body.trim() : ''; - let match = EMOJI_REGEX.exec(contentBodyTrimmed); + const contentBodyTrimmed = content.body !== undefined ? content.body.trim() : ''; + const match = EMOJI_REGEX.exec(contentBodyTrimmed); emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length; } diff --git a/src/ImageUtils.js b/src/ImageUtils.js index 3744241874..a83d94a633 100644 --- a/src/ImageUtils.js +++ b/src/ImageUtils.js @@ -42,13 +42,12 @@ module.exports = { // no scaling needs to be applied return fullHeight; } - var widthMulti = thumbWidth / fullWidth; - var heightMulti = thumbHeight / fullHeight; + const widthMulti = thumbWidth / fullWidth; + const heightMulti = thumbHeight / fullHeight; if (widthMulti < heightMulti) { // width is the dominant dimension so scaling will be fixed on that return Math.floor(widthMulti * fullHeight); - } - else { + } else { // height is the dominant dimension so scaling will be fixed on that return Math.floor(heightMulti * fullHeight); } diff --git a/src/Login.js b/src/Login.js index 049b79c2f4..0eff94ce60 100644 --- a/src/Login.js +++ b/src/Login.js @@ -59,8 +59,8 @@ export default class Login { } getFlows() { - var self = this; - var client = this._createTemporaryClient(); + const self = this; + const client = this._createTemporaryClient(); return client.loginFlows().then(function(result) { self._flows = result.flows; self._currentFlowIndex = 0; @@ -77,12 +77,12 @@ export default class Login { getCurrentFlowStep() { // technically the flow can have multiple steps, but no one does this // for login so we can ignore it. - var flowStep = this._flows[this._currentFlowIndex]; + const flowStep = this._flows[this._currentFlowIndex]; return flowStep ? flowStep.type : null; } loginAsGuest() { - var client = this._createTemporaryClient(); + const client = this._createTemporaryClient(); return client.registerGuest({ body: { initial_device_display_name: this._defaultDeviceDisplayName, @@ -94,7 +94,7 @@ export default class Login { accessToken: creds.access_token, homeserverUrl: this._hsUrl, identityServerUrl: this._isUrl, - guest: true + guest: true, }; }, (error) => { throw error; @@ -149,12 +149,12 @@ export default class Login { identityServerUrl: self._isUrl, userId: data.user_id, deviceId: data.device_id, - accessToken: data.access_token + accessToken: data.access_token, }); }, function(error) { if (error.httpStatus === 403) { if (self._fallbackHsUrl) { - var fbClient = Matrix.createClient({ + const fbClient = Matrix.createClient({ baseUrl: self._fallbackHsUrl, idBaseUrl: this._isUrl, }); @@ -165,7 +165,7 @@ export default class Login { identityServerUrl: self._isUrl, userId: data.user_id, deviceId: data.device_id, - accessToken: data.access_token + accessToken: data.access_token, }); }, function(fallback_error) { // throw the original error diff --git a/src/Markdown.js b/src/Markdown.js index 455d5e95bd..e05f163ba5 100644 --- a/src/Markdown.js +++ b/src/Markdown.js @@ -48,7 +48,7 @@ function html_if_tag_allowed(node) { * or false if it is only a single line. */ function is_multi_line(node) { - var par = node; + let par = node; while (par.parent) { par = par.parent; } @@ -143,7 +143,7 @@ export default class Markdown { if (isMultiLine) this.cr(); html_if_tag_allowed.call(this, node); if (isMultiLine) this.cr(); - } + }; return renderer.render(this.parsed); } @@ -178,7 +178,7 @@ export default class Markdown { renderer.html_block = function(node) { this.lit(node.literal); if (is_multi_line(node) && node.next) this.lit('\n\n'); - } + }; return renderer.render(this.parsed); } diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 4264828c7b..0c3d5b3775 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -95,7 +95,7 @@ class MatrixClientPeg { opts.pendingEventOrdering = "detached"; try { - let promise = this.matrixClient.store.startup(); + const promise = this.matrixClient.store.startup(); console.log(`MatrixClientPeg: waiting for MatrixClient store to initialise`); await promise; } catch(err) { @@ -136,7 +136,7 @@ class MatrixClientPeg { } _createClient(creds: MatrixClientCreds) { - var opts = { + const opts = { baseUrl: creds.homeserverUrl, idBaseUrl: creds.identityServerUrl, accessToken: creds.accessToken, @@ -153,8 +153,8 @@ class MatrixClientPeg { this.matrixClient.setGuest(Boolean(creds.guest)); - var notifTimelineSet = new EventTimelineSet(null, { - timelineSupport: true + const notifTimelineSet = new EventTimelineSet(null, { + timelineSupport: true, }); // XXX: what is our initial pagination token?! it somehow needs to be synchronised with /sync. notifTimelineSet.getLiveTimeline().setPaginationToken("", EventTimeline.BACKWARDS); diff --git a/src/Modal.js b/src/Modal.js index 056b6d8bf2..68d75d1ff1 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -17,8 +17,8 @@ limitations under the License. 'use strict'; -var React = require('react'); -var ReactDOM = require('react-dom'); +const React = require('react'); +const ReactDOM = require('react-dom'); import Analytics from './Analytics'; import sdk from './index'; @@ -137,15 +137,15 @@ class ModalManager { * @param {String} className CSS class to apply to the modal wrapper */ createDialogAsync(loader, props, className) { - var self = this; + const self = this; const modal = {}; // never call this from onFinished() otherwise it will loop // // nb explicit function() rather than arrow function, to get `arguments` - var closeDialog = function() { + const closeDialog = function() { if (props && props.onFinished) props.onFinished.apply(null, arguments); - var i = self._modals.indexOf(modal); + const i = self._modals.indexOf(modal); if (i >= 0) { self._modals.splice(i, 1); } @@ -160,7 +160,7 @@ class ModalManager { // property set here so you can't close the dialog from a button click! modal.elem = ( + onFinished={closeDialog} /> ); modal.onFinished = props ? props.onFinished : null; modal.className = className; @@ -191,13 +191,13 @@ class ModalManager { return; } - var modal = this._modals[0]; - var dialog = ( -
      + const modal = this._modals[0]; + const dialog = ( +
      - {modal.elem} + { modal.elem }
      -
      +
      ); diff --git a/src/Notifier.js b/src/Notifier.js index 155564dcdf..a2e80353e1 100644 --- a/src/Notifier.js +++ b/src/Notifier.js @@ -81,7 +81,7 @@ const Notifier = { } const avatarUrl = ev.sender ? Avatar.avatarUrlForMember( - ev.sender, 40, 40, 'crop' + ev.sender, 40, 40, 'crop', ) : null; const notif = plaf.displayNotification(title, msg, avatarUrl, room); @@ -303,7 +303,7 @@ const Notifier = { this._playAudioNotification(ev, room); } } - } + }, }; if (!global.mxNotifier) { diff --git a/src/Presence.js b/src/Presence.js index c45d571217..fab518e1cb 100644 --- a/src/Presence.js +++ b/src/Presence.js @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -var MatrixClientPeg = require("./MatrixClientPeg"); -var dis = require("./dispatcher"); +const MatrixClientPeg = require("./MatrixClientPeg"); +const dis = require("./dispatcher"); // Time in ms after that a user is considered as unavailable/away -var UNAVAILABLE_TIME_MS = 3 * 60 * 1000; // 3 mins -var PRESENCE_STATES = ["online", "offline", "unavailable"]; +const UNAVAILABLE_TIME_MS = 3 * 60 * 1000; // 3 mins +const PRESENCE_STATES = ["online", "offline", "unavailable"]; class Presence { @@ -71,14 +71,14 @@ class Presence { if (!this.running) { return; } - var old_state = this.state; + const old_state = this.state; this.state = newState; if (MatrixClientPeg.get().isGuest()) { return; // don't try to set presence when a guest; it won't work. } - var self = this; + const self = this; MatrixClientPeg.get().setPresence(this.state).done(function() { console.log("Presence: %s", newState); }, function(err) { @@ -104,7 +104,7 @@ class Presence { * @private */ _resetTimer() { - var self = this; + const self = this; this.setState("online"); // Re-arm the timer clearTimeout(this.timer); diff --git a/src/RichText.js b/src/RichText.js index cbd3b9ae18..4bc3815d25 100644 --- a/src/RichText.js +++ b/src/RichText.js @@ -44,9 +44,9 @@ export const contentStateToHTML = (contentState: ContentState) => { return stateToHTML(contentState, { inlineStyles: { UNDERLINE: { - element: 'u' - } - } + element: 'u', + }, + }, }); }; @@ -59,7 +59,7 @@ function unicodeToEmojiUri(str) { let replaceWith, unicode, alt; if ((!emojione.unicodeAlt) || (emojione.sprites)) { // if we are using the shortname as the alt tag then we need a reversed array to map unicode code point to shortnames - let mappedUnicode = emojione.mapUnicodeToShort(); + const mappedUnicode = emojione.mapUnicodeToShort(); } str = str.replace(emojione.regUnicode, function(unicodeChar) { @@ -90,14 +90,14 @@ function findWithRegex(regex, contentBlock: ContentBlock, callback: (start: numb } // Workaround for https://github.com/facebook/draft-js/issues/414 -let emojiDecorator = { +const emojiDecorator = { strategy: (contentState, contentBlock, callback) => { findWithRegex(EMOJI_REGEX, contentBlock, callback); }, component: (props) => { - let uri = unicodeToEmojiUri(props.children[0].props.text); - let shortname = emojione.toShort(props.children[0].props.text); - let style = { + const uri = unicodeToEmojiUri(props.children[0].props.text); + const shortname = emojione.toShort(props.children[0].props.text); + const style = { display: 'inline-block', width: '1em', maxHeight: '1em', @@ -106,7 +106,7 @@ let emojiDecorator = { backgroundPosition: 'center center', overflow: 'hidden', }; - return ({props.children}); + return ({ props.children }); }, }; @@ -118,16 +118,16 @@ export function getScopedRTDecorators(scope: any): CompositeDecorator { } export function getScopedMDDecorators(scope: any): CompositeDecorator { - let markdownDecorators = ['HR', 'BOLD', 'ITALIC', 'CODE', 'STRIKETHROUGH'].map( + const markdownDecorators = ['HR', 'BOLD', 'ITALIC', 'CODE', 'STRIKETHROUGH'].map( (style) => ({ strategy: (contentState, contentBlock, callback) => { return findWithRegex(MARKDOWN_REGEX[style], contentBlock, callback); }, component: (props) => ( - {props.children} + { props.children } - ) + ), })); markdownDecorators.push({ @@ -136,9 +136,9 @@ export function getScopedMDDecorators(scope: any): CompositeDecorator { }, component: (props) => ( - {props.children} + { props.children } - ) + ), }); // markdownDecorators.push(emojiDecorator); // TODO Consider renabling "syntax highlighting" when we can do it properly @@ -161,7 +161,7 @@ export function modifyText(contentState: ContentState, rangeToReplace: Selection for (let currentKey = startKey; currentKey && currentKey !== endKey; currentKey = contentState.getKeyAfter(currentKey)) { - let blockText = getText(currentKey); + const blockText = getText(currentKey); text += blockText.substring(startOffset, blockText.length); // from now on, we'll take whole blocks @@ -182,7 +182,7 @@ export function modifyText(contentState: ContentState, rangeToReplace: Selection export function selectionStateToTextOffsets(selectionState: SelectionState, contentBlocks: Array): {start: number, end: number} { let offset = 0, start = 0, end = 0; - for (let block of contentBlocks) { + for (const block of contentBlocks) { if (selectionState.getStartKey() === block.getKey()) { start = offset + selectionState.getStartOffset(); } @@ -259,7 +259,7 @@ export function attachImmutableEntitiesToEmoji(editorState: EditorState): Editor .set('focusOffset', end); const emojiText = plainText.substring(start, end); newContentState = newContentState.createEntity( - 'emoji', 'IMMUTABLE', { emojiUnicode: emojiText } + 'emoji', 'IMMUTABLE', { emojiUnicode: emojiText }, ); const entityKey = newContentState.getLastCreatedEntityKey(); newContentState = Modifier.replaceText( diff --git a/src/Rooms.js b/src/Rooms.js index 2e3f4457f0..6cc2d867a6 100644 --- a/src/Rooms.js +++ b/src/Rooms.js @@ -62,8 +62,7 @@ export function isConfCallRoom(room, me, conferenceHandler) { export function looksLikeDirectMessageRoom(room, me) { if (me.membership == "join" || me.membership === "ban" || - (me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) - { + (me.membership === "leave" && me.events.member.getSender() !== me.events.member.getStateKey())) { // Used to split rooms via tags const tagNames = Object.keys(room.tags); // Used for 1:1 direct chats diff --git a/src/ScalarAuthClient.js b/src/ScalarAuthClient.js index 0b753cf3ab..c9d056f88e 100644 --- a/src/ScalarAuthClient.js +++ b/src/ScalarAuthClient.js @@ -15,10 +15,10 @@ limitations under the License. */ import Promise from 'bluebird'; -var request = require('browser-request'); +const request = require('browser-request'); -var SdkConfig = require('./SdkConfig'); -var MatrixClientPeg = require('./MatrixClientPeg'); +const SdkConfig = require('./SdkConfig'); +const MatrixClientPeg = require('./MatrixClientPeg'); class ScalarAuthClient { @@ -38,7 +38,7 @@ class ScalarAuthClient { // Returns a scalar_token string getScalarToken() { - var tok = window.localStorage.getItem("mx_scalar_token"); + const tok = window.localStorage.getItem("mx_scalar_token"); if (tok) return Promise.resolve(tok); // No saved token, so do the dance to get one. First, we @@ -53,9 +53,9 @@ class ScalarAuthClient { } exchangeForScalarToken(openid_token_object) { - var defer = Promise.defer(); + const defer = Promise.defer(); - var scalar_rest_url = SdkConfig.get().integrations_rest_url; + const scalar_rest_url = SdkConfig.get().integrations_rest_url; request({ method: 'POST', uri: scalar_rest_url+'/register', @@ -77,7 +77,7 @@ class ScalarAuthClient { } getScalarInterfaceUrlForRoom(roomId, screen, id) { - var url = SdkConfig.get().integrations_ui_url; + let url = SdkConfig.get().integrations_ui_url; url += "?scalar_token=" + encodeURIComponent(this.scalarToken); url += "&room_id=" + encodeURIComponent(roomId); if (id) { diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index d14d439d66..7698829647 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -356,12 +356,12 @@ function getWidgets(event, roomId) { } const stateEvents = room.currentState.getStateEvents("im.vector.modular.widgets"); // Only return widgets which have required fields - let widgetStateEvents = []; + const widgetStateEvents = []; stateEvents.forEach((ev) => { if (ev.getContent().type && ev.getContent().url) { widgetStateEvents.push(ev.event); // return the raw event } - }) + }); sendResponse(event, widgetStateEvents); } @@ -376,7 +376,7 @@ function setPlumbingState(event, roomId, status) { sendError(event, _t('You need to be logged in.')); return; } - client.sendStateEvent(roomId, "m.room.plumbing", { status : status }).done(() => { + client.sendStateEvent(roomId, "m.room.plumbing", { status: status }).done(() => { sendResponse(event, { success: true, }); @@ -415,11 +415,11 @@ function setBotPower(event, roomId, userId, level) { } client.getStateEvent(roomId, "m.room.power_levels", "").then((powerLevels) => { - let powerEvent = new MatrixEvent( + const powerEvent = new MatrixEvent( { type: "m.room.power_levels", content: powerLevels, - } + }, ); client.setPowerLevel(roomId, userId, level, powerEvent).done(() => { @@ -485,8 +485,7 @@ function canSendEvent(event, roomId) { let canSend = false; if (isState) { canSend = room.currentState.maySendStateEvent(evType, me); - } - else { + } else { canSend = room.currentState.maySendEvent(evType, me); } @@ -517,8 +516,8 @@ function returnStateEvent(event, roomId, eventType, stateKey) { sendResponse(event, stateEvent.getContent()); } -var currentRoomId = null; -var currentRoomAlias = null; +let currentRoomId = null; +let currentRoomAlias = null; // Listen for when a room is viewed dis.register(onAction); @@ -542,7 +541,7 @@ const onMessage = function(event) { // // All strings start with the empty string, so for sanity return if the length // of the event origin is 0. - let url = SdkConfig.get().integrations_ui_url; + const url = SdkConfig.get().integrations_ui_url; if (event.origin.length === 0 || !url.startsWith(event.origin) || !event.data.action) { return; // don't log this - debugging APIs like to spam postMessage which floods the log otherwise } @@ -647,7 +646,7 @@ module.exports = { // Make an error so we get a stack trace const e = new Error( "ScalarMessaging: mismatched startListening / stopListening detected." + - " Negative count" + " Negative count", ); console.error(e); } diff --git a/src/Tinter.js b/src/Tinter.js index 5bf13e6d4a..6b23df8c9b 100644 --- a/src/Tinter.js +++ b/src/Tinter.js @@ -18,10 +18,10 @@ limitations under the License. // module.exports otherwise this will break when included by both // react-sdk and apps layered on top. -var DEBUG = 0; +const DEBUG = 0; // The colour keys to be replaced as referred to in CSS -var keyRgb = [ +const keyRgb = [ "rgb(118, 207, 166)", // Vector Green "rgb(234, 245, 240)", // Vector Light Green "rgb(211, 239, 225)", // BottomLeftMenu overlay (20% Vector Green) @@ -35,7 +35,7 @@ var keyRgb = [ // x = (255 - 234) / (255 - 118) = 0.16 // The colour keys to be replaced as referred to in SVGs -var keyHex = [ +const keyHex = [ "#76CFA6", // Vector Green "#EAF5F0", // Vector Light Green "#D3EFE1", // BottomLeftMenu overlay (20% Vector Green overlaid on Vector Light Green) @@ -44,14 +44,14 @@ var keyHex = [ // cache of our replacement colours // defaults to our keys. -var colors = [ +const colors = [ keyHex[0], keyHex[1], keyHex[2], keyHex[3], ]; -var cssFixups = [ +const cssFixups = [ // { // style: a style object that should be fixed up taken from a stylesheet // attr: name of the attribute to be clobbered, e.g. 'color' @@ -60,7 +60,7 @@ var cssFixups = [ ]; // CSS attributes to be fixed up -var cssAttrs = [ +const cssAttrs = [ "color", "backgroundColor", "borderColor", @@ -69,17 +69,17 @@ var cssAttrs = [ "borderLeftColor", ]; -var svgAttrs = [ +const svgAttrs = [ "fill", "stroke", ]; -var cached = false; +let cached = false; function calcCssFixups() { if (DEBUG) console.log("calcSvgFixups start"); - for (var i = 0; i < document.styleSheets.length; i++) { - var ss = document.styleSheets[i]; + for (let i = 0; i < document.styleSheets.length; i++) { + const ss = document.styleSheets[i]; if (!ss) continue; // well done safari >:( // Chromium apparently sometimes returns null here; unsure why. // see $14534907369972FRXBx:matrix.org in HQ @@ -104,12 +104,12 @@ function calcCssFixups() { if (ss.href && !ss.href.match(/\/bundle.*\.css$/)) continue; if (!ss.cssRules) continue; - for (var j = 0; j < ss.cssRules.length; j++) { - var rule = ss.cssRules[j]; + for (let j = 0; j < ss.cssRules.length; j++) { + const rule = ss.cssRules[j]; if (!rule.style) continue; - for (var k = 0; k < cssAttrs.length; k++) { - var attr = cssAttrs[k]; - for (var l = 0; l < keyRgb.length; l++) { + for (let k = 0; k < cssAttrs.length; k++) { + const attr = cssAttrs[k]; + for (let l = 0; l < keyRgb.length; l++) { if (rule.style[attr] === keyRgb[l]) { cssFixups.push({ style: rule.style, @@ -126,8 +126,8 @@ function calcCssFixups() { function applyCssFixups() { if (DEBUG) console.log("applyCssFixups start"); - for (var i = 0; i < cssFixups.length; i++) { - var cssFixup = cssFixups[i]; + for (let i = 0; i < cssFixups.length; i++) { + const cssFixup = cssFixups[i]; cssFixup.style[cssFixup.attr] = colors[cssFixup.index]; } if (DEBUG) console.log("applyCssFixups end"); @@ -140,15 +140,15 @@ function hexToRgb(color) { color[1] + color[1] + color[2] + color[2]; } - var val = parseInt(color, 16); - var r = (val >> 16) & 255; - var g = (val >> 8) & 255; - var b = val & 255; + const val = parseInt(color, 16); + const r = (val >> 16) & 255; + const g = (val >> 8) & 255; + const b = val & 255; return [r, g, b]; } function rgbToHex(rgb) { - var val = (rgb[0] << 16) | (rgb[1] << 8) | rgb[2]; + const val = (rgb[0] << 16) | (rgb[1] << 8) | rgb[2]; return '#' + (0x1000000 + val).toString(16).slice(1); } @@ -167,12 +167,11 @@ module.exports = { * * @param {Function} tintable Function to call when the tint changes. */ - registerTintable : function(tintable) { + registerTintable: function(tintable) { tintables.push(tintable); }, tint: function(primaryColor, secondaryColor, tertiaryColor) { - if (!cached) { calcCssFixups(); cached = true; @@ -185,7 +184,7 @@ module.exports = { if (!secondaryColor) { const x = 0.16; // average weighting factor calculated from vector green & light green - var rgb = hexToRgb(primaryColor); + const rgb = hexToRgb(primaryColor); rgb[0] = x * rgb[0] + (1 - x) * 255; rgb[1] = x * rgb[1] + (1 - x) * 255; rgb[2] = x * rgb[2] + (1 - x) * 255; @@ -194,8 +193,8 @@ module.exports = { if (!tertiaryColor) { const x = 0.19; - var rgb1 = hexToRgb(primaryColor); - var rgb2 = hexToRgb(secondaryColor); + const rgb1 = hexToRgb(primaryColor); + const rgb2 = hexToRgb(secondaryColor); rgb1[0] = x * rgb1[0] + (1 - x) * rgb2[0]; rgb1[1] = x * rgb1[1] + (1 - x) * rgb2[1]; rgb1[2] = x * rgb1[2] + (1 - x) * rgb2[2]; @@ -204,8 +203,7 @@ module.exports = { if (colors[0] === primaryColor && colors[1] === secondaryColor && - colors[2] === tertiaryColor) - { + colors[2] === tertiaryColor) { return; } @@ -248,14 +246,13 @@ module.exports = { // key colour; cache the element and apply. if (DEBUG) console.log("calcSvgFixups start for " + svgs); - var fixups = []; - for (var i = 0; i < svgs.length; i++) { + const fixups = []; + for (let i = 0; i < svgs.length; i++) { var svgDoc; try { svgDoc = svgs[i].contentDocument; - } - catch(e) { - var msg = 'Failed to get svg.contentDocument of ' + svgs[i].toString(); + } catch(e) { + let msg = 'Failed to get svg.contentDocument of ' + svgs[i].toString(); if (e.message) { msg += e.message; } @@ -265,12 +262,12 @@ module.exports = { console.error(e); } if (!svgDoc) continue; - var tags = svgDoc.getElementsByTagName("*"); - for (var j = 0; j < tags.length; j++) { - var tag = tags[j]; - for (var k = 0; k < svgAttrs.length; k++) { - var attr = svgAttrs[k]; - for (var l = 0; l < keyHex.length; l++) { + const tags = svgDoc.getElementsByTagName("*"); + for (let j = 0; j < tags.length; j++) { + const tag = tags[j]; + for (let k = 0; k < svgAttrs.length; k++) { + const attr = svgAttrs[k]; + for (let l = 0; l < keyHex.length; l++) { if (tag.getAttribute(attr) && tag.getAttribute(attr).toUpperCase() === keyHex[l]) { fixups.push({ node: tag, @@ -289,10 +286,10 @@ module.exports = { applySvgFixups: function(fixups) { if (DEBUG) console.log("applySvgFixups start for " + fixups); - for (var i = 0; i < fixups.length; i++) { - var svgFixup = fixups[i]; + for (let i = 0; i < fixups.length; i++) { + const svgFixup = fixups[i]; svgFixup.node.setAttribute(svgFixup.attr, colors[svgFixup.index]); } if (DEBUG) console.log("applySvgFixups end"); - } + }, }; diff --git a/src/Unread.js b/src/Unread.js index 8fffc2a429..20e876ad88 100644 --- a/src/Unread.js +++ b/src/Unread.js @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -var MatrixClientPeg = require('./MatrixClientPeg'); +const MatrixClientPeg = require('./MatrixClientPeg'); import UserSettingsStore from './UserSettingsStore'; import shouldHideEvent from './shouldHideEvent'; -var sdk = require('./index'); +const sdk = require('./index'); module.exports = { /** @@ -34,17 +34,17 @@ module.exports = { } else if (ev.getType == 'm.room.message' && ev.getContent().msgtype == 'm.notify') { return false; } - var EventTile = sdk.getComponent('rooms.EventTile'); + const EventTile = sdk.getComponent('rooms.EventTile'); return EventTile.haveTileForEvent(ev); }, doesRoomHaveUnreadMessages: function(room) { - var myUserId = MatrixClientPeg.get().credentials.userId; + const myUserId = MatrixClientPeg.get().credentials.userId; // get the most recent read receipt sent by our account. // N.B. this is NOT a read marker (RM, aka "read up to marker"), // despite the name of the method :(( - var readUpToId = room.getEventReadUpTo(myUserId); + const readUpToId = room.getEventReadUpTo(myUserId); // as we don't send RRs for our own messages, make sure we special case that // if *we* sent the last message into the room, we consider it not unread! @@ -54,8 +54,7 @@ module.exports = { // https://github.com/vector-im/riot-web/issues/3363 if (room.timeline.length && room.timeline[room.timeline.length - 1].sender && - room.timeline[room.timeline.length - 1].sender.userId === myUserId) - { + room.timeline[room.timeline.length - 1].sender.userId === myUserId) { return false; } @@ -67,8 +66,8 @@ module.exports = { const syncedSettings = UserSettingsStore.getSyncedSettings(); // Loop through messages, starting with the most recent... - for (var i = room.timeline.length - 1; i >= 0; --i) { - var ev = room.timeline[i]; + for (let i = room.timeline.length - 1; i >= 0; --i) { + const ev = room.timeline[i]; if (ev.getId() == readUpToId) { // If we've read up to this event, there's nothing more recents @@ -86,5 +85,5 @@ module.exports = { // is unread on the theory that false positives are better than // false negatives here. return true; - } + }, }; diff --git a/src/Velociraptor.js b/src/Velociraptor.js index 9c85bafca0..9a674d4f09 100644 --- a/src/Velociraptor.js +++ b/src/Velociraptor.js @@ -1,6 +1,6 @@ -var React = require('react'); -var ReactDom = require('react-dom'); -var Velocity = require('velocity-vector'); +const React = require('react'); +const ReactDom = require('react-dom'); +const Velocity = require('velocity-vector'); /** * The Velociraptor contains components and animates transitions with velocity. @@ -46,13 +46,13 @@ module.exports = React.createClass({ * update `this.children` according to the new list of children given */ _updateChildren: function(newChildren) { - var self = this; - var oldChildren = this.children || {}; + const self = this; + const oldChildren = this.children || {}; this.children = {}; React.Children.toArray(newChildren).forEach(function(c) { if (oldChildren[c.key]) { - var old = oldChildren[c.key]; - var oldNode = ReactDom.findDOMNode(self.nodes[old.key]); + const old = oldChildren[c.key]; + const oldNode = ReactDom.findDOMNode(self.nodes[old.key]); if (oldNode && oldNode.style.left != c.props.style.left) { Velocity(oldNode, { left: c.props.style.left }, self.props.transition).then(function() { @@ -71,18 +71,18 @@ module.exports = React.createClass({ } else { // new element. If we have a startStyle, use that as the style and go through // the enter animations - var newProps = {}; - var restingStyle = c.props.style; + const newProps = {}; + const restingStyle = c.props.style; - var startStyles = self.props.startStyles; + const startStyles = self.props.startStyles; if (startStyles.length > 0) { - var startStyle = startStyles[0]; + const startStyle = startStyles[0]; newProps.style = startStyle; // console.log("mounted@startstyle0: "+JSON.stringify(startStyle)); } - newProps.ref = (n => self._collectNode( - c.key, n, restingStyle + newProps.ref = ((n) => self._collectNode( + c.key, n, restingStyle, )); self.children[c.key] = React.cloneElement(c, newProps); @@ -103,8 +103,8 @@ module.exports = React.createClass({ this.nodes[k] === undefined && this.props.startStyles.length > 0 ) { - var startStyles = this.props.startStyles; - var transitionOpts = this.props.enterTransitionOpts; + const startStyles = this.props.startStyles; + const transitionOpts = this.props.enterTransitionOpts; const domNode = ReactDom.findDOMNode(node); // start from startStyle 1: 0 is the one we gave it // to start with, so now we animate 1 etc. @@ -154,7 +154,7 @@ module.exports = React.createClass({ render: function() { return ( - {Object.values(this.children)} + { Object.values(this.children) } ); }, diff --git a/src/VelocityBounce.js b/src/VelocityBounce.js index 3ad7d207a9..2141b05325 100644 --- a/src/VelocityBounce.js +++ b/src/VelocityBounce.js @@ -1,9 +1,9 @@ -var Velocity = require('velocity-vector'); +const Velocity = require('velocity-vector'); // courtesy of https://github.com/julianshapiro/velocity/issues/283 // We only use easeOutBounce (easeInBounce is just sort of nonsensical) function bounce( p ) { - var pow2, + let pow2, bounce = 4; while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) { diff --git a/src/WhoIsTyping.js b/src/WhoIsTyping.js index 2a12703a27..6bea2cbb92 100644 --- a/src/WhoIsTyping.js +++ b/src/WhoIsTyping.js @@ -14,19 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. */ -var MatrixClientPeg = require("./MatrixClientPeg"); +const MatrixClientPeg = require("./MatrixClientPeg"); import { _t } from './languageHandler'; module.exports = { usersTypingApartFromMeAndIgnored: function(room) { return this.usersTyping( - room, [MatrixClientPeg.get().credentials.userId].concat(MatrixClientPeg.get().getIgnoredUsers()) + room, [MatrixClientPeg.get().credentials.userId].concat(MatrixClientPeg.get().getIgnoredUsers()), ); }, usersTypingApartFromMe: function(room) { return this.usersTyping( - room, [MatrixClientPeg.get().credentials.userId] + room, [MatrixClientPeg.get().credentials.userId], ); }, @@ -35,15 +35,15 @@ module.exports = { * to exclude, return a list of user objects who are typing. */ usersTyping: function(room, exclude) { - var whoIsTyping = []; + const whoIsTyping = []; if (exclude === undefined) { exclude = []; } - var memberKeys = Object.keys(room.currentState.members); - for (var i = 0; i < memberKeys.length; ++i) { - var userId = memberKeys[i]; + const memberKeys = Object.keys(room.currentState.members); + for (let i = 0; i < memberKeys.length; ++i) { + const userId = memberKeys[i]; if (room.currentState.members[userId].typing) { if (exclude.indexOf(userId) == -1) { @@ -76,5 +76,5 @@ module.exports = { const lastPerson = names.pop(); return _t('%(names)s and %(lastPerson)s are typing', {names: names.join(', '), lastPerson: lastPerson}); } - } + }, }; diff --git a/src/async-components/views/dialogs/EncryptedEventDialog.js b/src/async-components/views/dialogs/EncryptedEventDialog.js index cec2f05de2..a8f588d39a 100644 --- a/src/async-components/views/dialogs/EncryptedEventDialog.js +++ b/src/async-components/views/dialogs/EncryptedEventDialog.js @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -var React = require("react"); +const React = require("react"); import { _t } from '../../../languageHandler'; -var sdk = require('../../../index'); -var MatrixClientPeg = require("../../../MatrixClientPeg"); +const sdk = require('../../../index'); +const MatrixClientPeg = require("../../../MatrixClientPeg"); module.exports = React.createClass({ displayName: 'EncryptedEventDialog', @@ -33,7 +33,7 @@ module.exports = React.createClass({ componentWillMount: function() { this._unmounted = false; - var client = MatrixClientPeg.get(); + const client = MatrixClientPeg.get(); // first try to load the device from our store. // @@ -60,7 +60,7 @@ module.exports = React.createClass({ componentWillUnmount: function() { this._unmounted = true; - var client = MatrixClientPeg.get(); + const client = MatrixClientPeg.get(); if (client) { client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged); } @@ -89,12 +89,12 @@ module.exports = React.createClass({ }, _renderDeviceInfo: function() { - var device = this.state.device; + const device = this.state.device; if (!device) { return ({ _t('unknown device') }); } - var verificationStatus = ({ _t('NOT verified') }); + let verificationStatus = ({ _t('NOT verified') }); if (device.isBlocked()) { verificationStatus = ({ _t('Blacklisted') }); } else if (device.isVerified()) { @@ -118,7 +118,7 @@ module.exports = React.createClass({ { _t('Ed25519 fingerprint') } - {device.getFingerprint()} + { device.getFingerprint() } @@ -126,7 +126,7 @@ module.exports = React.createClass({ }, _renderEventInfo: function() { - var event = this.props.event; + const event = this.props.event; return ( @@ -165,36 +165,36 @@ module.exports = React.createClass({ }, render: function() { - var DeviceVerifyButtons = sdk.getComponent('elements.DeviceVerifyButtons'); + const DeviceVerifyButtons = sdk.getComponent('elements.DeviceVerifyButtons'); - var buttons = null; + let buttons = null; if (this.state.device) { buttons = ( - ); } return ( -
      +
      { _t('End-to-end encryption information') }

      { _t('Event information') }

      - {this._renderEventInfo()} + { this._renderEventInfo() }

      { _t('Sender device information') }

      - {this._renderDeviceInfo()} + { this._renderDeviceInfo() }
      - - {buttons} + { buttons }
      ); - } + }, }); diff --git a/src/autocomplete/Autocompleter.js b/src/autocomplete/Autocompleter.js index 7a64fb154c..5b10110f04 100644 --- a/src/autocomplete/Autocompleter.js +++ b/src/autocomplete/Autocompleter.js @@ -45,7 +45,7 @@ const PROVIDERS = [ EmojiProvider, CommandProvider, DuckDuckGoProvider, -].map(completer => completer.getInstance()); +].map((completer) => completer.getInstance()); // Providers will get rejected if they take longer than this. const PROVIDER_COMPLETION_TIMEOUT = 3000; diff --git a/src/autocomplete/Components.js b/src/autocomplete/Components.js index 0f0399cf7d..a27533f7c2 100644 --- a/src/autocomplete/Components.js +++ b/src/autocomplete/Components.js @@ -30,13 +30,13 @@ export class TextualCompletion extends React.Component { subtitle, description, className, - ...restProps, + ...restProps } = this.props; return (
      - {title} - {subtitle} - {description} + { title } + { subtitle } + { description }
      ); } @@ -56,14 +56,14 @@ export class PillCompletion extends React.Component { description, initialComponent, className, - ...restProps, + ...restProps } = this.props; return (
      - {initialComponent} - {title} - {subtitle} - {description} + { initialComponent } + { title } + { subtitle } + { description }
      ); } diff --git a/src/autocomplete/DuckDuckGoProvider.js b/src/autocomplete/DuckDuckGoProvider.js index 9c996bb1cc..b2e85c4668 100644 --- a/src/autocomplete/DuckDuckGoProvider.js +++ b/src/autocomplete/DuckDuckGoProvider.js @@ -38,7 +38,7 @@ export default class DuckDuckGoProvider extends AutocompleteProvider { } async getCompletions(query: string, selection: {start: number, end: number}) { - let {command, range} = this.getCurrentCommand(query, selection); + const {command, range} = this.getCurrentCommand(query, selection); if (!query || !command) { return []; } @@ -47,7 +47,7 @@ export default class DuckDuckGoProvider extends AutocompleteProvider { method: 'GET', }); const json = await response.json(); - let results = json.Results.map(result => { + const results = json.Results.map((result) => { return { completion: result.Text, component: ( @@ -105,7 +105,7 @@ export default class DuckDuckGoProvider extends AutocompleteProvider { renderCompletions(completions: [React.Component]): ?React.Component { return
      - {completions} + { completions }
      ; } } diff --git a/src/autocomplete/EmojiProvider.js b/src/autocomplete/EmojiProvider.js index 35a2ee6b53..a5b80e3b0e 100644 --- a/src/autocomplete/EmojiProvider.js +++ b/src/autocomplete/EmojiProvider.js @@ -138,7 +138,7 @@ export default class EmojiProvider extends AutocompleteProvider { return { completion: unicode, component: ( - {unicode}} /> + { unicode }} /> ), range, }; @@ -152,14 +152,13 @@ export default class EmojiProvider extends AutocompleteProvider { } static getInstance() { - if (instance == null) - {instance = new EmojiProvider();} + if (instance == null) {instance = new EmojiProvider();} return instance; } renderCompletions(completions: [React.Component]): ?React.Component { return
      - {completions} + { completions }
      ; } } diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js index 26b30a3d27..296399c06c 100644 --- a/src/autocomplete/UserProvider.js +++ b/src/autocomplete/UserProvider.js @@ -59,7 +59,7 @@ export default class UserProvider extends AutocompleteProvider { if (this.users === null) this._makeUsers(); let completions = []; - let {command, range} = this.getCurrentCommand(query, selection, force); + const {command, range} = this.getCurrentCommand(query, selection, force); if (command) { completions = this.matcher.match(command[0]).map((user) => { const displayName = (user.name || user.userId || '').replace(' (IRC)', ''); // FIXME when groups are done @@ -71,7 +71,7 @@ export default class UserProvider extends AutocompleteProvider { href: 'https://matrix.to/#/' + user.userId, component: ( } + initialComponent={} title={displayName} description={user.userId} /> ), @@ -132,7 +132,7 @@ export default class UserProvider extends AutocompleteProvider { renderCompletions(completions: [React.Component]): ?React.Component { return
      - {completions} + { completions }
      ; } diff --git a/src/components/structures/ContextualMenu.js b/src/components/structures/ContextualMenu.js index e5a62b8345..c3ad7f9cd1 100644 --- a/src/components/structures/ContextualMenu.js +++ b/src/components/structures/ContextualMenu.js @@ -17,9 +17,9 @@ limitations under the License. 'use strict'; -var classNames = require('classnames'); -var React = require('react'); -var ReactDOM = require('react-dom'); +const classNames = require('classnames'); +const React = require('react'); +const ReactDOM = require('react-dom'); // Shamelessly ripped off Modal.js. There's probably a better way // of doing reusable widgets like dialog boxes & menus where we go and @@ -36,7 +36,7 @@ module.exports = { }, getOrCreateContainer: function() { - var container = document.getElementById(this.ContextualMenuContainerId); + let container = document.getElementById(this.ContextualMenuContainerId); if (!container) { container = document.createElement("div"); @@ -48,9 +48,9 @@ module.exports = { }, createMenu: function(Element, props) { - var self = this; + const self = this; - var closeMenu = function() { + const closeMenu = function() { ReactDOM.unmountComponentAtNode(self.getOrCreateContainer()); if (props && props.onFinished) { @@ -58,17 +58,17 @@ module.exports = { } }; - var position = { + const position = { top: props.top, }; - var chevronOffset = {}; + const chevronOffset = {}; if (props.chevronOffset) { chevronOffset.top = props.chevronOffset; } // To override the default chevron colour, if it's been set - var chevronCSS = ""; + let chevronCSS = ""; if (props.menuColour) { chevronCSS = ` .mx_ContextualMenu_chevron_left:after { @@ -81,7 +81,7 @@ module.exports = { `; } - var chevron = null; + let chevron = null; if (props.left) { chevron =
      ; position.left = props.left; @@ -90,15 +90,15 @@ module.exports = { position.right = props.right; } - var className = 'mx_ContextualMenu_wrapper'; + const className = 'mx_ContextualMenu_wrapper'; - var menuClasses = classNames({ + const menuClasses = classNames({ 'mx_ContextualMenu': true, 'mx_ContextualMenu_left': props.left, 'mx_ContextualMenu_right': !props.left, }); - var menuStyle = {}; + const menuStyle = {}; if (props.menuWidth) { menuStyle.width = props.menuWidth; } @@ -113,14 +113,14 @@ module.exports = { // FIXME: If a menu uses getDefaultProps it clobbers the onFinished // property set here so you can't close the menu from a button click! - var menu = ( + const menu = (
      - {chevron} - + { chevron } +
      - +
      ); diff --git a/src/components/structures/CreateRoom.js b/src/components/structures/CreateRoom.js index 7ecc315ba7..26454c5ea6 100644 --- a/src/components/structures/CreateRoom.js +++ b/src/components/structures/CreateRoom.js @@ -61,7 +61,7 @@ module.exports = React.createClass({ }, onCreateRoom: function() { - var options = {}; + const options = {}; if (this.state.room_name) { options.name = this.state.room_name; @@ -79,14 +79,14 @@ module.exports = React.createClass({ { type: "m.room.join_rules", content: { - "join_rule": this.state.is_private ? "invite" : "public" - } + "join_rule": this.state.is_private ? "invite" : "public", + }, }, { type: "m.room.history_visibility", content: { - "history_visibility": this.state.share_history ? "shared" : "invited" - } + "history_visibility": this.state.share_history ? "shared" : "invited", + }, }, ]; } @@ -94,19 +94,19 @@ module.exports = React.createClass({ options.invite = this.state.invited_users; - var alias = this.getAliasLocalpart(); + const alias = this.getAliasLocalpart(); if (alias) { options.room_alias_name = alias; } - var cli = MatrixClientPeg.get(); + const cli = MatrixClientPeg.get(); if (!cli) { // TODO: Error. console.error("Cannot create room: No matrix client."); return; } - var deferred = cli.createRoom(options); + const deferred = cli.createRoom(options); if (this.state.encrypt) { // TODO @@ -116,7 +116,7 @@ module.exports = React.createClass({ phase: this.phases.CREATING, }); - var self = this; + const self = this; deferred.then(function(resp) { self.setState({ @@ -209,7 +209,7 @@ module.exports = React.createClass({ onAliasChanged: function(alias) { this.setState({ - alias: alias + alias: alias, }); }, @@ -220,64 +220,64 @@ module.exports = React.createClass({ }, render: function() { - var curr_phase = this.state.phase; + const curr_phase = this.state.phase; if (curr_phase == this.phases.CREATING) { - var Loader = sdk.getComponent("elements.Spinner"); + const Loader = sdk.getComponent("elements.Spinner"); return ( - + ); } else { - var error_box = ""; + let error_box = ""; if (curr_phase == this.phases.ERROR) { error_box = (
      - {_t('An error occurred: %(error_string)s', {error_string: this.state.error_string})} + { _t('An error occurred: %(error_string)s', {error_string: this.state.error_string}) }
      ); } - var CreateRoomButton = sdk.getComponent("create_room.CreateRoomButton"); - var RoomAlias = sdk.getComponent("create_room.RoomAlias"); - var Presets = sdk.getComponent("create_room.Presets"); - var UserSelector = sdk.getComponent("elements.UserSelector"); - var SimpleRoomHeader = sdk.getComponent("rooms.SimpleRoomHeader"); + const CreateRoomButton = sdk.getComponent("create_room.CreateRoomButton"); + const RoomAlias = sdk.getComponent("create_room.RoomAlias"); + const Presets = sdk.getComponent("create_room.Presets"); + const UserSelector = sdk.getComponent("elements.UserSelector"); + const SimpleRoomHeader = sdk.getComponent("rooms.SimpleRoomHeader"); - var domain = MatrixClientPeg.get().getDomain(); + const domain = MatrixClientPeg.get().getDomain(); return (
      - +
      -
      -