Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1ad4a81

Browse files
committed
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into t3chguy/devtools
2 parents b75ae63 + 6077693 commit 1ad4a81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6217
-1264
lines changed

.eslintignore.errorfiles

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ src/components/views/create_room/CreateRoomButton.js
3333
src/components/views/create_room/Presets.js
3434
src/components/views/create_room/RoomAlias.js
3535
src/components/views/dialogs/ChatCreateOrReuseDialog.js
36-
src/components/views/dialogs/ChatInviteDialog.js
3736
src/components/views/dialogs/DeactivateAccountDialog.js
3837
src/components/views/dialogs/InteractiveAuthDialog.js
3938
src/components/views/dialogs/SetMxIdDialog.js
@@ -114,7 +113,6 @@ src/components/views/settings/EnableNotificationsButton.js
114113
src/ContentMessages.js
115114
src/HtmlUtils.js
116115
src/ImageUtils.js
117-
src/Invite.js
118116
src/languageHandler.js
119117
src/linkify-matrix.js
120118
src/Login.js

CHANGELOG.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
1+
Changes in [0.10.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.10.2) (2017-08-24)
2+
=====================================================================================================
3+
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.10.1...v0.10.2)
4+
5+
* Force update on timelinepanel when event decrypted
6+
[\#1334](https://github.com/matrix-org/matrix-react-sdk/pull/1334)
7+
* Dispatch incoming_call synchronously
8+
[\#1337](https://github.com/matrix-org/matrix-react-sdk/pull/1337)
9+
* Fix React crying on machines without internet due to return undefined
10+
[\#1335](https://github.com/matrix-org/matrix-react-sdk/pull/1335)
11+
* Catch the promise rejection if scalar fails
12+
[\#1333](https://github.com/matrix-org/matrix-react-sdk/pull/1333)
13+
* Update from Weblate.
14+
[\#1329](https://github.com/matrix-org/matrix-react-sdk/pull/1329)
15+
16+
Changes in [0.10.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.10.1) (2017-08-23)
17+
=====================================================================================================
18+
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.10.1-rc.1...v0.10.1)
19+
20+
* [No changes]
21+
22+
Changes in [0.10.1-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.10.1-rc.1) (2017-08-22)
23+
===============================================================================================================
24+
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.10.0-rc.2...v0.10.1-rc.1)
25+
26+
* Matthew/multiple widgets
27+
[\#1327](https://github.com/matrix-org/matrix-react-sdk/pull/1327)
28+
* Fix proptypes on UserPickerDialog
29+
[\#1326](https://github.com/matrix-org/matrix-react-sdk/pull/1326)
30+
* AppsDrawer: Remove unnecessary bind
31+
[\#1325](https://github.com/matrix-org/matrix-react-sdk/pull/1325)
32+
* Position add app widget link
33+
[\#1322](https://github.com/matrix-org/matrix-react-sdk/pull/1322)
34+
* Remove app tile beta tag.
35+
[\#1323](https://github.com/matrix-org/matrix-react-sdk/pull/1323)
36+
* Add missing translation.
37+
[\#1324](https://github.com/matrix-org/matrix-react-sdk/pull/1324)
38+
* Note that apps are not E2EE
39+
[\#1319](https://github.com/matrix-org/matrix-react-sdk/pull/1319)
40+
* Only render appTile body (including warnings) if drawer shown.
41+
[\#1321](https://github.com/matrix-org/matrix-react-sdk/pull/1321)
42+
* Timeline improvements
43+
[\#1320](https://github.com/matrix-org/matrix-react-sdk/pull/1320)
44+
* Add a space between widget name and "widget" in widget event tiles
45+
[\#1318](https://github.com/matrix-org/matrix-react-sdk/pull/1318)
46+
* Move manage integrations button from settings page to room header as a
47+
stand-alone component
48+
[\#1286](https://github.com/matrix-org/matrix-react-sdk/pull/1286)
49+
* Don't apply case logic to app names
50+
[\#1316](https://github.com/matrix-org/matrix-react-sdk/pull/1316)
51+
* Stop integ manager opening on every room switch
52+
[\#1315](https://github.com/matrix-org/matrix-react-sdk/pull/1315)
53+
* Add behaviour to toggle app draw on app tile header click
54+
[\#1313](https://github.com/matrix-org/matrix-react-sdk/pull/1313)
55+
* Change OOO so that MELS generation will continue over hidden events
56+
[\#1308](https://github.com/matrix-org/matrix-react-sdk/pull/1308)
57+
* Implement TextualEvent tiles for im.vector.modular.widgets
58+
[\#1312](https://github.com/matrix-org/matrix-react-sdk/pull/1312)
59+
* Don't show widget security warning to the person that added it to the room
60+
[\#1314](https://github.com/matrix-org/matrix-react-sdk/pull/1314)
61+
* remove unused strings introduced by string change
62+
[\#1311](https://github.com/matrix-org/matrix-react-sdk/pull/1311)
63+
* hotfix bad fn signature regression
64+
[\#1310](https://github.com/matrix-org/matrix-react-sdk/pull/1310)
65+
* Show a dialog if the maximum number of widgets allowed has been reached.
66+
[\#1291](https://github.com/matrix-org/matrix-react-sdk/pull/1291)
67+
* Fix Robot translation
68+
[\#1309](https://github.com/matrix-org/matrix-react-sdk/pull/1309)
69+
* Refactor ChatInviteDialog to be UserPickerDialog
70+
[\#1300](https://github.com/matrix-org/matrix-react-sdk/pull/1300)
71+
* Update Link to Translation status
72+
[\#1302](https://github.com/matrix-org/matrix-react-sdk/pull/1302)
73+
174
Changes in [0.9.7](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.9.7) (2017-06-22)
275
===================================================================================================
376
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.9.6...v0.9.7)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ are currently filed against vector-im/riot-web rather than this project).
2626

2727
Translation Status
2828
==================
29-
[![translationsstatus](https://translate.nordgedanken.de/widgets/riot-web/-/multi-auto.svg)](https://translate.nordgedanken.de/engage/riot-web/?utm_source=widget)
29+
[![Translation status](https://translate.riot.im/widgets/riot-web/-/multi-auto.svg)](https://translate.riot.im/engage/riot-web/?utm_source=widget)
3030

3131
Developer Guide
3232
===============

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-react-sdk",
3-
"version": "0.9.7",
3+
"version": "0.10.2",
44
"description": "SDK for matrix.org using React",
55
"author": "matrix.org",
66
"repository": {
@@ -66,7 +66,7 @@
6666
"isomorphic-fetch": "^2.2.1",
6767
"linkifyjs": "^2.1.3",
6868
"lodash": "^4.13.1",
69-
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
69+
"matrix-js-sdk": "0.8.2",
7070
"optimist": "^0.6.1",
7171
"prop-types": "^15.5.8",
7272
"react": "^15.4.0",

src/ComposerHistoryManager.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,38 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import {ContentState} from 'draft-js';
18+
import {ContentState, convertToRaw, convertFromRaw} from 'draft-js';
1919
import * as RichText from './RichText';
2020
import Markdown from './Markdown';
21-
import _flow from 'lodash/flow';
2221
import _clamp from 'lodash/clamp';
2322

2423
type MessageFormat = 'html' | 'markdown';
2524

2625
class HistoryItem {
27-
message: string = '';
26+
27+
// Keeping message for backwards-compatibility
28+
message: string;
29+
rawContentState: RawDraftContentState;
2830
format: MessageFormat = 'html';
2931

30-
constructor(message: string, format: MessageFormat) {
31-
this.message = message;
32+
constructor(contentState: ?ContentState, format: ?MessageFormat) {
33+
this.rawContentState = contentState ? convertToRaw(contentState) : null;
3234
this.format = format;
3335
}
3436

35-
toContentState(format: MessageFormat): ContentState {
36-
let {message} = this;
37-
if (format === 'markdown') {
37+
toContentState(outputFormat: MessageFormat): ContentState {
38+
const contentState = convertFromRaw(this.rawContentState);
39+
if (outputFormat === 'markdown') {
3840
if (this.format === 'html') {
39-
message = _flow([RichText.htmlToContentState, RichText.stateToMarkdown])(message);
41+
return ContentState.createFromText(RichText.stateToMarkdown(contentState));
4042
}
41-
return ContentState.createFromText(message);
4243
} else {
4344
if (this.format === 'markdown') {
44-
message = new Markdown(message).toHTML();
45+
return RichText.htmlToContentState(new Markdown(contentState.getPlainText()).toHTML());
4546
}
46-
return RichText.htmlToContentState(message);
4747
}
48+
// history item has format === outputFormat
49+
return contentState;
4850
}
4951
}
5052

@@ -67,8 +69,8 @@ export default class ComposerHistoryManager {
6769
this.lastIndex = this.currentIndex;
6870
}
6971

70-
addItem(message: string, format: MessageFormat) {
71-
const item = new HistoryItem(message, format);
72+
save(contentState: ContentState, format: MessageFormat) {
73+
const item = new HistoryItem(contentState, format);
7274
this.history.push(item);
7375
this.currentIndex = this.lastIndex + 1;
7476
sessionStorage.setItem(`${this.prefix}[${this.lastIndex++}]`, JSON.stringify(item));

src/Invite.js

Lines changed: 113 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2016 OpenMarket Ltd
3+
Copyright 2017 New Vector Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -16,24 +17,11 @@ limitations under the License.
1617

1718
import MatrixClientPeg from './MatrixClientPeg';
1819
import MultiInviter from './utils/MultiInviter';
19-
20-
const emailRegex = /^\S+@\S+\.\S+$/;
21-
22-
const mxidRegex = /^@\S+:\S+$/
23-
24-
export function getAddressType(inputText) {
25-
const isEmailAddress = emailRegex.test(inputText);
26-
const isMatrixId = mxidRegex.test(inputText);
27-
28-
// sanity check the input for user IDs
29-
if (isEmailAddress) {
30-
return 'email';
31-
} else if (isMatrixId) {
32-
return 'mx';
33-
} else {
34-
return null;
35-
}
36-
}
20+
import Modal from './Modal';
21+
import { getAddressType } from './UserAddress';
22+
import createRoom from './createRoom';
23+
import sdk from './';
24+
import { _t } from './languageHandler';
3725

3826
export function inviteToRoom(roomId, addr) {
3927
const addrType = getAddressType(addr);
@@ -52,12 +40,116 @@ export function inviteToRoom(roomId, addr) {
5240
* Simpler interface to utils/MultiInviter but with
5341
* no option to cancel.
5442
*
55-
* @param {roomId} The ID of the room to invite to
56-
* @param {array} Array of strings of addresses to invite. May be matrix IDs or 3pids.
57-
* @returns Promise
43+
* @param {string} roomId The ID of the room to invite to
44+
* @param {string[]} addrs Array of strings of addresses to invite. May be matrix IDs or 3pids.
45+
* @returns {Promise} Promise
5846
*/
5947
export function inviteMultipleToRoom(roomId, addrs) {
6048
const inviter = new MultiInviter(roomId);
6149
return inviter.invite(addrs);
6250
}
6351

52+
export function showStartChatInviteDialog() {
53+
const UserPickerDialog = sdk.getComponent("dialogs.UserPickerDialog");
54+
Modal.createTrackedDialog('Start a chat', '', UserPickerDialog, {
55+
title: _t('Start a chat'),
56+
description: _t("Who would you like to communicate with?"),
57+
placeholder: _t("Email, name or matrix ID"),
58+
button: _t("Start Chat"),
59+
onFinished: _onStartChatFinished,
60+
});
61+
}
62+
63+
export function showRoomInviteDialog(roomId) {
64+
const UserPickerDialog = sdk.getComponent("dialogs.UserPickerDialog");
65+
Modal.createTrackedDialog('Chat Invite', '', UserPickerDialog, {
66+
title: _t('Invite new room members'),
67+
description: _t('Who would you like to add to this room?'),
68+
button: _t('Send Invites'),
69+
placeholder: _t("Email, name or matrix ID"),
70+
onFinished: (shouldInvite, addrs) => {
71+
_onRoomInviteFinished(roomId, shouldInvite, addrs);
72+
},
73+
});
74+
}
75+
76+
function _onStartChatFinished(shouldInvite, addrs) {
77+
if (!shouldInvite) return;
78+
79+
const addrTexts = addrs.map((addr) => addr.address);
80+
81+
if (_isDmChat(addrTexts)) {
82+
// Start a new DM chat
83+
createRoom({dmUserId: addrTexts[0]}).catch((err) => {
84+
console.error(err.stack);
85+
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
86+
Modal.createTrackedDialog('Failed to invite user', '', ErrorDialog, {
87+
title: _t("Failed to invite user"),
88+
description: ((err && err.message) ? err.message : _t("Operation failed")),
89+
});
90+
});
91+
} else {
92+
// Start multi user chat
93+
let room;
94+
createRoom().then((roomId) => {
95+
room = MatrixClientPeg.get().getRoom(roomId);
96+
return inviteMultipleToRoom(roomId, addrTexts);
97+
}).then((addrs) => {
98+
return _showAnyInviteErrors(addrs, room);
99+
}).catch((err) => {
100+
console.error(err.stack);
101+
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
102+
Modal.createTrackedDialog('Failed to invite', '', ErrorDialog, {
103+
title: _t("Failed to invite"),
104+
description: ((err && err.message) ? err.message : _t("Operation failed")),
105+
});
106+
});
107+
}
108+
}
109+
110+
function _onRoomInviteFinished(roomId, shouldInvite, addrs) {
111+
if (!shouldInvite) return;
112+
113+
const addrTexts = addrs.map((addr) => addr.address);
114+
115+
// Invite new users to a room
116+
inviteMultipleToRoom(roomId, addrTexts).then((addrs) => {
117+
const room = MatrixClientPeg.get().getRoom(roomId);
118+
return _showAnyInviteErrors(addrs, room);
119+
}).catch((err) => {
120+
console.error(err.stack);
121+
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
122+
Modal.createTrackedDialog('Failed to invite', '', ErrorDialog, {
123+
title: _t("Failed to invite"),
124+
description: ((err && err.message) ? err.message : _t("Operation failed")),
125+
});
126+
});
127+
}
128+
129+
function _isDmChat(addrTexts) {
130+
if (addrTexts.length === 1 && getAddressType(addrTexts[0])) {
131+
return true;
132+
} else {
133+
return false;
134+
}
135+
}
136+
137+
function _showAnyInviteErrors(addrs, room) {
138+
// Show user any errors
139+
const errorList = [];
140+
for (const addr of Object.keys(addrs)) {
141+
if (addrs[addr] === "error") {
142+
errorList.push(addr);
143+
}
144+
}
145+
146+
if (errorList.length > 0) {
147+
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
148+
Modal.createTrackedDialog('Failed to invite the following users to the room', '', ErrorDialog, {
149+
title: _t("Failed to invite the following users to the %(roomName)s room:", {roomName: room.name}),
150+
description: errorList.join(", "),
151+
});
152+
}
153+
return addrs;
154+
}
155+

src/Modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ class ModalManager {
112112
return this.createDialogAsync((cb) => {cb(Element);}, props, className);
113113
}
114114

115-
createTrackedDialogAsync(analyticsId, loader, props, className) {
116-
Analytics.trackEvent('Modal', analyticsId);
115+
createTrackedDialogAsync(analyticsAction, analyticsInfo, loader, props, className) {
116+
Analytics.trackEvent('Modal', analyticsAction, analyticsInfo);
117117
return this.createDialogAsync(loader, props, className);
118118
}
119119

0 commit comments

Comments
 (0)