From baf0d3798371146bfc2275335b6bc90e7b26602a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 19 Jun 2018 07:56:04 +0100 Subject: [PATCH 1/2] un-break having no displayname user settings Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/settings/ChangeDisplayName.js | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/views/settings/ChangeDisplayName.js b/src/components/views/settings/ChangeDisplayName.js index a74e223349..238fd9c2c3 100644 --- a/src/components/views/settings/ChangeDisplayName.js +++ b/src/components/views/settings/ChangeDisplayName.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,21 +24,14 @@ import { _t } from '../../../languageHandler'; module.exports = React.createClass({ displayName: 'ChangeDisplayName', - _getDisplayName: function() { + _getDisplayName: async function() { const cli = MatrixClientPeg.get(); - return cli.getProfileInfo(cli.credentials.userId).then(function(result) { - let displayname = result.displayname; - if (!displayname) { - if (MatrixClientPeg.get().isGuest()) { - displayname = "Guest " + MatrixClientPeg.get().getUserIdLocalpart(); - } else { - displayname = MatrixClientPeg.get().getUserIdLocalpart(); - } - } - return displayname; - }, function(error) { + try { + const res = await cli.getProfileInfo(cli.getUserId()); + return res.displayname; + } catch (e) { throw new Error("Failed to fetch display name"); - }); + } }, _changeDisplayName: function(new_displayname) { From 9fa7cb863567db08bda30bbff6351dd5a7cbc977 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 19 Jun 2018 07:57:28 +0100 Subject: [PATCH 2/2] delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/settings/ChangeDisplayName.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/views/settings/ChangeDisplayName.js b/src/components/views/settings/ChangeDisplayName.js index 238fd9c2c3..afe1521f0f 100644 --- a/src/components/views/settings/ChangeDisplayName.js +++ b/src/components/views/settings/ChangeDisplayName.js @@ -15,10 +15,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -'use strict'; -const React = require('react'); -const sdk = require('../../../index'); -const MatrixClientPeg = require("../../../MatrixClientPeg"); +import React from 'react'; +import sdk from '../../../index'; +import MatrixClientPeg from '../../../MatrixClientPeg'; import { _t } from '../../../languageHandler'; module.exports = React.createClass({ @@ -34,10 +33,10 @@ module.exports = React.createClass({ } }, - _changeDisplayName: function(new_displayname) { + _changeDisplayName: function(newDisplayname) { const cli = MatrixClientPeg.get(); - return cli.setDisplayName(new_displayname).catch(function(e) { - throw new Error("Failed to set display name"); + return cli.setDisplayName(newDisplayname).catch(function(e) { + throw new Error("Failed to set display name", e); }); },