mirror of https://github.com/vector-im/riot-web
Bits of PR feedback
parent
b6f3b2f594
commit
0a6450507e
|
@ -414,7 +414,7 @@ function _startCallApp(roomId, type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentJitsiWidgets = WidgetUtils.getRoomWidgets(room).filter((ev) => {
|
const currentJitsiWidgets = WidgetUtils.getRoomWidgets(room).filter((ev) => {
|
||||||
return ev.getContent().type == 'jitsi';
|
return ev.getContent().type === 'jitsi';
|
||||||
});
|
});
|
||||||
if (currentJitsiWidgets.length > 0) {
|
if (currentJitsiWidgets.length > 0) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -449,9 +449,7 @@ function _startCallApp(roomId, type) {
|
||||||
queryString
|
queryString
|
||||||
);
|
);
|
||||||
|
|
||||||
const widgetData = {
|
const widgetData = { widgetSessionId };
|
||||||
widgetSessionId: widgetSessionId,
|
|
||||||
};
|
|
||||||
|
|
||||||
const widgetId = (
|
const widgetId = (
|
||||||
'jitsi_' +
|
'jitsi_' +
|
||||||
|
|
|
@ -210,8 +210,10 @@ export default class WidgetUtils {
|
||||||
console.error(`$widgetId is non-configurable`);
|
console.error(`$widgetId is non-configurable`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const addingWidget = widgetUrl !== null;
|
||||||
|
|
||||||
// Add new widget / update
|
// Add new widget / update
|
||||||
if (widgetUrl !== null) {
|
if (addingWidget) {
|
||||||
userWidgets[widgetId] = {
|
userWidgets[widgetId] = {
|
||||||
content: content,
|
content: content,
|
||||||
sender: client.getUserId(),
|
sender: client.getUserId(),
|
||||||
|
@ -226,7 +228,7 @@ export default class WidgetUtils {
|
||||||
// wait for this, the action will complete but if the user is fast enough,
|
// wait for this, the action will complete but if the user is fast enough,
|
||||||
// the widget still won't actually be there.
|
// the widget still won't actually be there.
|
||||||
return client.setAccountData('m.widgets', userWidgets).then(() => {
|
return client.setAccountData('m.widgets', userWidgets).then(() => {
|
||||||
return WidgetUtils.waitForUserWidget(widgetId, widgetUrl !== null);
|
return WidgetUtils.waitForUserWidget(widgetId, addingWidget);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
dis.dispatch({ action: "user_widget_updated" });
|
dis.dispatch({ action: "user_widget_updated" });
|
||||||
});
|
});
|
||||||
|
@ -235,22 +237,24 @@ export default class WidgetUtils {
|
||||||
static setRoomWidget(widgetId, widgetType, widgetUrl, widgetName, widgetData, roomId) {
|
static setRoomWidget(widgetId, widgetType, widgetUrl, widgetName, widgetData, roomId) {
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
if (widgetUrl === null) { // widget is being deleted
|
const addingWidget = widgetUrl !== null;
|
||||||
content = {};
|
|
||||||
} else {
|
if (addingWidget) {
|
||||||
content = {
|
content = {
|
||||||
type: widgetType,
|
type: widgetType,
|
||||||
url: widgetUrl,
|
url: widgetUrl,
|
||||||
name: widgetName,
|
name: widgetName,
|
||||||
data: widgetData,
|
data: widgetData,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
content = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
// TODO - Room widgets need to be moved to 'm.widget' state events
|
// TODO - Room widgets need to be moved to 'm.widget' state events
|
||||||
// https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing
|
// https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing
|
||||||
return client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).then(() => {
|
return client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).then(() => {
|
||||||
return WidgetUtils.waitForRoomWidget(widgetId, roomId, widgetUrl !== null);
|
return WidgetUtils.waitForRoomWidget(widgetId, roomId, addingWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue