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

Commit

Permalink
Add comments to highlight where we'll need m.widget support
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Apr 9, 2020
1 parent 4d461c6 commit b4b0c4c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ScalarMessaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Request:
Response:
[
{
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
type: "im.vector.modular.widgets",
state_key: "wid1",
content: {
Expand All @@ -190,6 +191,7 @@ Example:
room_id: "!foo:bar",
response: [
{
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
type: "im.vector.modular.widgets",
state_key: "wid1",
content: {
Expand Down
1 change: 1 addition & 0 deletions src/TextForEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ const stateHandlers = {
'm.room.guest_access': textForGuestAccessEvent,
'm.room.related_groups': textForRelatedGroupsEvent,

// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
'im.vector.modular.widgets': textForWidgetEvent,
};

Expand Down
1 change: 1 addition & 0 deletions src/components/views/rooms/EventTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const stateEventTileTypes = {
'm.room.power_levels': 'messages.TextualEvent',
'm.room.pinned_events': 'messages.TextualEvent',
'm.room.server_acl': 'messages.TextualEvent',
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
'im.vector.modular.widgets': 'messages.TextualEvent',
'm.room.tombstone': 'messages.TextualEvent',
'm.room.join_rules': 'messages.TextualEvent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const plEventsToLabels = {
"m.room.tombstone": _td("Upgrade the room"),
"m.room.encryption": _td("Enable room encryption"),

// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
"im.vector.modular.widgets": _td("Modify widgets"),
};

Expand All @@ -47,6 +48,7 @@ const plEventsToShow = {
"m.room.tombstone": {isState: true},
"m.room.encryption": {isState: true},

// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
"im.vector.modular.widgets": {isState: true},
};

Expand Down
1 change: 1 addition & 0 deletions src/stores/ActiveWidgetStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ActiveWidgetStore extends EventEmitter {
// Everything else relies on views listening for events and calling setters
// on this class which is terrible. This store should just listen for events
// and keep itself up to date.
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
if (ev.getType() !== 'im.vector.modular.widgets') return;

if (ev.getStateKey() === this._persistentWidgetId) {
Expand Down
7 changes: 5 additions & 2 deletions src/utils/WidgetUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class WidgetUtils {
return false;
}

// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
return room.currentState.maySendStateEvent('im.vector.modular.widgets', me);
}

Expand Down Expand Up @@ -180,6 +181,7 @@ export default class WidgetUtils {
}

const room = MatrixClientPeg.get().getRoom(roomId);
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
const startingWidgetEvents = room.currentState.getStateEvents('im.vector.modular.widgets');
if (eventsInIntendedState(startingWidgetEvents)) {
resolve();
Expand All @@ -189,6 +191,7 @@ export default class WidgetUtils {
function onRoomStateEvents(ev) {
if (ev.getRoomId() !== roomId) return;

// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
const currentWidgetEvents = room.currentState.getStateEvents('im.vector.modular.widgets');

if (eventsInIntendedState(currentWidgetEvents)) {
Expand Down Expand Up @@ -268,8 +271,7 @@ export default class WidgetUtils {
WidgetEchoStore.setRoomWidgetEcho(roomId, widgetId, content);

const client = MatrixClientPeg.get();
// TODO - Room widgets need to be moved to 'm.widget' state events
// https://docs.google.com/document/d/1uPF7XWY_dXTKVKV7jZQ2KmsI19wn9-kFRgQ1tFQP7wQ/edit?usp=sharing
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
return client.sendStateEvent(roomId, "im.vector.modular.widgets", content, widgetId).then(() => {
return WidgetUtils.waitForRoomWidget(widgetId, roomId, addingWidget);
}).finally(() => {
Expand All @@ -283,6 +285,7 @@ export default class WidgetUtils {
* @return {[object]} Array containing current / active room widgets
*/
static getRoomWidgets(room) {
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
const appsStateEvents = room.currentState.getStateEvents('im.vector.modular.widgets');
if (!appsStateEvents) {
return [];
Expand Down
1 change: 1 addition & 0 deletions test/components/views/rooms/RoomSettings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ describe.skip('RoomSettings', () => {
'm.room.history_visibility': 50,
'm.room.power_levels': 50,
'm.room.topic': 50,
// TODO: Enable support for m.widget event type (https://github.com/vector-im/riot-web/issues/13111)
'im.vector.modular.widgets': 50,
},
},
Expand Down

0 comments on commit b4b0c4c

Please sign in to comment.