From 28738f1a30cd66f8da187a898a513d8d86107071 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Thu, 30 Jan 2025 15:24:47 +0000 Subject: [PATCH] Add new extensions for FOSDEM additions. --- src/lifecycles/ClientLifecycle.ts | 25 ++++++++++++++ src/lifecycles/ConferenceExtensions.ts | 48 ++++++++++++++++++++++++++ src/lifecycles/types.ts | 4 ++- src/types/extensions.ts | 4 +++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/lifecycles/ClientLifecycle.ts create mode 100644 src/lifecycles/ConferenceExtensions.ts diff --git a/src/lifecycles/ClientLifecycle.ts b/src/lifecycles/ClientLifecycle.ts new file mode 100644 index 0000000..b732dcf --- /dev/null +++ b/src/lifecycles/ClientLifecycle.ts @@ -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", +} diff --git a/src/lifecycles/ConferenceExtensions.ts b/src/lifecycles/ConferenceExtensions.ts new file mode 100644 index 0000000..35d2722 --- /dev/null +++ b/src/lifecycles/ConferenceExtensions.ts @@ -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; + } +} diff --git a/src/lifecycles/types.ts b/src/lifecycles/types.ts index 8bcded1..75b0f99 100644 --- a/src/lifecycles/types.ts +++ b/src/lifecycles/types.ts @@ -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. @@ -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; diff --git a/src/types/extensions.ts b/src/types/extensions.ts index 2e4d6d4..97fa1ba 100644 --- a/src/types/extensions.ts +++ b/src/types/extensions.ts @@ -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 @@ -14,6 +16,7 @@ limitations under the License. */ import { ProvideBrandingExtensions } from "../lifecycles/BrandingExtensions"; +import { ProvideConferenceExtensions } from "../lifecycles/ConferenceExtensions"; import { ProvideCryptoSetupExtensions } from "../lifecycles/CryptoSetupExtensions"; import { ProvideExperimentalExtensions } from "../lifecycles/ExperimentalExtensions"; @@ -21,4 +24,5 @@ export type AllExtensions = { branding?: ProvideBrandingExtensions; cryptoSetup?: ProvideCryptoSetupExtensions; experimental?: ProvideExperimentalExtensions; + conference?: ProvideConferenceExtensions; };