Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2018-05-15 15:30:47 +00:00
commit e410b7a5ab
4 changed files with 54 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Changes in [0.12.4-rc.5](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.12.4-rc.5) (2018-05-15)
===============================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.12.4-rc.4...v0.12.4-rc.5)
* Wait for echo from server when adding user widgets
[\#1905](https://github.com/matrix-org/matrix-react-sdk/pull/1905)
Changes in [0.12.4-rc.4](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.12.4-rc.4) (2018-05-14)
===============================================================================================================
[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.12.4-rc.3...v0.12.4-rc.4)

View file

@ -1,6 +1,6 @@
{
"name": "matrix-react-sdk",
"version": "0.12.4-rc.4",
"version": "0.12.4-rc.5",
"description": "SDK for matrix.org using React",
"author": "matrix.org",
"repository": {

View file

@ -286,6 +286,41 @@ function inviteUser(event, roomId, userId) {
});
}
/**
* Returns a promise that resolves when a widget with the given
* ID has been added as a user widget (ie. the accountData event
* arrives) or rejects after a timeout
*
* @param {string} widgetId The ID of the widget to wait for
* @returns {Promise} that resolves when the widget is available
*/
function waitForUserWidget(widgetId) {
return new Promise((resolve, reject) => {
const currentAccountDataEvent = MatrixClientPeg.get().getAccountData('m.widgets');
if (
currentAccountDataEvent &&
currentAccountDataEvent.getContent() &&
currentAccountDataEvent.getContent()[widgetId] !== undefined
) {
resolve();
return;
}
function onAccountData(ev) {
if (ev.getType() === 'm.widgets' && ev.getContent() && ev.getContent()[widgetId] !== undefined) {
MatrixClientPeg.get().removeListener('accountData', onAccountData);
clearTimeout(timerId);
resolve();
}
}
const timerId = setTimeout(() => {
MatrixClientPeg.get().removeListener('accountData', onAccountData);
reject(new Error("Timed out waiting for widget ID " + widgetId + " to appear"));
}, 10000);
MatrixClientPeg.get().on('accountData', onAccountData);
});
}
function setWidget(event, roomId) {
const widgetId = event.data.widget_id;
const widgetType = event.data.type;
@ -355,12 +390,20 @@ function setWidget(event, roomId) {
};
}
// This starts listening for when the echo comes back from the server
// since the widget won't appear added until this happens. If we don't
// wait for this, the action will complete but if the user is fast enough,
// the widget still won't actually be there.
client.setAccountData('m.widgets', userWidgets).then(() => {
return waitForUserWidget(widgetId);
}).then(() => {
sendResponse(event, {
success: true,
});
dis.dispatch({ action: "user_widget_updated" });
}).catch((e) => {
sendError(event, _t('Unable to create widget.'), e);
});
} else { // Room widget
if (!roomId) {
@ -373,6 +416,8 @@ function setWidget(event, roomId) {
// TODO - Room widgets need to be moved to 'm.widget' state events
// https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing
client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).done(() => {
// XXX: We should probably wait for the echo of the state event to come back from the server,
// as we do with user widgets.
sendResponse(event, {
success: true,
});

View file

@ -190,7 +190,6 @@
"Message Replies": "Message Replies",
"Message Pinning": "Message Pinning",
"Tag Panel": "Tag Panel",
"Sticker Messages": "Sticker Messages",
"Disable Emoji suggestions while typing": "Disable Emoji suggestions while typing",
"Use compact timeline layout": "Use compact timeline layout",
"Hide removed messages": "Hide removed messages",
@ -566,8 +565,6 @@
"Download %(text)s": "Download %(text)s",
"Invalid file%(extra)s": "Invalid file%(extra)s",
"Error decrypting image": "Error decrypting image",
"This image cannot be displayed.": "This image cannot be displayed.",
"Image '%(Body)s' cannot be displayed.": "Image '%(Body)s' cannot be displayed.",
"Error decrypting video": "Error decrypting video",
"%(senderDisplayName)s changed the avatar for %(roomName)s": "%(senderDisplayName)s changed the avatar for %(roomName)s",
"%(senderDisplayName)s removed the room avatar.": "%(senderDisplayName)s removed the room avatar.",
@ -815,8 +812,8 @@
"Encryption key request": "Encryption key request",
"Sign out": "Sign out",
"Log out and remove encryption keys?": "Log out and remove encryption keys?",
"Send Logs": "Send Logs",
"Clear Storage and Sign Out": "Clear Storage and Sign Out",
"Send Logs": "Send Logs",
"Refresh": "Refresh",
"Unable to restore session": "Unable to restore session",
"We encountered an error trying to restore your previous session.": "We encountered an error trying to restore your previous session.",