mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 07:20:29 +03:00
clean up to provide elementUrl option (instead of while testing just planting a string with the url)
This commit is contained in:
parent
38ad5e3f7e
commit
0106fab00b
1 changed files with 9 additions and 14 deletions
|
|
@ -28,10 +28,9 @@ import { SmallWidgetDriver } from './SmallWidgetDriver';
|
||||||
* @param roomId - The ID of the room.
|
* @param roomId - The ID of the room.
|
||||||
* @returns The generated URL object.
|
* @returns The generated URL object.
|
||||||
*/
|
*/
|
||||||
export const getWidgetUrl = (mx: MatrixClient, roomId: string): URL => {
|
export const getWidgetUrl = (mx: MatrixClient, roomId: string, elementCallUrl: string): URL => {
|
||||||
const baseUrl = window.location.origin;
|
const baseUrl = window.location.origin;
|
||||||
// Ensure the path is correct relative to the application's structure
|
const url = new URL(elementCallUrl) ?? new URL('./dist/element-call/dist/index.html', baseUrl);
|
||||||
let url = new URL('./dist/element-call/dist/index.html', baseUrl);
|
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
embed: 'true',
|
embed: 'true',
|
||||||
|
|
@ -50,17 +49,13 @@ export const getWidgetUrl = (mx: MatrixClient, roomId: string): URL => {
|
||||||
parentUrl: window.location.origin,
|
parentUrl: window.location.origin,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replace '$' encoded as %24 if necessary for template variables
|
|
||||||
const replacedParams = params.toString().replace(/%24/g, '$');
|
const replacedParams = params.toString().replace(/%24/g, '$');
|
||||||
url.hash = `#?${replacedParams}`; // Use #? for query parameters in the hash
|
url.hash = `#?${replacedParams}`;
|
||||||
|
|
||||||
logger.info('Generated Element Call Widget URL:', url.toString()); // Use info level for clarity
|
logger.info('Generated Element Call Widget URL:', url.toString());
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Widget Interfaces and Classes ---
|
|
||||||
|
|
||||||
// Interface describing the data structure for the widget
|
|
||||||
export interface IApp extends IWidget {
|
export interface IApp extends IWidget {
|
||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
roomId: string;
|
roomId: string;
|
||||||
|
|
@ -69,8 +64,7 @@ export interface IApp extends IWidget {
|
||||||
'io.element.managed_hybrid'?: boolean;
|
'io.element.managed_hybrid'?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom EventEmitter class to manage widget communication setup
|
export class SmallWidget extends EventEmitter {
|
||||||
export class Edget extends EventEmitter {
|
|
||||||
private client: MatrixClient;
|
private client: MatrixClient;
|
||||||
|
|
||||||
private messaging: ClientWidgetApi | null = null;
|
private messaging: ClientWidgetApi | null = null;
|
||||||
|
|
@ -263,7 +257,8 @@ export class Edget extends EventEmitter {
|
||||||
if (timelineEvent.getId() === upToEventId) {
|
if (timelineEvent.getId() === upToEventId) {
|
||||||
// The event must be somewhere before the "read up to" marker
|
// The event must be somewhere before the "read up to" marker
|
||||||
return false;
|
return false;
|
||||||
} else if (timelineEvent.getId() === ev.getId()) {
|
}
|
||||||
|
if (timelineEvent.getId() === ev.getId()) {
|
||||||
// The event is after the marker; advance it
|
// The event is after the marker; advance it
|
||||||
this.readUpToMap[roomId] = evId;
|
this.readUpToMap[roomId] = evId;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -320,7 +315,7 @@ export class Edget extends EventEmitter {
|
||||||
if (this.messaging) {
|
if (this.messaging) {
|
||||||
// Potentially call stop() or remove listeners if the API provides such methods
|
// Potentially call stop() or remove listeners if the API provides such methods
|
||||||
// this.messaging.stop(); // Example if a stop method exists
|
// this.messaging.stop(); // Example if a stop method exists
|
||||||
this.messaging.removeAllListeners(); // Remove listeners attached by Edget
|
this.messaging.removeAllListeners(); // Remove listeners attached by SmallWidget
|
||||||
logger.info(`Widget messaging stopped for widgetId: ${this.mockWidget.id}`);
|
logger.info(`Widget messaging stopped for widgetId: ${this.mockWidget.id}`);
|
||||||
this.messaging = null;
|
this.messaging = null;
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +339,7 @@ export const getWidgetData = (
|
||||||
overwriteData: object
|
overwriteData: object
|
||||||
): IWidgetData => {
|
): IWidgetData => {
|
||||||
// Example: Determine E2EE based on room state if needed
|
// Example: Determine E2EE based on room state if needed
|
||||||
let perParticipantE2EE = true; // Default or based on logic
|
const perParticipantE2EE = true; // Default or based on logic
|
||||||
// const roomEncryption = client.getRoom(roomId)?.currentState.getStateEvents(EventType.RoomEncryption, "");
|
// const roomEncryption = client.getRoom(roomId)?.currentState.getStateEvents(EventType.RoomEncryption, "");
|
||||||
// if (roomEncryption) perParticipantE2EE = true; // Simplified example
|
// if (roomEncryption) perParticipantE2EE = true; // Simplified example
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue