You've already forked matrix-react-sdk
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user