Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Nov 12, 2020
1 parent 06a06af commit b978b53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ClientWidgetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class ClientWidgetApi extends EventEmitter {
}).then(allowedCaps => {
console.log(`Widget ${this.widget.id} is allowed capabilities:`, Array.from(allowedCaps));
this.allowedCapabilities = allowedCaps;
this.allowedEvents = Array.from(new Set(WidgetEventCapability.findEventCapabilities(allowedCaps)));
this.allowedEvents = WidgetEventCapability.findEventCapabilities(allowedCaps);
this.capabilitiesFinished = true;
this.emit("ready");
});
Expand Down
10 changes: 7 additions & 3 deletions src/models/WidgetEventCapability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ export class WidgetEventCapability {

if (direction === null) continue;

// The capability uses `#` as a separator between event type and state key/msgtype,
// so we split on that. However, a # is also valid in either one of those so we
// join accordingly.
// Eg: `m.room.message##m.text` is "m.room.message" event with msgtype "#m.text".
let keyStr: string = null;
if (eventSegment.includes('#')) {
const p = eventSegment.split('#');
eventSegment = p[0];
keyStr = p.slice(1).join('#');
const parts = eventSegment.split('#');
eventSegment = parts[0];
keyStr = parts.slice(1).join('#');
}

parsed.push(new WidgetEventCapability(direction, eventSegment, isState, keyStr, cap));
Expand Down

0 comments on commit b978b53

Please sign in to comment.