1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-10 09:22:25 +03:00

Fix widgets for all other sources too

This commit is contained in:
Travis Ralston
2020-04-09 15:25:11 -06:00
parent dc92f557fd
commit 4510499987
3 changed files with 18 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ limitations under the License.
export class WidgetType {
public static readonly JITSI = new WidgetType("m.jitsi", "jitsi");
public static readonly CUSTOM = new WidgetType("m.custom", "m.custom");
constructor(public readonly preferred: string, public readonly legacy: string) {
}
@@ -23,4 +24,14 @@ export class WidgetType {
public matches(type: string): boolean {
return type === this.preferred || type === this.legacy;
}
static fromString(type: string): WidgetType {
// First try and match it against something we're already aware of
const known = Object.values(WidgetType).filter(v => v instanceof WidgetType);
const knownMatch = known.find(w => w.matches(type));
if (knownMatch) return knownMatch;
// If that fails, invent a new widget type
return new WidgetType(type, type);
}
}