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

Commit 877a5d7

Browse files
authored
Add branding extensions (#51)
* Add branding extensions * prettier * Update docs and types.
1 parent ca0b3ea commit 877a5d7

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
interface AppTitleBase {
2+
/**
3+
* The configured brand name.
4+
* @example Element
5+
*/
6+
brand: string;
7+
/**
8+
* Is the client sync loop in an error state.
9+
*/
10+
syncError: boolean;
11+
/**
12+
* The current unread notification count.
13+
*/
14+
unreadNotificationCount?: number;
15+
/**
16+
* Has the client muted notifications.
17+
*/
18+
notificationsMuted?: boolean;
19+
}
20+
21+
export interface AppTitleInRoom extends AppTitleBase {
22+
/**
23+
* The room name, may be undefined if the room has no name.
24+
*/
25+
roomName?: string;
26+
/**
27+
* The room ID of the room in view.
28+
*/
29+
roomId: string;
30+
}
31+
32+
export type AppTitleContext = AppTitleBase | AppTitleInRoom;
33+
34+
export interface ProvideBrandingExtensions {
35+
/**
36+
* Called whenever the client would update the document title.
37+
* @param context Current application context used to generate the title.
38+
* @returns A string to be used for the full title, or null to use the default title.
39+
*/
40+
getAppTitle(context: AppTitleContext): string | null;
41+
}
42+
43+
export abstract class BrandingExtensionsBase implements ProvideBrandingExtensions {
44+
public getAppTitle(context: AppTitleContext): string | null {
45+
return null;
46+
}
47+
}

src/types/extensions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
*/
1515

16+
import { ProvideBrandingExtensions } from "../lifecycles/BrandingExtensions";
1617
import { ProvideCryptoSetupExtensions } from "../lifecycles/CryptoSetupExtensions";
1718
import { ProvideExperimentalExtensions } from "../lifecycles/ExperimentalExtensions";
1819

1920
export type AllExtensions = {
21+
branding?: ProvideBrandingExtensions;
2022
cryptoSetup?: ProvideCryptoSetupExtensions;
2123
experimental?: ProvideExperimentalExtensions;
2224
};

0 commit comments

Comments
 (0)