diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7bef4a88..f668ca3f97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,61 @@ +Changes in [0.13.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.13.2) (2018-08-23) +===================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.13.1...v0.13.2) + + * Don't crash if the value of a room tag is null + [\#2135](https://github.com/matrix-org/matrix-react-sdk/pull/2135) + +Changes in [0.13.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.13.1) (2018-08-20) +===================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.13.1-rc.1...v0.13.1) + + * No changes since rc.1 + +Changes in [0.13.1-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.13.1-rc.1) (2018-08-16) +=============================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.13.0...v0.13.1-rc.1) + + * Update from Weblate. + [\#2121](https://github.com/matrix-org/matrix-react-sdk/pull/2121) + * Shift to M_RESOURCE_LIMIT_EXCEEDED errors + [\#2120](https://github.com/matrix-org/matrix-react-sdk/pull/2120) + * Fix RoomSettings test + [\#2119](https://github.com/matrix-org/matrix-react-sdk/pull/2119) + * Show room version number in room settings + [\#2117](https://github.com/matrix-org/matrix-react-sdk/pull/2117) + * Warning bar for MAU limit hit + [\#2114](https://github.com/matrix-org/matrix-react-sdk/pull/2114) + * Recognise server notices room(s) + [\#2112](https://github.com/matrix-org/matrix-react-sdk/pull/2112) + * Update room tags behaviour to match spec more + [\#2111](https://github.com/matrix-org/matrix-react-sdk/pull/2111) + * while logging out ignore `Session.logged_out` as it is intentional + [\#2058](https://github.com/matrix-org/matrix-react-sdk/pull/2058) + * Don't show 'connection lost' bar on MAU error + [\#2110](https://github.com/matrix-org/matrix-react-sdk/pull/2110) + * Support MAU error on sync + [\#2108](https://github.com/matrix-org/matrix-react-sdk/pull/2108) + * Support active user limit on message send + [\#2106](https://github.com/matrix-org/matrix-react-sdk/pull/2106) + * Run end to end tests as part of Travis build + [\#2091](https://github.com/matrix-org/matrix-react-sdk/pull/2091) + * Remove package-lock.json for now + [\#2097](https://github.com/matrix-org/matrix-react-sdk/pull/2097) + * Support montly active user limit error on /login + [\#2103](https://github.com/matrix-org/matrix-react-sdk/pull/2103) + * Unpin sanitize-html + [\#2105](https://github.com/matrix-org/matrix-react-sdk/pull/2105) + * Pin sanitize-html to 0.18.2 + [\#2101](https://github.com/matrix-org/matrix-react-sdk/pull/2101) + * Make clicking on side panels close settings (mk 3) + [\#2096](https://github.com/matrix-org/matrix-react-sdk/pull/2096) + * Fix persistent element location not updating + [\#2092](https://github.com/matrix-org/matrix-react-sdk/pull/2092) + * fix Devtools input autofocus && state traversal when len === 1 && key="" + [\#2090](https://github.com/matrix-org/matrix-react-sdk/pull/2090) + * allow autocompleting Emoji by common aliases, e.g :+1: to :thumbsup: + [\#2085](https://github.com/matrix-org/matrix-react-sdk/pull/2085) + Changes in [0.13.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.13.0) (2018-07-30) ===================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.13.0-rc.2...v0.13.0) diff --git a/package.json b/package.json index 15e46019ea..1bdced5caf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "0.13.0", + "version": "0.13.2", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { @@ -73,7 +73,7 @@ "linkifyjs": "^2.1.6", "lodash": "^4.13.1", "lolex": "2.3.2", - "matrix-js-sdk": "0.10.7", + "matrix-js-sdk": "0.10.8", "optimist": "^0.6.1", "pako": "^1.0.5", "prop-types": "^15.5.8", diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 3325044b84..fa7b8c5b76 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -480,7 +480,7 @@ function getMembershipCount(event, roomId) { sendError(event, _t('This room is not recognised.')); return; } - const count = room.getJoinedMembers().length; + const count = room.getJoinedMemberCount(); sendResponse(event, count); } @@ -497,12 +497,11 @@ function canSendEvent(event, roomId) { sendError(event, _t('This room is not recognised.')); return; } - const me = client.credentials.userId; - const member = room.getMember(me); - if (!member || member.membership !== "join") { + if (room.getMyMembership() !== "join") { sendError(event, _t('You are not in this room.')); return; } + const me = client.credentials.userId; let canSend = false; if (isState) { diff --git a/src/VectorConferenceHandler.js b/src/VectorConferenceHandler.js index 9ba46b2ab6..c53a01d464 100644 --- a/src/VectorConferenceHandler.js +++ b/src/VectorConferenceHandler.js @@ -72,7 +72,7 @@ ConferenceCall.prototype._getConferenceUserRoom = function() { for (var i = 0; i < rooms.length; i++) { var confUser = rooms[i].getMember(this.confUserId); if (confUser && confUser.membership === "join" && - rooms[i].getJoinedMembers().length === 2) { + rooms[i].getJoinedMemberCount() === 2) { confRoom = rooms[i]; break; } diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 2bc6522232..0c4688a411 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -434,7 +434,10 @@ const LoggedInView = React.createClass({ } const usageLimitEvent = this.state.serverNoticeEvents.find((e) => { - return e && e.getType() === 'm.server_notice.usage_limit_reached'; + return ( + e && e.getType() === 'm.room.message' && + e.getContent()['server_notice_type'] === 'm.server_notice.usage_limit_reached' + ); }); let topBar; diff --git a/src/components/structures/RightPanel.js b/src/components/structures/RightPanel.js index 18523ceb59..bd4ed722cb 100644 --- a/src/components/structures/RightPanel.js +++ b/src/components/structures/RightPanel.js @@ -280,7 +280,7 @@ module.exports = React.createClass({ const room = cli.getRoom(this.props.roomId); let isUserInRoom; if (room) { - const numMembers = room.getJoinedMembers().length; + const numMembers = room.getJoinedMemberCount(); membersTitle = _t('%(count)s Members', { count: numMembers }); membersBadge =
{ formatCount(numMembers) }
; isUserInRoom = room.hasMembershipState(this.context.matrixClient.credentials.userId, 'join'); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 5243cd15fa..ca06243ed1 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -310,7 +310,7 @@ module.exports = React.createClass({ }); } else if (room) { //viewing a previously joined room, try to lazy load members - + // Stop peeking because we have joined this room previously MatrixClientPeg.get().stopPeeking(); this.setState({isPeeking: false}); @@ -363,7 +363,7 @@ module.exports = React.createClass({ // XXX: EVIL HACK to autofocus inviting on empty rooms. // We use the setTimeout to avoid racing with focus_composer. if (this.state.room && - this.state.room.getJoinedMembers().length == 1 && + this.state.room.getJoinedMemberCount() == 1 && this.state.room.getLiveTimeline() && this.state.room.getLiveTimeline().getEvents() && this.state.room.getLiveTimeline().getEvents().length <= 6) { @@ -701,7 +701,6 @@ module.exports = React.createClass({ } this._updateRoomMembers(); - this._checkIfAlone(this.state.room); }, onRoomMemberMembership: function(ev, member, oldMembership) { @@ -717,6 +716,7 @@ module.exports = React.createClass({ // refresh the conf call notification state this._updateConfCallNotification(); this._updateDMState(); + this._checkIfAlone(this.state.room); }, 500), _checkIfAlone: function(room) { @@ -729,8 +729,8 @@ module.exports = React.createClass({ return; } - const joinedMembers = room.currentState.getMembers().filter((m) => m.membership === "join" || m.membership === "invite"); - this.setState({isAlone: joinedMembers.length === 1}); + const joinedOrInvitedMemberCount = room.getJoinedMemberCount() + room.getInvitedMemberCount(); + this.setState({isAlone: joinedOrInvitedMemberCount === 1}); }, _updateConfCallNotification: function() { @@ -1508,9 +1508,8 @@ module.exports = React.createClass({ } } - const myUserId = MatrixClientPeg.get().credentials.userId; - const myMember = this.state.room.getMember(myUserId); - if (myMember && myMember.membership == 'invite') { + const myMembership = this.state.room.getMyMembership(); + if (myMembership == 'invite') { if (this.state.joining || this.state.rejecting) { return (
@@ -1518,6 +1517,8 @@ module.exports = React.createClass({
); } else { + const myUserId = MatrixClientPeg.get().credentials.userId; + const myMember = this.state.room.getMember(myUserId); const inviteEvent = myMember.events.member; var inviterName = inviteEvent.sender ? inviteEvent.sender.name : inviteEvent.getSender(); @@ -1609,7 +1610,7 @@ module.exports = React.createClass({ } else if (this.state.showingPinned) { hideCancel = true; // has own cancel aux = ; - } else if (!myMember || myMember.membership !== "join") { + } else if (myMembership !== "join") { // We do have a room object for this room, but we're not currently in it. // We may have a 3rd party invite to it. var inviterName = undefined; @@ -1651,7 +1652,7 @@ module.exports = React.createClass({ let messageComposer, searchInfo; const canSpeak = ( // joined and not showing search results - myMember && (myMember.membership == 'join') && !this.state.searchResults + myMembership == 'join' && !this.state.searchResults ); if (canSpeak) { messageComposer = @@ -1786,15 +1787,15 @@ module.exports = React.createClass({ oobData={this.props.oobData} editing={this.state.editingRoomSettings} saving={this.state.uploadingRoomSettings} - inRoom={myMember && myMember.membership === 'join'} + inRoom={myMembership === 'join'} collapsedRhs={this.props.collapsedRhs} onSearchClick={this.onSearchClick} onSettingsClick={this.onSettingsClick} onPinnedClick={this.onPinnedClick} onSaveClick={this.onSettingsSaveClick} onCancelClick={(aux && !hideCancel) ? this.onCancelClick : null} - onForgetClick={(myMember && myMember.membership === "leave") ? this.onForgetClick : null} - onLeaveClick={(myMember && myMember.membership === "join") ? this.onLeaveClick : null} + onForgetClick={(myMembership === "leave") ? this.onForgetClick : null} + onLeaveClick={(myMembership === "join") ? this.onLeaveClick : null} /> { auxPanel }
diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index f4dc92aca4..53e1ddea71 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -921,6 +921,25 @@ module.exports = React.createClass({
; }, + _renderTermsAndConditionsLinks: function() { + if (SdkConfig.get().terms_and_conditions_links) { + const tncLinks = []; + for (const tncEntry of SdkConfig.get().terms_and_conditions_links) { + tncLinks.push(
+ {tncEntry.text} +
); + } + return
+

{ _t("Legal") }

+
+ {tncLinks} +
+
; + } else { + return null; + } + }, + _renderClearCache: function() { return

{ _t("Clear Cache") }

@@ -1407,6 +1426,8 @@ module.exports = React.createClass({ { this._renderDeactivateAccount() } + { this._renderTermsAndConditionsLinks() } +
); diff --git a/src/components/views/avatars/RoomAvatar.js b/src/components/views/avatars/RoomAvatar.js index 821448207f..e0105159fb 100644 --- a/src/components/views/avatars/RoomAvatar.js +++ b/src/components/views/avatars/RoomAvatar.js @@ -19,6 +19,7 @@ import {ContentRepo} from "matrix-js-sdk"; import MatrixClientPeg from "../../../MatrixClientPeg"; import Modal from '../../../Modal'; import sdk from "../../../index"; +import DMRoomMap from '../../../utils/DMRoomMap'; module.exports = React.createClass({ displayName: 'RoomAvatar', @@ -107,58 +108,37 @@ module.exports = React.createClass({ }, getOneToOneAvatar: function(props) { - if (!props.room) return null; - - const mlist = props.room.currentState.members; - const userIds = []; - const leftUserIds = []; - // for .. in optimisation to return early if there are >2 keys - for (const uid in mlist) { - if (mlist.hasOwnProperty(uid)) { - if (["join", "invite"].includes(mlist[uid].membership)) { - userIds.push(uid); - } else { - leftUserIds.push(uid); - } - } - if (userIds.length > 2) { - return null; - } + const room = props.room; + if (!room) { + return null; } - - if (userIds.length == 2) { - let theOtherGuy = null; - if (mlist[userIds[0]].userId == MatrixClientPeg.get().credentials.userId) { - theOtherGuy = mlist[userIds[1]]; - } else { - theOtherGuy = mlist[userIds[0]]; - } - return theOtherGuy.getAvatarUrl( - MatrixClientPeg.get().getHomeserverUrl(), - Math.floor(props.width * window.devicePixelRatio), - Math.floor(props.height * window.devicePixelRatio), - props.resizeMethod, - false, - ); - } else if (userIds.length == 1) { - // The other 1-1 user left, leaving just the current user, so show the left user's avatar - if (leftUserIds.length === 1) { - return mlist[leftUserIds[0]].getAvatarUrl( - MatrixClientPeg.get().getHomeserverUrl(), - props.width, props.height, props.resizeMethod, - false, - ); - } - return mlist[userIds[0]].getAvatarUrl( - MatrixClientPeg.get().getHomeserverUrl(), - Math.floor(props.width * window.devicePixelRatio), - Math.floor(props.height * window.devicePixelRatio), - props.resizeMethod, - false, - ); + let otherMember = null; + const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId); + if (otherUserId) { + otherMember = room.getMember(otherUserId); } else { - return null; + // if the room is not marked as a 1:1, but only has max 2 members + // then still try to show any avatar (pref. other member) + const totalMemberCount = room.getJoinedMemberCount() + + room.getInvitedMemberCount(); + const members = room.currentState.getMembers(); + if (totalMemberCount == 2) { + const myUserId = MatrixClientPeg.get().getUserId(); + otherMember = members.find(m => m.userId !== myUserId); + } else if (totalMemberCount == 1) { + otherMember = members[0]; + } } + if (otherMember) { + return otherMember.getAvatarUrl( + MatrixClientPeg.get().getHomeserverUrl(), + Math.floor(props.width * window.devicePixelRatio), + Math.floor(props.height * window.devicePixelRatio), + props.resizeMethod, + false, + ); + } + return null; }, onRoomAvatarClick: function() { diff --git a/src/components/views/context_menus/RoomTileContextMenu.js b/src/components/views/context_menus/RoomTileContextMenu.js index 77f71fa8fa..ce9895447e 100644 --- a/src/components/views/context_menus/RoomTileContextMenu.js +++ b/src/components/views/context_menus/RoomTileContextMenu.js @@ -346,20 +346,18 @@ module.exports = React.createClass({ }, render: function() { - const myMember = this.props.room.getMember( - MatrixClientPeg.get().credentials.userId, - ); + const myMembership = this.props.room.getMyMembership(); // Can't set notif level or tags on non-join rooms - if (myMember.membership !== 'join') { - return this._renderLeaveMenu(myMember.membership); + if (myMembership !== 'join') { + return this._renderLeaveMenu(myMembership); } return (
{ this._renderNotifMenu() }
- { this._renderLeaveMenu(myMember.membership) } + { this._renderLeaveMenu(myMembership) }
{ this._renderRoomTagMenu() }
diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index a7e02d16ae..eccdfe17af 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -71,6 +71,23 @@ export default class MessageComposer extends React.Component { // XXX: fragile as all hell - fixme somehow, perhaps with a dedicated Room.encryption event or something. MatrixClientPeg.get().on("event", this.onEvent); this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate); + this._waitForOwnMember(); + } + + _waitForOwnMember() { + // if we have the member already, do that + const me = this.props.room.getMember(MatrixClientPeg.get().getUserId()); + if (me) { + this.setState({me}); + return; + } + // Otherwise, wait for member loading to finish and then update the member for the avatar. + // The members should already be loading, and loadMembersIfNeeded + // will return the promise for the existing operation + this.props.room.loadMembersIfNeeded().then(() => { + const me = this.props.room.getMember(MatrixClientPeg.get().getUserId()); + this.setState({me}); + }); } componentWillUnmount() { @@ -208,7 +225,6 @@ export default class MessageComposer extends React.Component { } render() { - const me = this.props.room.getMember(MatrixClientPeg.get().credentials.userId); const uploadInputStyle = {display: 'none'}; const MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); const TintableSvg = sdk.getComponent("elements.TintableSvg"); @@ -216,11 +232,13 @@ export default class MessageComposer extends React.Component { const controls = []; - controls.push( -
- -
, - ); + if (this.state.me) { + controls.push( +
+ +
, + ); + } let e2eImg, e2eTitle, e2eClass; const roomIsEncrypted = MatrixClientPeg.get().isRoomEncrypted(this.props.room.roomId); diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 732048f712..3e632ba8ce 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -97,7 +97,7 @@ module.exports = React.createClass({ }; // All rooms that should be kept in the room list when filtering. // By default, show all rooms. - this._visibleRooms = MatrixClientPeg.get().getRooms(); + this._visibleRooms = MatrixClientPeg.get().getVisibleRooms(); // Listen to updates to group data. RoomList cares about members and rooms in order // to filter the room list when group tags are selected. @@ -302,7 +302,7 @@ module.exports = React.createClass({ this._visibleRooms = Array.from(roomSet); } else { // Show all rooms - this._visibleRooms = MatrixClientPeg.get().getRooms(); + this._visibleRooms = MatrixClientPeg.get().getVisibleRooms(); } this._delayedRefreshRoomList(); }, diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index aeb55be075..46869c1773 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -799,15 +799,15 @@ module.exports = React.createClass({ } let leaveButton = null; - const myMember = this.props.room.getMember(myUserId); - if (myMember) { - if (myMember.membership === "join") { + const myMemberShip = this.props.room.getMyMembership(); + if (myMemberShip) { + if (myMemberShip === "join") { leaveButton = ( { _t('Leave room') } ); - } else if (myMember.membership === "leave") { + } else if (myMemberShip === "leave") { leaveButton = ( { _t('Forget room') } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 043b90518d..f3fb4320a9 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -203,6 +203,8 @@ "Your browser does not support the required cryptography extensions": "Your browser does not support the required cryptography extensions", "Not a valid Riot keyfile": "Not a valid Riot keyfile", "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", + "Sorry, your homeserver is too old to participate in this room.": "Sorry, your homeserver is too old to participate in this room.", + "Please contact your homeserver administrator.": "Please contact your homeserver administrator.", "Failed to join room": "Failed to join room", "Message Pinning": "Message Pinning", "Increase performance by only loading room members on first view": "Increase performance by only loading room members on first view", @@ -1129,6 +1131,7 @@ "Lazy loading members not supported": "Lazy loading members not supported", "Lazy loading is not supported by your current homeserver.": "Lazy loading is not supported by your current homeserver.", "Deactivate my account": "Deactivate my account", + "Legal": "Legal", "Clear Cache": "Clear Cache", "Clear Cache and Reload": "Clear Cache and Reload", "Updates": "Updates", diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index 0a0a39a450..6571e1590f 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -284,8 +284,8 @@ class RoomListStore extends Store { if (optimisticRequest && roomB === optimisticRequest.room) metaB = optimisticRequest.metaData; // Make sure the room tag has an order element, if not set it to be the bottom - const a = metaA.order; - const b = metaB.order; + const a = metaA ? metaA.order : undefined; + const b = metaB ? metaB.order : undefined; // Order undefined room tag orders to the bottom if (a === undefined && b !== undefined) { diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index fed0d7b4a1..f15925f480 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -223,7 +223,13 @@ class RoomViewStore extends Store { action: 'join_room_error', err: err, }); - const msg = err.message ? err.message : JSON.stringify(err); + let msg = err.message ? err.message : JSON.stringify(err); + if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { + msg =
+ {_t("Sorry, your homeserver is too old to participate in this room.")}
+ {_t("Please contact your homeserver administrator.")} +
; + } const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Failed to join room', '', ErrorDialog, { title: _t("Failed to join room"), diff --git a/test/components/views/rooms/RoomList-test.js b/test/components/views/rooms/RoomList-test.js index 1e9f80f161..fbb2dd4af9 100644 --- a/test/components/views/rooms/RoomList-test.js +++ b/test/components/views/rooms/RoomList-test.js @@ -94,6 +94,7 @@ describe('RoomList', () => { createRoom({tags: {'m.lowpriority': {}}, name: 'Some unimportant room'}), createRoom({tags: {'custom.tag': {}}, name: 'Some room customly tagged'}), ]; + client.getVisibleRooms = client.getRooms; const roomMap = {}; client.getRooms().forEach((r) => { diff --git a/test/test-utils.js b/test/test-utils.js index eab355d8a7..bc4d29210e 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -74,6 +74,7 @@ export function createTestClient() { getPushActionsForEvent: sinon.stub(), getRoom: sinon.stub().returns(mkStubRoom()), getRooms: sinon.stub().returns([]), + getVisibleRooms: sinon.stub().returns([]), getGroups: sinon.stub().returns([]), loginFlows: sinon.stub(), on: sinon.stub(), @@ -257,6 +258,7 @@ export function mkStubRoom(roomId = null) { hasMembershipState: () => null, getVersion: () => '1', shouldUpgradeToVersion: () => null, + getMyMembership: () => "join", currentState: { getStateEvents: sinon.stub(), mayClientSendStateEvent: sinon.stub().returns(true),