Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Add new extensions for FOSDEM additions. #53

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/lifecycles/ClientLifecycle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2025 New Vector Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/**
* Client lifecycle events
*/
export enum ClientLifecycle {
/**
* An event to notify when the client has completed it's first sync.
*/
FirstSync = "first_sync",
}
48 changes: 48 additions & 0 deletions src/lifecycles/ConferenceExtensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright 2025 New Vector Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/**
* Extensions that are useful when rebranding the app to be used
* in a conference.
*/
export interface ProvideConferenceExtensions {
filterServerList(servers: string[]): string[];
serverLoginNotice(serverName: string): string | null;
defaultAvatarUrlForString(s: string): string | null;
getAvatarInitialLetter(s: string): string | null;
}

export abstract class ConferenceExtensionsBase implements ProvideConferenceExtensions {
public abstract filterServerList(servers: string[]): string[];
public abstract serverLoginNotice(serverName: string): string | null;
public abstract defaultAvatarUrlForString(s: string): string | null;
public abstract getAvatarInitialLetter(s: string): string | null;
}

export class DefaultConferenceExtensions extends ConferenceExtensionsBase {
public filterServerList(servers: string[]): string[] {
return servers;
}
public serverLoginNotice(): null {
return null;
}
public defaultAvatarUrlForString(): null {
return null;
}
public getAvatarInitialLetter(): null {
return null;
}
}
4 changes: 3 additions & 1 deletion src/lifecycles/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Copyright 2025 New Vector Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -17,5 +18,6 @@ limitations under the License.
import { RoomViewLifecycle } from "./RoomViewLifecycle";
import { WidgetLifecycle } from "./WidgetLifecycle";
import { WrapperLifecycle } from "./WrapperLifecycle";
import { ClientLifecycle } from "./ClientLifecycle";

export type AnyLifecycle = RoomViewLifecycle | WidgetLifecycle | WrapperLifecycle;
export type AnyLifecycle = RoomViewLifecycle | WidgetLifecycle | WrapperLifecycle | ClientLifecycle;
4 changes: 4 additions & 0 deletions src/types/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
Copyright 2023 Verji Tech AS
Copyright 2025 New Vector Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand All @@ -14,11 +16,13 @@ limitations under the License.
*/

import { ProvideBrandingExtensions } from "../lifecycles/BrandingExtensions";
import { ProvideConferenceExtensions } from "../lifecycles/ConferenceExtensions";
import { ProvideCryptoSetupExtensions } from "../lifecycles/CryptoSetupExtensions";
import { ProvideExperimentalExtensions } from "../lifecycles/ExperimentalExtensions";

export type AllExtensions = {
branding?: ProvideBrandingExtensions;
cryptoSetup?: ProvideCryptoSetupExtensions;
experimental?: ProvideExperimentalExtensions;
conference?: ProvideConferenceExtensions;
};