From f85898cdcae640f79968081f3a907b8b1fea3813 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 7 Aug 2019 12:15:11 -0600 Subject: [PATCH] Remove ChatCreateOrReuseDialog Part of https://github.com/vector-im/riot-web/issues/10416 All usages of the dialog have been replaced with new DM logic. --- .../views/dialogs/ChatCreateOrReuseDialog.js | 203 ------------------ src/i18n/strings/en_EN.json | 7 - 2 files changed, 210 deletions(-) delete mode 100644 src/components/views/dialogs/ChatCreateOrReuseDialog.js diff --git a/src/components/views/dialogs/ChatCreateOrReuseDialog.js b/src/components/views/dialogs/ChatCreateOrReuseDialog.js deleted file mode 100644 index b8e5b7d0a4..0000000000 --- a/src/components/views/dialogs/ChatCreateOrReuseDialog.js +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2017 Vector Creations 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. -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 PropTypes from 'prop-types'; -import sdk from '../../../index'; -import { _t } from '../../../languageHandler'; -import MatrixClientPeg from '../../../MatrixClientPeg'; -import DMRoomMap from '../../../utils/DMRoomMap'; -import AccessibleButton from '../elements/AccessibleButton'; -import Unread from '../../../Unread'; -import classNames from 'classnames'; - -export default class ChatCreateOrReuseDialog extends React.Component { - constructor(props) { - super(props); - this.onFinished = this.onFinished.bind(this); - this.onRoomTileClick = this.onRoomTileClick.bind(this); - - this.state = { - tiles: [], - profile: { - displayName: null, - avatarUrl: null, - }, - profileError: null, - }; - } - - componentWillMount() { - const client = MatrixClientPeg.get(); - - const dmRoomMap = new DMRoomMap(client); - const dmRooms = dmRoomMap.getDMRoomsForUserId(this.props.userId); - - const RoomTile = sdk.getComponent("rooms.RoomTile"); - - const tiles = []; - for (const roomId of dmRooms) { - const room = client.getRoom(roomId); - if (room && room.getMyMembership() === "join") { - const member = room.getMember(this.props.userId); - if (!member || member.membership !== "join") { - continue; - } - - const isInvite = room.getMyMembership() === "invite"; - const highlight = room.getUnreadNotificationCount('highlight') > 0 || isInvite; - tiles.push( - , - ); - } - } - - this.setState({ - tiles: tiles, - }); - - if (tiles.length === 0) { - this.setState({ - busyProfile: true, - }); - MatrixClientPeg.get().getProfileInfo(this.props.userId).done((resp) => { - const profile = { - displayName: resp.displayname, - avatarUrl: null, - }; - if (resp.avatar_url) { - profile.avatarUrl = MatrixClientPeg.get().mxcUrlToHttp( - resp.avatar_url, 48, 48, "crop", - ); - } - this.setState({ - busyProfile: false, - profile: profile, - }); - }, (err) => { - console.error( - 'Unable to get profile for user ' + this.props.userId + ':', - err, - ); - this.setState({ - busyProfile: false, - profileError: err, - }); - }); - } - } - - onRoomTileClick(roomId) { - this.props.onExistingRoomSelected(roomId); - } - - onFinished() { - this.props.onFinished(false); - } - - render() { - let title = ''; - let content = null; - if (this.state.tiles.length > 0) { - // Show the existing rooms with a "+" to add a new dm - title = _t('Create a new chat or reuse an existing one'); - const labelClasses = classNames({ - mx_MemberInfo_createRoom_label: true, - mx_RoomTile_name: true, - }); - const startNewChat = -
- -
-
{ _t("Start new chat") }
-
; - content =
- { _t('You already have existing direct chats with this user:') } -
- { this.state.tiles } - { startNewChat } -
-
; - } else { - // Show the avatar, name and a button to confirm that a new chat is requested - const BaseAvatar = sdk.getComponent('avatars.BaseAvatar'); - const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); - const Spinner = sdk.getComponent('elements.Spinner'); - title = _t('Start chatting'); - - let profile = null; - if (this.state.busyProfile) { - profile = ; - } else if (this.state.profileError) { - profile =
- Unable to load profile information for { this.props.userId } -
; - } else { - profile =
- -
- { this.state.profile.displayName || this.props.userId } -
-
; - } - content =
-
-

- { _t('Click on the button below to start chatting!') } -

- { profile } -
- -
; - } - - const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); - return ( - - { content } - - ); - } -} - -ChatCreateOrReuseDialog.propTypes = { - userId: PropTypes.string.isRequired, - // Called when clicking outside of the dialog - onFinished: PropTypes.func.isRequired, - onNewDMClick: PropTypes.func.isRequired, - onExistingRoomSelected: PropTypes.func.isRequired, -}; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 4155120608..2a7b14170f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -116,7 +116,6 @@ "Send Invites": "Send Invites", "Failed to start chat": "Failed to start chat", "Operation failed": "Operation failed", - "Failed to invite user": "Failed to invite user", "Failed to invite": "Failed to invite", "Failed to invite users to the room:": "Failed to invite users to the room:", "Failed to invite the following users to the %(roomName)s room:": "Failed to invite the following users to the %(roomName)s room:", @@ -1125,12 +1124,6 @@ "Unable to load commit detail: %(msg)s": "Unable to load commit detail: %(msg)s", "Unavailable": "Unavailable", "Changelog": "Changelog", - "Create a new chat or reuse an existing one": "Create a new chat or reuse an existing one", - "Start new chat": "Start new chat", - "You already have existing direct chats with this user:": "You already have existing direct chats with this user:", - "Start chatting": "Start chatting", - "Click on the button below to start chatting!": "Click on the button below to start chatting!", - "Start Chatting": "Start Chatting", "You cannot delete this message. (%(code)s)": "You cannot delete this message. (%(code)s)", "Removing…": "Removing…", "Confirm Removal": "Confirm Removal",