From 36218093fc45023d873b8c002cc6d1a9ea60feed Mon Sep 17 00:00:00 2001 From: RiotTranslate Date: Mon, 5 Jun 2017 15:31:09 +0200 Subject: [PATCH 1/8] Update from Weblate. (#1030) * Added translation using Weblate (Thai) * Translated using Weblate (Thai) Currently translated at 2.6% (22 of 827 strings) Translation: Riot Web/matrix-react-sdk Translate-URL: https://translate.nordgedanken.de/projects/riot-web/matrix-react-sdk/th/ --- src/i18n/strings/th.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/i18n/strings/th.json diff --git a/src/i18n/strings/th.json b/src/i18n/strings/th.json new file mode 100644 index 0000000000..9e4266753c --- /dev/null +++ b/src/i18n/strings/th.json @@ -0,0 +1,24 @@ +{ + "de": "เยอร์มัน", + "en-us": "อังกฤษ (สหรัฐอเมริกา)", + "en": "อังกฤษ", + "en-ca": "อังกฤษ(แคนาดา)", + "ja": "ญี่ปุ่น", + "fr": "ฝรั่งเศส", + "ko": "เกาหลี", + "th": "ไทย", + "vi": "เวียดนาม", + "accept": "ยอมรับ", + "Account": "บัญชี", + "Add phone number": "เพิ่มหมายเลขโทรศัพท์", + "Microphone": "ไมโครโฟน", + "No Microphones detected": "ไม่พบไมโครโฟน", + "Camera": "กล้อง", + "Advanced": "ขึ้นสูง", + "and": "และ", + "Ban": "แบน", + "Bug Report": "รายงานจุดบกพร่อง", + "Change Password": "เปลี่ยนรหัสผ่าน", + "Create Room": "สรัางห้อง", + "Delete": "ลบ" +} From c5cd6aecd60b61c4047e88f1aa8868ff550a2311 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Jun 2017 15:54:44 +0100 Subject: [PATCH 2/8] Revert "Call MatrixClient.clearStores on logout" This reverts commit c3d37c1ff9f3cb30834bb6e97c49845be9363b2f. This commit was introducing a bug where no rooms would be shown if you want straight to /#/login and logged in (because this causes a guest session to be created but the indexeddb store not to be cleared, so the new login picks up the stale indexedb sync data. --- src/Lifecycle.js | 38 ++++++------------------- src/components/structures/MatrixChat.js | 4 +-- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index a3bec14492..bf7b25fd2b 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -237,7 +237,7 @@ function _handleRestoreFailure(e) { + ' This is a once off; sorry for the inconvenience.', ); - _clearStorage(); + _clearLocalStorage(); return q.reject(new Error( _t('Unable to restore previous session') + ': ' + msg, @@ -258,7 +258,7 @@ function _handleRestoreFailure(e) { return def.promise.then((success) => { if (success) { // user clicked continue. - _clearStorage(); + _clearLocalStorage(); return false; } @@ -332,10 +332,6 @@ export function setLoggedIn(credentials) { } // stop any running clients before we create a new one with these new credentials - // - // XXX: why do we have any running clients here? Maybe on sign-in after - // initial use as a guest? but what about our persistent storage? we need to - // be careful not to leak e2e data created as one user into another session. stopMatrixClient(); MatrixClientPeg.replaceUsingCreds(credentials); @@ -406,19 +402,13 @@ export function startMatrixClient() { * a session has been logged out / ended. */ export function onLoggedOut() { - stopMatrixClient(true); + _clearLocalStorage(); + stopMatrixClient(); dis.dispatch({action: 'on_logged_out'}); } -function _clearStorage() { +function _clearLocalStorage() { Analytics.logout(); - - const cli = MatrixClientPeg.get(); - if (cli) { - // TODO: *really* ought to wait for the promise to complete - cli.clearStores().done(); - } - if (!window.localStorage) { return; } @@ -435,13 +425,9 @@ function _clearStorage() { } /** - * Stop all the background processes related to the current client. - * - * Optionally clears persistent stores. - * - * @param {boolean} clearStores true to clear the persistent stores. + * Stop all the background processes related to the current client */ -export function stopMatrixClient(clearStores) { +export function stopMatrixClient() { Notifier.stop(); UserActivity.stop(); Presence.stop(); @@ -450,13 +436,7 @@ export function stopMatrixClient(clearStores) { if (cli) { cli.stopClient(); cli.removeAllListeners(); + cli.store.deleteAllData(); + MatrixClientPeg.unset(); } - - if (clearStores) { - // note that we have to do this *after* stopping the client, but - // *before* clearing the MatrixClientPeg. - _clearStorage(); - } - - MatrixClientPeg.unset(); } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 0dedc02270..72a745107e 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -292,7 +292,7 @@ module.exports = React.createClass({ }, componentWillUnmount: function() { - Lifecycle.stopMatrixClient(false); + Lifecycle.stopMatrixClient(); dis.unregister(this.dispatcherRef); UDEHandler.stopListening(); window.removeEventListener("focus", this.onFocus); @@ -364,7 +364,7 @@ module.exports = React.createClass({ // is completed in another browser, we'll be 401ed for using // a guest access token for a non-guest account. // It will be restarted in onReturnToGuestClick - Lifecycle.stopMatrixClient(false); + Lifecycle.stopMatrixClient(); this.notifyNewScreen('register'); break; From 3c0290588ca1ec951775aef4aab5406fd6947ca8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Jun 2017 16:17:32 +0100 Subject: [PATCH 3/8] Always show the spinner during the first sync Before, we were relying on the fact that `ready` would still have been false from before. This was not the case, for example, if we naviagted straight to /#/login (which causes a guest session to be set up and the sync for that completes after we navigate to the login screen). We should always mark ourselves as not-ready after login since we will always have to wait for the sync. --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 72a745107e..e3792410b2 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -507,7 +507,7 @@ module.exports = React.createClass({ this._onSetTheme(payload.value); break; case 'on_logging_in': - this.setState({loggingIn: true}); + this.setState({loggingIn: true, ready: false}); break; case 'on_logged_in': this._onLoggedIn(payload.teamToken); From 3dbea45426fdace08e68982373fce5ef4c176e6d Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 5 Jun 2017 16:50:00 +0100 Subject: [PATCH 4/8] Comment --- src/components/structures/MatrixChat.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e3792410b2..c4d3df03d3 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -507,6 +507,10 @@ module.exports = React.createClass({ this._onSetTheme(payload.value); break; case 'on_logging_in': + // We are now logging in, so set the state to reflect that + // and also that we're not ready (we'll be marked as logged + // in once the login completes, then ready once the sync + // completes). this.setState({loggingIn: true, ready: false}); break; case 'on_logged_in': From cc8078837dca07f9067d19db81f84f7e7af5c1be Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Mon, 5 Jun 2017 16:57:30 +0100 Subject: [PATCH 5/8] Remove DM-guessing code (again) Seems this got reverted somehow: >the revert of https://github.com/matrix-org/matrix-react-sdk/pull/807 (https://github.com/matrix-org/matrix-react-sdk/commit/ebfafb363972e77ef02f0e518573bf68ebc0ed15) also included the revert of https://github.com/matrix-org/matrix-react-sdk/pull/829 --- src/components/views/rooms/RoomList.js | 37 -------------------------- 1 file changed, 37 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index f02f70b88b..3b43ea2b39 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -275,43 +275,6 @@ module.exports = React.createClass({ } }); - if (s.lists["im.vector.fake.direct"].length == 0 && - MatrixClientPeg.get().getAccountData('m.direct') === undefined && - !MatrixClientPeg.get().isGuest()) - { - // scan through the 'recents' list for any rooms which look like DM rooms - // and make them DM rooms - const oldRecents = s.lists["im.vector.fake.recent"]; - s.lists["im.vector.fake.recent"] = []; - - for (const room of oldRecents) { - const me = room.getMember(MatrixClientPeg.get().credentials.userId); - - if (me && Rooms.looksLikeDirectMessageRoom(room, me)) { - s.lists["im.vector.fake.direct"].push(room); - } else { - s.lists["im.vector.fake.recent"].push(room); - } - } - - // save these new guessed DM rooms into the account data - const newMDirectEvent = {}; - for (const room of s.lists["im.vector.fake.direct"]) { - const me = room.getMember(MatrixClientPeg.get().credentials.userId); - const otherPerson = Rooms.getOnlyOtherMember(room, me); - if (!otherPerson) continue; - - const roomList = newMDirectEvent[otherPerson.userId] || []; - roomList.push(room.roomId); - newMDirectEvent[otherPerson.userId] = roomList; - } - - // if this fails, fine, we'll just do the same thing next time we get the room lists - MatrixClientPeg.get().setAccountData('m.direct', newMDirectEvent).done(); - } - - //console.log("calculated new roomLists; im.vector.fake.recent = " + s.lists["im.vector.fake.recent"]); - // we actually apply the sorting to this when receiving the prop in RoomSubLists. return s; From d77a09adbafca12393c8cb25ec7c541a6fe70b04 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 5 Jun 2017 21:32:51 +0100 Subject: [PATCH 6/8] quick and dirty override to disable MD globally --- src/components/views/rooms/MessageComposerInputOld.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInputOld.js b/src/components/views/rooms/MessageComposerInputOld.js index f6af20c03b..80fb51e6b5 100644 --- a/src/components/views/rooms/MessageComposerInputOld.js +++ b/src/components/views/rooms/MessageComposerInputOld.js @@ -29,7 +29,6 @@ var Markdown = require("../../../Markdown"); var TYPING_USER_TIMEOUT = 10000; var TYPING_SERVER_TIMEOUT = 30000; -var MARKDOWN_ENABLED = true; export function onSendMessageFailed(err, room) { // XXX: temporary logging to try to diagnose @@ -77,7 +76,8 @@ export default React.createClass({ componentWillMount: function() { this.oldScrollHeight = 0; - this.markdownEnabled = MARKDOWN_ENABLED; + this.markdownEnabled = !UserSettingsStore.getSyncedSetting('disableMarkdown', false); + var self = this; this.sentHistory = { // The list of typed messages. Index 0 is more recent From ed7c138d91ee0f521e96fe1a4faf60dd8fd5cfde Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 5 Jun 2017 21:38:25 +0100 Subject: [PATCH 7/8] quick and dirty override to disable MD globally --- src/components/structures/UserSettings.js | 4 ++++ src/i18n/strings/en_EN.json | 1 + 2 files changed, 5 insertions(+) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 89debcb461..6cb262e79a 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -88,6 +88,10 @@ const SETTINGS_LABELS = [ id: 'hideRedactions', label: 'Hide removed messages', }, + { + id: 'disableMarkdown', + label: 'Disable markdown formatting', + }, /* { id: 'useFixedWidthFont', diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 2bef4b8901..6a7c510544 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -241,6 +241,7 @@ "Direct chats": "Direct chats", "disabled": "disabled", "Disable inline URL previews by default": "Disable inline URL previews by default", + "Disable markdown formatting": "Disable markdown formatting", "Disinvite": "Disinvite", "Display name": "Display name", "Displays action": "Displays action", From 0b56d33bd2a7738ca9a988ae13083c3cb8f618e4 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Tue, 6 Jun 2017 13:56:37 +0100 Subject: [PATCH 8/8] Null guard all interpolated strings passed to _t (#1035) --- src/languageHandler.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/languageHandler.js b/src/languageHandler.js index 798798b6e5..68e8ca6172 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -35,6 +35,25 @@ counterpart.setFallbackLocale('en'); // just import counterpart and use it directly, we end up using a different // instance. export function _t(...args) { + // Horrible hack to avoid https://github.com/vector-im/riot-web/issues/4191 + // The interpolation library that counterpart uses does not support undefined/null + // values and instead will throw an error. This is a problem since everywhere else + // in JS land passing undefined/null will simply stringify instead, and when converting + // valid ES6 template strings to i18n strings it's extremely easy to pass undefined/null + // if there are no existing null guards. To avoid this making the app completely inoperable, + // we'll check all the values for undefined/null and stringify them here. + if (args[1] && typeof args[1] === 'object') { + Object.keys(args[1]).forEach((k) => { + if (args[1][k] === undefined) { + console.warn("_t called with undefined interpolation name: " + k); + args[1][k] = 'undefined'; + } + if (args[1][k] === null) { + console.warn("_t called with null interpolation name: " + k); + args[1][k] = 'null'; + } + }); + } return counterpart.translate(...args); }