diff --git a/src/lifecycles/BrandingExtensions.ts b/src/lifecycles/BrandingExtensions.ts new file mode 100644 index 0000000..1ff7105 --- /dev/null +++ b/src/lifecycles/BrandingExtensions.ts @@ -0,0 +1,47 @@ +interface AppTitleBase { + /** + * The configured brand name. + * @example Element + */ + brand: string; + /** + * Is the client sync loop in an error state. + */ + syncError: boolean; + /** + * The current unread notification count. + */ + unreadNotificationCount?: number; + /** + * Has the client muted notifications. + */ + notificationsMuted?: boolean; +} + +export interface AppTitleInRoom extends AppTitleBase { + /** + * The room name, may be undefined if the room has no name. + */ + roomName?: string; + /** + * The room ID of the room in view. + */ + roomId: string; +} + +export type AppTitleContext = AppTitleBase | AppTitleInRoom; + +export interface ProvideBrandingExtensions { + /** + * Called whenever the client would update the document title. + * @param context Current application context used to generate the title. + * @returns A string to be used for the full title, or null to use the default title. + */ + getAppTitle(context: AppTitleContext): string | null; +} + +export abstract class BrandingExtensionsBase implements ProvideBrandingExtensions { + public getAppTitle(context: AppTitleContext): string | null { + return null; + } +} diff --git a/src/types/extensions.ts b/src/types/extensions.ts index 2fcbdcc..2e4d6d4 100644 --- a/src/types/extensions.ts +++ b/src/types/extensions.ts @@ -13,10 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { ProvideBrandingExtensions } from "../lifecycles/BrandingExtensions"; import { ProvideCryptoSetupExtensions } from "../lifecycles/CryptoSetupExtensions"; import { ProvideExperimentalExtensions } from "../lifecycles/ExperimentalExtensions"; export type AllExtensions = { + branding?: ProvideBrandingExtensions; cryptoSetup?: ProvideCryptoSetupExtensions; experimental?: ProvideExperimentalExtensions; };