Introduce a Module API to get application settings. (#34278)
* Add a module API to get application settings. * fix test
This commit is contained in:
@@ -61,6 +61,8 @@ export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiEx
|
||||
readonly i18n: I18nApi;
|
||||
readonly navigation: NavigationApi;
|
||||
readonly rootNode: HTMLElement;
|
||||
// @alpha
|
||||
readonly settings: SettingsApi;
|
||||
readonly stores: StoresApi;
|
||||
// @alpha
|
||||
readonly widget: WidgetApi;
|
||||
@@ -478,6 +480,11 @@ export interface RoomViewProps {
|
||||
// @alpha @deprecated (undocumented)
|
||||
export type RuntimeModuleConstructor = new (api: ModuleApi) => RuntimeModule;
|
||||
|
||||
// @alpha
|
||||
export interface SettingsApi {
|
||||
getValue<T = any>(settingName: string, roomId?: string | null, excludeDefault?: boolean): T | undefined;
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export interface SpacePanelItemProps {
|
||||
className?: string;
|
||||
|
||||
@@ -24,6 +24,7 @@ import { type WidgetLifecycleApi } from "./widget-lifecycle.ts";
|
||||
import { type WidgetApi } from "./widget.ts";
|
||||
import { type CustomisationsApi } from "./customisations.ts";
|
||||
import { type ComposerApi } from "./composer.ts";
|
||||
import { type SettingsApi } from "./settings.ts";
|
||||
|
||||
/**
|
||||
* Module interface for modules to implement.
|
||||
@@ -166,6 +167,12 @@ export interface Api
|
||||
*/
|
||||
readonly composer: ComposerApi;
|
||||
|
||||
/**
|
||||
* Allows modules to read application settings.
|
||||
* @alpha Subject to change.
|
||||
*/
|
||||
readonly settings: SettingsApi;
|
||||
|
||||
/**
|
||||
* Create a ReactDOM root for rendering React components.
|
||||
* Exposed to allow modules to avoid needing to bundle their own ReactDOM.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* API for reading application settings.
|
||||
* @alpha Subject to change.
|
||||
*/
|
||||
export interface SettingsApi {
|
||||
/**
|
||||
* Gets the value of a setting, computed across all applicable levels
|
||||
* (device, room, account, config, default, etc.).
|
||||
* @param settingName - The name of the setting to read.
|
||||
* @param roomId - Room ID to read a room-scoped value for, or null/undefined for a
|
||||
* non-room-scoped value.
|
||||
* @param excludeDefault - If true, do not fall back to the setting's default value.
|
||||
*/
|
||||
getValue<T = any>(settingName: string, roomId?: string | null, excludeDefault?: boolean): T | undefined;
|
||||
}
|
||||
@@ -35,5 +35,6 @@ export type * from "./api/widget-lifecycle";
|
||||
export type * from "./api/widget";
|
||||
export type * from "./api/customisations";
|
||||
export { UIComponent } from "./api/customisations";
|
||||
export type * from "./api/settings";
|
||||
export * from "./api/watchable";
|
||||
export type * from "./utils";
|
||||
|
||||
Reference in New Issue
Block a user