mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
db2dcb459f
Adds #90
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { WidgetsResponse } from "./scalar_responses";
|
|
|
|
// Scalar's widget types (known)
|
|
export const WIDGET_SCALAR_CUSTOM = "customwidget";
|
|
export const WIDGET_SCALAR_ETHERPAD = "etherpad";
|
|
export const WIDGET_SCALAR_GOOGLEDOCS = "googledocs";
|
|
export const WIDGET_SCALAR_JITSI = "jitsi";
|
|
export const WIDGET_SCALAR_YOUTUBE = "youtube";
|
|
export const WIDGET_SCALAR_GRAFANA = "grafana";
|
|
// Placeholder until Scalar supports twitch
|
|
export const WIDGET_SCALAR_TWITCH = "";
|
|
|
|
// Dimension has its own set of types to ensure that we don't conflict with Scalar
|
|
export const WIDGET_DIM_CUSTOM = "dimension-customwidget";
|
|
export const WIDGET_DIM_YOUTUBE = "dimension-youtube";
|
|
export const WIDGET_DIM_TWITCH = "dimension-twitch";
|
|
export const WIDGET_DIM_ETHERPAD = "dimension-etherpad";
|
|
export const WIDGET_DIM_JITSI = "dimension-jitsi";
|
|
export const WIDGET_DIM_GOOGLEDOCS = "dimension-googledocs";
|
|
|
|
export interface Widget {
|
|
id: string;
|
|
type: string;
|
|
url: string;
|
|
name?: string;
|
|
data?: any;
|
|
ownerId?: string;
|
|
|
|
// used only in ui
|
|
newName?: string;
|
|
newUrl?: string;
|
|
}
|
|
|
|
export function ScalarToWidgets(scalarResponse: WidgetsResponse): Widget[] {
|
|
let widgets = [];
|
|
|
|
for (let event of scalarResponse.response) {
|
|
widgets.push({
|
|
id: event.state_key,
|
|
type: event.content.type,
|
|
url: event.content.url,
|
|
name: event.content.name,
|
|
data: event.content.data,
|
|
ownerId: event.sender,
|
|
});
|
|
}
|
|
|
|
return widgets;
|
|
}
|