@cometchat/skills 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/bin/install.js +27 -0
- package/package.json +14 -1
- package/skills/cometchat/SKILL.md +233 -69
- package/skills/cometchat/references/asking-questions.md +48 -0
- package/skills/cometchat-a11y/SKILL.md +3 -2
- package/skills/cometchat-android-v5/SKILL.md +2 -1
- package/skills/cometchat-android-v5-calls/SKILL.md +36 -22
- package/skills/cometchat-android-v5-calls/references/README.md +1 -1
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +7 -5
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +4 -4
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +33 -25
- package/skills/cometchat-android-v5-calls/references/call-session.md +2 -2
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +5 -5
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +2 -2
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +20 -14
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +1 -1
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +43 -27
- package/skills/cometchat-android-v5-calls/references/participant-management.md +3 -3
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +25 -19
- package/skills/cometchat-android-v5-calls/references/recording.md +2 -2
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +1 -1
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +5 -9
- package/skills/cometchat-android-v5-calls/references/session-settings.md +3 -3
- package/skills/cometchat-android-v5-calls/references/setup.md +1 -1
- package/skills/cometchat-android-v5-calls/references/share-invite.md +9 -4
- package/skills/cometchat-android-v5-calls/references/video-controls.md +4 -4
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +2 -2
- package/skills/cometchat-android-v5-components/SKILL.md +4 -3
- package/skills/cometchat-android-v5-core/SKILL.md +5 -3
- package/skills/cometchat-android-v5-customization/SKILL.md +171 -7
- package/skills/cometchat-android-v5-extensions/SKILL.md +7 -4
- package/skills/cometchat-android-v5-features/SKILL.md +5 -4
- package/skills/cometchat-android-v5-placement/SKILL.md +2 -1
- package/skills/cometchat-android-v5-production/SKILL.md +2 -1
- package/skills/cometchat-android-v5-push/SKILL.md +2 -3
- package/skills/cometchat-android-v5-testing/SKILL.md +2 -1
- package/skills/cometchat-android-v5-theming/SKILL.md +2 -1
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +3 -2
- package/skills/cometchat-android-v6/SKILL.md +2 -1
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +11 -7
- package/skills/cometchat-android-v6-calls/SKILL.md +79 -18
- package/skills/cometchat-android-v6-calls/references/advanced-features.md +87 -0
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +24 -15
- package/skills/cometchat-android-v6-calls/references/call-session.md +2 -2
- package/skills/cometchat-android-v6-calls/references/device-management.md +17 -16
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +7 -4
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +13 -8
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +6 -4
- package/skills/cometchat-android-v6-compose-components/SKILL.md +52 -29
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +156 -1
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +129 -40
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +27 -1
- package/skills/cometchat-android-v6-core/SKILL.md +208 -28
- package/skills/cometchat-android-v6-events/SKILL.md +4 -1
- package/skills/cometchat-android-v6-extensions/SKILL.md +2 -1
- package/skills/cometchat-android-v6-features/SKILL.md +26 -2
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +31 -1
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +172 -1
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +20 -5
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +36 -5
- package/skills/cometchat-android-v6-migration/SKILL.md +44 -42
- package/skills/cometchat-android-v6-production/SKILL.md +6 -3
- package/skills/cometchat-android-v6-push/SKILL.md +43 -2
- package/skills/cometchat-android-v6-testing/SKILL.md +11 -8
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +26 -5
- package/skills/cometchat-angular-calls/SKILL.md +256 -389
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +3 -2
- package/skills/cometchat-angular-calls/references/call-layouts.md +29 -12
- package/skills/cometchat-angular-calls/references/call-session.md +2 -2
- package/skills/cometchat-angular-calls/references/custom-ui.md +18 -10
- package/skills/cometchat-angular-calls/references/device-management.md +53 -34
- package/skills/cometchat-angular-calls/references/group-calls.md +45 -24
- package/skills/cometchat-angular-calls/references/idle-timeout.md +31 -15
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +7 -6
- package/skills/cometchat-angular-calls/references/raise-hand.md +9 -4
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +32 -39
- package/skills/cometchat-angular-calls/references/ringing-integration.md +3 -1
- package/skills/cometchat-angular-calls/references/share-invite.md +11 -5
- package/skills/cometchat-angular-calls/references/virtual-background.md +29 -0
- package/skills/cometchat-angular-components/SKILL.md +149 -620
- package/skills/cometchat-angular-core/SKILL.md +232 -312
- package/skills/cometchat-angular-customization/SKILL.md +415 -223
- package/skills/cometchat-angular-features/SKILL.md +216 -334
- package/skills/cometchat-angular-patterns/SKILL.md +168 -359
- package/skills/cometchat-angular-placement/SKILL.md +189 -560
- package/skills/cometchat-angular-production/SKILL.md +241 -92
- package/skills/cometchat-angular-push/SKILL.md +280 -294
- package/skills/cometchat-angular-testing/SKILL.md +430 -158
- package/skills/cometchat-angular-theming/SKILL.md +190 -265
- package/skills/cometchat-angular-troubleshooting/SKILL.md +192 -157
- package/skills/cometchat-astro-patterns/SKILL.md +2 -1
- package/skills/cometchat-calls/SKILL.md +25 -19
- package/skills/cometchat-calls/references/use-case-broadcast.md +15 -10
- package/skills/cometchat-calls/references/use-case-marketplace.md +2 -3
- package/skills/cometchat-calls/references/use-case-support.md +3 -4
- package/skills/cometchat-calls/references/use-case-team.md +23 -12
- package/skills/cometchat-calls/references/use-case-telehealth.md +3 -4
- package/skills/cometchat-components/SKILL.md +163 -25
- package/skills/cometchat-core/SKILL.md +255 -19
- package/skills/cometchat-customization/SKILL.md +50 -25
- package/skills/cometchat-features/SKILL.md +313 -34
- package/skills/cometchat-flutter-v5/SKILL.md +10 -4
- package/skills/cometchat-flutter-v5-calls/SKILL.md +188 -158
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +48 -24
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +20 -15
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +100 -145
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +12 -8
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +30 -36
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +15 -13
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +12 -9
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +115 -65
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +41 -30
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +17 -14
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +8 -2
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +2 -1
- package/skills/cometchat-flutter-v5-core/SKILL.md +5 -4
- package/skills/cometchat-flutter-v5-customization/SKILL.md +136 -5
- package/skills/cometchat-flutter-v5-events/SKILL.md +2 -1
- package/skills/cometchat-flutter-v5-messages/SKILL.md +2 -1
- package/skills/cometchat-flutter-v5-production/SKILL.md +15 -6
- package/skills/cometchat-flutter-v5-push/SKILL.md +2 -1
- package/skills/cometchat-flutter-v5-testing/SKILL.md +17 -6
- package/skills/cometchat-flutter-v5-theming/SKILL.md +2 -1
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +7 -6
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +3 -2
- package/skills/cometchat-flutter-v6/SKILL.md +17 -16
- package/skills/cometchat-flutter-v6-calls/SKILL.md +72 -57
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +5 -3
- package/skills/cometchat-flutter-v6-calls/references/advanced-features.md +89 -0
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +15 -12
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +2 -2
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +9 -3
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +10 -10
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +15 -7
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +6 -3
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +23 -16
- package/skills/cometchat-flutter-v6-components/SKILL.md +32 -11
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +39 -11
- package/skills/cometchat-flutter-v6-core/SKILL.md +182 -21
- package/skills/cometchat-flutter-v6-customization/SKILL.md +97 -25
- package/skills/cometchat-flutter-v6-events/SKILL.md +3 -2
- package/skills/cometchat-flutter-v6-features/SKILL.md +15 -6
- package/skills/cometchat-flutter-v6-messages/SKILL.md +111 -60
- package/skills/cometchat-flutter-v6-migration/SKILL.md +18 -25
- package/skills/cometchat-flutter-v6-placement/SKILL.md +79 -50
- package/skills/cometchat-flutter-v6-production/SKILL.md +13 -12
- package/skills/cometchat-flutter-v6-push/SKILL.md +41 -19
- package/skills/cometchat-flutter-v6-testing/SKILL.md +4 -4
- package/skills/cometchat-flutter-v6-theming/SKILL.md +38 -5
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +182 -17
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +12 -4
- package/skills/cometchat-i18n/SKILL.md +139 -78
- package/skills/cometchat-ios/SKILL.md +4 -2
- package/skills/cometchat-ios-calls/SKILL.md +225 -95
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +11 -9
- package/skills/cometchat-ios-calls/references/audio-modes-and-controls.md +45 -0
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +6 -7
- package/skills/cometchat-ios-calls/references/call-layouts.md +31 -91
- package/skills/cometchat-ios-calls/references/call-session.md +51 -54
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +33 -29
- package/skills/cometchat-ios-calls/references/custom-ui.md +38 -38
- package/skills/cometchat-ios-calls/references/group-calls.md +33 -70
- package/skills/cometchat-ios-calls/references/idle-timeout.md +24 -25
- package/skills/cometchat-ios-calls/references/in-call-chat.md +19 -23
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +128 -70
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +20 -20
- package/skills/cometchat-ios-calls/references/raise-hand.md +14 -227
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +35 -122
- package/skills/cometchat-ios-calls/references/ringing-integration.md +17 -16
- package/skills/cometchat-ios-calls/references/share-invite.md +8 -12
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +4 -4
- package/skills/cometchat-ios-components/SKILL.md +200 -12
- package/skills/cometchat-ios-core/SKILL.md +173 -45
- package/skills/cometchat-ios-customization/SKILL.md +276 -110
- package/skills/cometchat-ios-features/SKILL.md +64 -36
- package/skills/cometchat-ios-placement/SKILL.md +15 -12
- package/skills/cometchat-ios-production/SKILL.md +12 -4
- package/skills/cometchat-ios-push/SKILL.md +53 -19
- package/skills/cometchat-ios-testing/SKILL.md +14 -9
- package/skills/cometchat-ios-theming/SKILL.md +39 -3
- package/skills/cometchat-ios-troubleshooting/SKILL.md +41 -21
- package/skills/cometchat-native-bare-patterns/SKILL.md +34 -17
- package/skills/cometchat-native-calls/SKILL.md +28 -16
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +2 -2
- package/skills/cometchat-native-calls/references/call-layouts.md +15 -14
- package/skills/cometchat-native-calls/references/call-session.md +2 -2
- package/skills/cometchat-native-calls/references/custom-ui.md +12 -8
- package/skills/cometchat-native-calls/references/device-management.md +53 -30
- package/skills/cometchat-native-calls/references/group-calls.md +35 -30
- package/skills/cometchat-native-calls/references/idle-timeout.md +6 -6
- package/skills/cometchat-native-calls/references/in-call-chat.md +10 -8
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +2 -2
- package/skills/cometchat-native-calls/references/raise-hand.md +15 -13
- package/skills/cometchat-native-calls/references/recording-screen-share.md +49 -170
- package/skills/cometchat-native-calls/references/share-invite.md +7 -5
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +4 -2
- package/skills/cometchat-native-components/SKILL.md +84 -52
- package/skills/cometchat-native-core/SKILL.md +101 -32
- package/skills/cometchat-native-customization/SKILL.md +150 -28
- package/skills/cometchat-native-expo-patterns/SKILL.md +57 -26
- package/skills/cometchat-native-features/SKILL.md +23 -16
- package/skills/cometchat-native-placement/SKILL.md +19 -10
- package/skills/cometchat-native-production/SKILL.md +9 -3
- package/skills/cometchat-native-push/SKILL.md +2 -1
- package/skills/cometchat-native-testing/SKILL.md +1 -2
- package/skills/cometchat-native-theming/SKILL.md +54 -29
- package/skills/cometchat-native-troubleshooting/SKILL.md +9 -3
- package/skills/cometchat-nextjs-patterns/SKILL.md +20 -6
- package/skills/cometchat-placement/SKILL.md +42 -3
- package/skills/cometchat-production/SKILL.md +12 -5
- package/skills/cometchat-react-calls/SKILL.md +220 -10
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +4 -3
- package/skills/cometchat-react-calls/references/call-layouts.md +5 -6
- package/skills/cometchat-react-calls/references/call-session.md +1 -1
- package/skills/cometchat-react-calls/references/custom-ui.md +61 -15
- package/skills/cometchat-react-calls/references/device-management.md +55 -51
- package/skills/cometchat-react-calls/references/group-calls.md +18 -23
- package/skills/cometchat-react-calls/references/idle-timeout.md +25 -12
- package/skills/cometchat-react-calls/references/in-call-chat.md +7 -7
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +9 -11
- package/skills/cometchat-react-calls/references/raise-hand.md +14 -14
- package/skills/cometchat-react-calls/references/recording-screen-share.md +39 -38
- package/skills/cometchat-react-calls/references/ringing-integration.md +2 -2
- package/skills/cometchat-react-calls/references/share-invite.md +4 -5
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +20 -2
- package/skills/cometchat-react-calls/references/virtual-background.md +32 -0
- package/skills/cometchat-react-patterns/SKILL.md +44 -4
- package/skills/cometchat-react-push/SKILL.md +258 -72
- package/skills/cometchat-react-router-patterns/SKILL.md +10 -4
- package/skills/cometchat-react-testing/SKILL.md +14 -5
- package/skills/cometchat-theming/SKILL.md +181 -18
- package/skills/cometchat-troubleshooting/SKILL.md +40 -20
|
@@ -1,447 +1,256 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cometchat-angular-patterns
|
|
3
|
-
description: "Angular-specific integration patterns for CometChat UI Kit
|
|
3
|
+
description: "Angular-specific integration patterns for CometChat UI Kit v5 (@cometchat/chat-uikit-angular@5) — standalone bootstrap with main.ts init-before-bootstrap, functional route guards (CanActivateFn), lazy standalone routes (loadComponent), NgZone correctness for SDK callbacks, OnPush change detection, and SSR/Angular-Universal considerations."
|
|
4
4
|
license: "MIT"
|
|
5
|
-
compatibility: "Angular
|
|
6
|
-
allowed-tools: "shell, file-read, file-search, file-list, ask-user"
|
|
5
|
+
compatibility: "Angular 17–21 (standalone APIs); @cometchat/chat-uikit-angular ^5.0"
|
|
7
6
|
metadata:
|
|
8
7
|
author: "CometChat"
|
|
9
|
-
version: "
|
|
10
|
-
tags: "cometchat angular patterns routing lazy
|
|
8
|
+
version: "4.0.0"
|
|
9
|
+
tags: "cometchat angular patterns routing lazy guards standalone bootstrap ssr ngzone v5"
|
|
11
10
|
---
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
> **Ground truth:** `@cometchat/chat-uikit-angular@5.x` (+ `@cometchat/calls-sdk-javascript@^5`) — installed package types + `ui-kit/angular`. **Official docs:** https://www.cometchat.com/docs/ui-kit/angular/overview · **Docs MCP:** `claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp` (or fetch the URL directly without MCP). Verify symbols against the installed package/source before relying on them.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
## Purpose
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
Angular-specific wiring for CometChat UI Kit **v5** — how to hook init into Angular's standalone bootstrap, lazy-load chat routes, guard them, keep SDK callbacks inside Angular's zone, and handle SSR. Assumes the base integration from `cometchat-angular-core` + components from `cometchat-angular-components`.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
**v5 is standalone-first (Angular 17–21).** Everything below uses `bootstrapApplication` + `app.config.ts` + functional APIs. There is **no NgModule, no `AppModule`, no `declarations`, no `CUSTOM_ELEMENTS_SCHEMA`** — those are v4 patterns and must not appear in a v5 app.
|
|
20
19
|
|
|
21
20
|
---
|
|
22
21
|
|
|
23
|
-
## 1.
|
|
22
|
+
## 1. Initialize in `main.ts` — before `bootstrapApplication`
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
The v5 canonical (matches the kit's own sample app and the docs): call `CometChatUIKit.init()` in `main.ts` and bootstrap the Angular app **inside the resolved init promise**. This guarantees the SDK is ready before any `<cometchat-*>` component can mount. `init()` is a static method, so it works fine outside Angular's DI context.
|
|
26
25
|
|
|
27
26
|
```typescript
|
|
28
|
-
//
|
|
29
|
-
import {
|
|
30
|
-
import { UIKitSettingsBuilder } from "@cometchat/uikit-
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
// src/main.ts
|
|
28
|
+
import { bootstrapApplication } from "@angular/platform-browser";
|
|
29
|
+
import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-angular";
|
|
30
|
+
import { AppComponent } from "./app/app.component";
|
|
31
|
+
import { appConfig } from "./app/app.config";
|
|
32
|
+
import { environment } from "./environments/environment";
|
|
33
|
+
|
|
34
|
+
const settings = new UIKitSettingsBuilder()
|
|
35
|
+
.setAppId(environment.cometchat.appId)
|
|
36
|
+
.setRegion(environment.cometchat.region)
|
|
37
|
+
.setAuthKey(environment.cometchat.authKey)
|
|
38
|
+
.subscribePresenceForAllUsers()
|
|
39
|
+
// .setCallingEnabled(true) // uncomment + install @cometchat/calls-sdk-javascript for voice/video
|
|
40
|
+
.build();
|
|
41
|
+
|
|
42
|
+
// `init(...)` is `Promise<InitResult> | undefined` (v5.0.2) — coalesce to a Promise so
|
|
43
|
+
// `.then`/`.catch` don't fail `tsc` strict (TS2532) on Angular 21.
|
|
44
|
+
(CometChatUIKit.init(settings) ?? Promise.resolve())
|
|
45
|
+
.then(() => {
|
|
46
|
+
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
|
|
47
|
+
})
|
|
48
|
+
.catch((error) => {
|
|
49
|
+
console.error("CometChat UIKit init failed:", error);
|
|
50
|
+
// Still bootstrap so the app renders (it can show a "chat unavailable" state).
|
|
51
|
+
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
|
|
52
|
+
});
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
|
-
// app.
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
export function initCometChat(service: CometChatInitService): () => Promise<void> {
|
|
61
|
-
return () => service.initialize();
|
|
62
|
-
}
|
|
56
|
+
// src/app/app.config.ts — providers only; init does NOT live here
|
|
57
|
+
import { ApplicationConfig } from "@angular/core";
|
|
58
|
+
import { provideRouter } from "@angular/router";
|
|
59
|
+
import { routes } from "./app.routes";
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
providers: [
|
|
66
|
-
|
|
67
|
-
provide: APP_INITIALIZER,
|
|
68
|
-
useFactory: initCometChat,
|
|
69
|
-
deps: [CometChatInitService],
|
|
70
|
-
multi: true,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
})
|
|
74
|
-
export class AppModule {}
|
|
61
|
+
export const appConfig: ApplicationConfig = {
|
|
62
|
+
providers: [provideRouter(routes)],
|
|
63
|
+
};
|
|
75
64
|
```
|
|
76
65
|
|
|
77
|
-
With `APP_INITIALIZER`, Angular waits for the init promise to resolve before bootstrapping the root component. No `*ngIf="isReady"` guard needed on the root template.
|
|
78
|
-
|
|
79
|
-
**⚠️ `APP_INITIALIZER` blocks the entire app bootstrap.** If CometChat init fails (network error, wrong credentials), the app never renders. Add error handling:
|
|
80
|
-
|
|
81
66
|
```typescript
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
}
|
|
67
|
+
// src/environments/environment.ts
|
|
68
|
+
export const environment = {
|
|
69
|
+
production: false,
|
|
70
|
+
cometchat: {
|
|
71
|
+
appId: "APP_ID", // Dashboard → Your App → Credentials
|
|
72
|
+
region: "REGION", // us | eu | in
|
|
73
|
+
authKey: "AUTH_KEY", // dev/testing only — use Auth Tokens in production
|
|
74
|
+
},
|
|
75
|
+
};
|
|
90
76
|
```
|
|
91
77
|
|
|
78
|
+
> Don't use `APP_INITIALIZER` for this. The kit's sample app and docs both init in `main.ts` and bootstrap inside `.then()` — that's the v5 canonical and avoids the DI-timing edge cases of an init factory provider. Always `.catch()` so a network/credential failure degrades gracefully instead of leaving a blank app.
|
|
79
|
+
|
|
92
80
|
---
|
|
93
81
|
|
|
94
|
-
## 2.
|
|
82
|
+
## 2. Login + functional route guard
|
|
95
83
|
|
|
96
|
-
|
|
84
|
+
Init readies the SDK; **login** establishes the session. Guard chat routes with a functional `CanActivateFn` (the v17+ idiom — no class guard, no `Injectable`). This mirrors the sample app's `authGuard`:
|
|
97
85
|
|
|
98
86
|
```typescript
|
|
99
|
-
//
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
87
|
+
// src/app/guards/auth.guard.ts
|
|
88
|
+
import { CanActivateFn, Router } from "@angular/router";
|
|
89
|
+
import { inject } from "@angular/core";
|
|
90
|
+
import { CometChat } from "@cometchat/chat-sdk-javascript";
|
|
91
|
+
|
|
92
|
+
export const authGuard: CanActivateFn = async () => {
|
|
93
|
+
const router = inject(Router);
|
|
94
|
+
try {
|
|
95
|
+
const user = await CometChat.getLoggedinUser(); // async; note lowercase 'in'
|
|
96
|
+
if (user) return true;
|
|
97
|
+
return router.createUrlTree(["/login"]);
|
|
98
|
+
} catch {
|
|
99
|
+
return router.createUrlTree(["/login"]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
export class CometChatAuthGuard implements CanActivate {
|
|
106
|
-
constructor(private router: Router) {}
|
|
104
|
+
For dev convenience you can auto-login a seeded user instead of redirecting:
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
```typescript
|
|
107
|
+
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
108
|
+
// …inside the guard, when no user is found:
|
|
109
|
+
try {
|
|
110
|
+
await CometChatUIKit.login("cometchat-uid-1"); // bare UID string in v5 — NOT login({ uid })
|
|
111
|
+
return true;
|
|
112
|
+
} catch {
|
|
113
|
+
return router.createUrlTree(["/login"]);
|
|
115
114
|
}
|
|
116
115
|
```
|
|
117
116
|
|
|
117
|
+
Two real session-check APIs exist; pick by context:
|
|
118
|
+
- `CometChat.getLoggedinUser()` / `CometChatUIKit.getLoggedinUser()` — **async** (returns `Promise<User | null>`, lowercase `in`). Use in guards/async flows. This is what the sample app guards use.
|
|
119
|
+
- `CometChatUIKit.getLoggedInUser()` — **sync** (returns `User | null`, capital `I`). Use inside components for a synchronous read after the session is known to exist.
|
|
120
|
+
|
|
118
121
|
```typescript
|
|
119
|
-
// app
|
|
120
|
-
import {
|
|
122
|
+
// src/app/app.routes.ts
|
|
123
|
+
import { Routes } from "@angular/router";
|
|
124
|
+
import { authGuard } from "./guards/auth.guard";
|
|
121
125
|
|
|
122
126
|
export const routes: Routes = [
|
|
123
127
|
{
|
|
124
128
|
path: "chat",
|
|
125
|
-
canActivate: [
|
|
126
|
-
|
|
129
|
+
canActivate: [authGuard],
|
|
130
|
+
// Lazy-load a standalone component — no NgModule, no loadChildren:
|
|
131
|
+
loadComponent: () => import("./chat/chat.component").then((m) => m.ChatComponent),
|
|
127
132
|
},
|
|
128
|
-
{ path: "
|
|
133
|
+
{ path: "", redirectTo: "chat", pathMatch: "full" },
|
|
129
134
|
];
|
|
130
135
|
```
|
|
131
136
|
|
|
132
137
|
---
|
|
133
138
|
|
|
134
|
-
## 3. Lazy
|
|
139
|
+
## 3. Lazy-loaded standalone chat route
|
|
135
140
|
|
|
136
|
-
|
|
141
|
+
The chat surface is a standalone component that imports only the CometChat components it renders.
|
|
137
142
|
|
|
138
143
|
```typescript
|
|
139
|
-
// chat/chat.
|
|
140
|
-
import {
|
|
141
|
-
import { RouterModule, Routes } from "@angular/router";
|
|
142
|
-
import { CommonModule } from "@angular/common";
|
|
144
|
+
// chat/chat.component.ts
|
|
145
|
+
import { Component } from "@angular/core";
|
|
143
146
|
import {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
CometChatConversationsComponent,
|
|
148
|
+
CometChatMessageHeaderComponent,
|
|
149
|
+
CometChatMessageListComponent,
|
|
150
|
+
CometChatMessageComposerComponent,
|
|
148
151
|
} from "@cometchat/chat-uikit-angular";
|
|
149
|
-
import {
|
|
150
|
-
import { MessagesComponent } from "./messages/messages.component";
|
|
151
|
-
|
|
152
|
-
const routes: Routes = [
|
|
153
|
-
{ path: "", component: ConversationsComponent },
|
|
154
|
-
{ path: "messages/user/:uid", component: MessagesComponent },
|
|
155
|
-
{ path: "messages/group/:guid", component: MessagesComponent },
|
|
156
|
-
];
|
|
152
|
+
import { CometChat } from "@cometchat/chat-sdk-javascript";
|
|
157
153
|
|
|
158
|
-
@
|
|
154
|
+
@Component({
|
|
155
|
+
selector: "app-chat",
|
|
156
|
+
standalone: true,
|
|
159
157
|
imports: [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
CometChatMessageList,
|
|
165
|
-
CometChatMessageComposer,
|
|
158
|
+
CometChatConversationsComponent,
|
|
159
|
+
CometChatMessageHeaderComponent,
|
|
160
|
+
CometChatMessageListComponent,
|
|
161
|
+
CometChatMessageComposerComponent,
|
|
166
162
|
],
|
|
167
|
-
|
|
168
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
163
|
+
templateUrl: "./chat.component.html",
|
|
169
164
|
})
|
|
170
|
-
export class
|
|
171
|
-
|
|
165
|
+
export class ChatComponent {
|
|
166
|
+
selectedUser?: CometChat.User;
|
|
172
167
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
loadChildren: () => import("./chat/chat.module").then((m) => m.ChatModule),
|
|
179
|
-
},
|
|
180
|
-
];
|
|
168
|
+
onConversation(conversation: CometChat.Conversation) {
|
|
169
|
+
const entity = conversation.getConversationWith();
|
|
170
|
+
if (entity instanceof CometChat.User) this.selectedUser = entity;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
181
173
|
```
|
|
182
174
|
|
|
183
|
-
|
|
175
|
+
`loadComponent` (not `loadChildren`) is the standalone way to lazy-load — there's no feature NgModule to point at.
|
|
184
176
|
|
|
185
177
|
---
|
|
186
178
|
|
|
187
|
-
##
|
|
179
|
+
## 4. NgZone — keep SDK callbacks inside Angular's zone
|
|
188
180
|
|
|
189
|
-
|
|
181
|
+
CometChat SDK callbacks (event listeners, Promise resolutions from non-Angular timers) can fire **outside** Angular's zone, so a view bound to the result won't update until the next tick. If a UI value set inside an SDK callback isn't refreshing, re-enter the zone:
|
|
190
182
|
|
|
191
183
|
```typescript
|
|
192
|
-
|
|
193
|
-
import {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
useFactory: (service: CometChatInitService) => () => service.initialize(),
|
|
208
|
-
deps: [CometChatInitService],
|
|
209
|
-
multi: true,
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
// app.routes.ts
|
|
217
|
-
import { Routes } from "@angular/router";
|
|
218
|
-
|
|
219
|
-
export const routes: Routes = [
|
|
220
|
-
{
|
|
221
|
-
path: "chat",
|
|
222
|
-
loadComponent: () =>
|
|
223
|
-
import("./chat/conversations.component").then((m) => m.ConversationsComponent),
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
path: "messages/user/:uid",
|
|
227
|
-
loadComponent: () =>
|
|
228
|
-
import("./chat/messages.component").then((m) => m.MessagesComponent),
|
|
229
|
-
},
|
|
230
|
-
];
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
## 5. Login flow integration
|
|
236
|
-
|
|
237
|
-
Wire CometChat login to your app's existing auth flow.
|
|
238
|
-
|
|
239
|
-
### Pattern A — Login on app startup (dev mode)
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
// app.component.ts
|
|
243
|
-
import { Component, OnInit } from "@angular/core";
|
|
244
|
-
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
245
|
-
|
|
246
|
-
@Component({ selector: "app-root", templateUrl: "./app.component.html" })
|
|
247
|
-
export class AppComponent implements OnInit {
|
|
248
|
-
isReady = false;
|
|
249
|
-
|
|
250
|
-
ngOnInit(): void {
|
|
251
|
-
// CometChat.init() already called via APP_INITIALIZER
|
|
252
|
-
CometChatUIKit.getLoggedinUser()
|
|
253
|
-
.then((user) => {
|
|
254
|
-
if (!user) {
|
|
255
|
-
return CometChatUIKit.login({ uid: "cometchat-uid-1" });
|
|
256
|
-
}
|
|
257
|
-
return user;
|
|
258
|
-
})
|
|
259
|
-
.then(() => (this.isReady = true))
|
|
260
|
-
.catch(console.error);
|
|
184
|
+
import { Component, NgZone } from "@angular/core";
|
|
185
|
+
import { CometChat } from "@cometchat/chat-sdk-javascript";
|
|
186
|
+
|
|
187
|
+
@Component({ /* … */ })
|
|
188
|
+
export class PresenceComponent {
|
|
189
|
+
status = "offline";
|
|
190
|
+
constructor(private zone: NgZone) {}
|
|
191
|
+
|
|
192
|
+
ngOnInit() {
|
|
193
|
+
CometChat.addUserListener("presence", new CometChat.UserListener({
|
|
194
|
+
onUserOnline: (user: CometChat.User) =>
|
|
195
|
+
this.zone.run(() => { this.status = "online"; }), // ← re-enter zone
|
|
196
|
+
onUserOffline: (user: CometChat.User) =>
|
|
197
|
+
this.zone.run(() => { this.status = "offline"; }),
|
|
198
|
+
}));
|
|
261
199
|
}
|
|
262
200
|
}
|
|
263
201
|
```
|
|
264
202
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
// auth.service.ts
|
|
269
|
-
import { Injectable } from "@angular/core";
|
|
270
|
-
import { HttpClient } from "@angular/common/http";
|
|
271
|
-
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
272
|
-
import { environment } from "../environments/environment";
|
|
273
|
-
|
|
274
|
-
@Injectable({ providedIn: "root" })
|
|
275
|
-
export class AuthService {
|
|
276
|
-
constructor(private http: HttpClient) {}
|
|
277
|
-
|
|
278
|
-
loginWithCometChat(appJwt: string): Promise<void> {
|
|
279
|
-
// 1. Fetch CometChat auth token from your backend
|
|
280
|
-
return this.http
|
|
281
|
-
.post<{ authToken: string }>(environment.cometchat.tokenEndpoint, {}, {
|
|
282
|
-
headers: { Authorization: `Bearer ${appJwt}` },
|
|
283
|
-
})
|
|
284
|
-
.toPromise()
|
|
285
|
-
.then((response) => {
|
|
286
|
-
// 2. Login with the auth token
|
|
287
|
-
return CometChatUIKit.login({ authToken: response!.authToken });
|
|
288
|
-
})
|
|
289
|
-
.then(() => {
|
|
290
|
-
// 3. CometChat session established
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
logout(): Promise<void> {
|
|
295
|
-
return CometChatUIKit.logout();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
```
|
|
203
|
+
The kit's own `<cometchat-*>` components handle this internally — you only need `zone.run()` for **your own** code that mutates view state inside an SDK callback. Prefer the kit's `@Output`s where they exist (they're already zone-correct). Alternatively, consume `CometChatUIKit.loggedInUser$` (an RxJS observable) with the `async` pipe — observables integrate with change detection cleanly.
|
|
299
204
|
|
|
300
205
|
---
|
|
301
206
|
|
|
302
|
-
##
|
|
303
|
-
|
|
304
|
-
CometChat works alongside Angular Material. Common integration points:
|
|
305
|
-
|
|
306
|
-
### Theming coexistence
|
|
307
|
-
|
|
308
|
-
CometChat uses its own `CometChatThemeService` — it does NOT read from Angular Material's theme. Set both independently:
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
// app.component.ts
|
|
312
|
-
import { Component } from "@angular/core";
|
|
313
|
-
import { CometChatThemeService } from "@cometchat/chat-uikit-angular";
|
|
314
|
-
|
|
315
|
-
@Component({ selector: "app-root", templateUrl: "./app.component.html" })
|
|
316
|
-
export class AppComponent {
|
|
317
|
-
constructor(private cometChatTheme: CometChatThemeService) {
|
|
318
|
-
// Set CometChat palette to match your Material theme's primary color
|
|
319
|
-
cometChatTheme.theme.palette.setPrimary({ light: "#6200EE", dark: "#BB86FC" });
|
|
320
|
-
cometChatTheme.theme.palette.setMode("light");
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
```
|
|
207
|
+
## 5. OnPush change detection
|
|
324
208
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
```html
|
|
328
|
-
<!-- app.component.html -->
|
|
329
|
-
<mat-sidenav-container style="height: 100vh;">
|
|
330
|
-
<mat-sidenav mode="side" opened style="width: 320px;">
|
|
331
|
-
<cometchat-conversations
|
|
332
|
-
[onItemClick]="handleConvClick"
|
|
333
|
-
style="height: 100%;"
|
|
334
|
-
></cometchat-conversations>
|
|
335
|
-
</mat-sidenav>
|
|
336
|
-
<mat-sidenav-content style="display: flex; flex-direction: column;">
|
|
337
|
-
<cometchat-message-header [user]="selectedUser" [hideBackButton]="true"></cometchat-message-header>
|
|
338
|
-
<cometchat-message-list [user]="selectedUser" style="flex: 1; overflow: hidden;"></cometchat-message-list>
|
|
339
|
-
<cometchat-message-composer [user]="selectedUser"></cometchat-message-composer>
|
|
340
|
-
</mat-sidenav-content>
|
|
341
|
-
</mat-sidenav-container>
|
|
342
|
-
```
|
|
209
|
+
CometChat components are heavy; if your host component uses `ChangeDetectionStrategy.OnPush`, pass **immutable** references — reassign `selectedUser`/`selectedGroup` (a new object) rather than mutating, so OnPush detects the change. Binding the same mutated object won't trigger a re-render. (This mirrors the React "new reference per update" rule.)
|
|
343
210
|
|
|
344
211
|
---
|
|
345
212
|
|
|
346
|
-
##
|
|
213
|
+
## 6. SSR / Angular Universal
|
|
214
|
+
|
|
215
|
+
CometChat is a **browser-only** SDK (WebSocket + IndexedDB + `window`). It must not run during server-side rendering. The recommended setup is `ng new --ssr false` (per the docs) — but if your app already uses `@angular/ssr`, keep CometChat off the server.
|
|
347
216
|
|
|
348
|
-
|
|
217
|
+
- **Don't** call `CometChatUIKit.init()` / render `<cometchat-*>` on the server. Because init lives in `main.ts` (§1), gate it on the platform — `main.ts` runs in both the browser and server entry under SSR:
|
|
349
218
|
|
|
350
219
|
```typescript
|
|
351
|
-
//
|
|
220
|
+
// src/main.ts (SSR-safe)
|
|
352
221
|
import { isPlatformBrowser } from "@angular/common";
|
|
353
|
-
import { PLATFORM_ID
|
|
354
|
-
|
|
355
|
-
@Injectable({ providedIn: "root" })
|
|
356
|
-
export class CometChatInitService {
|
|
357
|
-
constructor(@Inject(PLATFORM_ID) private platformId: object) {}
|
|
358
|
-
|
|
359
|
-
initialize(): Promise<void> {
|
|
360
|
-
// Skip CometChat init on the server
|
|
361
|
-
if (!isPlatformBrowser(this.platformId)) {
|
|
362
|
-
return Promise.resolve();
|
|
363
|
-
}
|
|
364
|
-
// ... normal init
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
```
|
|
222
|
+
import { PLATFORM_ID } from "@angular/core";
|
|
368
223
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
template: `
|
|
373
|
-
<ng-container *ngIf="isBrowser">
|
|
374
|
-
<cometchat-conversations></cometchat-conversations>
|
|
375
|
-
</ng-container>
|
|
376
|
-
`,
|
|
377
|
-
})
|
|
378
|
-
export class ChatComponent {
|
|
379
|
-
isBrowser: boolean;
|
|
380
|
-
constructor(@Inject(PLATFORM_ID) platformId: object) {
|
|
381
|
-
this.isBrowser = isPlatformBrowser(platformId);
|
|
382
|
-
}
|
|
224
|
+
// bootstrap once, unconditionally:
|
|
225
|
+
function boot() {
|
|
226
|
+
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
|
|
383
227
|
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
**⚠️ CometChat components must not render during SSR.** They use browser APIs that throw in Node.js. Always guard with `isPlatformBrowser()`.
|
|
387
|
-
|
|
388
|
-
---
|
|
389
|
-
|
|
390
|
-
## 8. Change detection optimization
|
|
391
228
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
397
|
-
template: `
|
|
398
|
-
<cometchat-conversations
|
|
399
|
-
[onItemClick]="handleConvClick"
|
|
400
|
-
></cometchat-conversations>
|
|
401
|
-
`,
|
|
402
|
-
})
|
|
403
|
-
export class ChatComponent {
|
|
404
|
-
constructor(private cdr: ChangeDetectorRef) {}
|
|
405
|
-
|
|
406
|
-
handleConvClick = (conversation: CometChat.Conversation): void => {
|
|
407
|
-
// Update component state
|
|
408
|
-
this.selectedConversation = conversation;
|
|
409
|
-
// Trigger change detection manually when using OnPush
|
|
410
|
-
this.cdr.markForCheck();
|
|
411
|
-
};
|
|
229
|
+
if (typeof window === "undefined") {
|
|
230
|
+
boot(); // server render — skip CometChat init entirely
|
|
231
|
+
} else {
|
|
232
|
+
CometChatUIKit.init(settings).then(boot).catch((e) => { console.error(e); boot(); });
|
|
412
233
|
}
|
|
413
234
|
```
|
|
414
235
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
## 9. Anti-patterns
|
|
420
|
-
|
|
421
|
-
1. **Do NOT call `CometChatUIKit.init()` inside a lazy-loaded module.** Init must complete before any `<cometchat-*>` component renders. Use `APP_INITIALIZER` at the root level.
|
|
422
|
-
|
|
423
|
-
2. **Do NOT use `ChangeDetectionStrategy.OnPush` without calling `markForCheck()` after CometChat callbacks.** CometChat callbacks run outside Angular's zone — without `markForCheck()`, the view won't update.
|
|
424
|
-
|
|
425
|
-
3. **Do NOT import CometChat components in `AppModule` if they're only used in a lazy-loaded feature module.** Import them in the feature module to keep the initial bundle small.
|
|
426
|
-
|
|
427
|
-
4. **Do NOT skip `isPlatformBrowser()` guard in SSR apps.** CometChat uses browser APIs that crash in Node.js.
|
|
428
|
-
|
|
429
|
-
5. **Do NOT use `window.location.reload()` after login.** This is a common pattern in CometChat examples but it's an anti-pattern in Angular — use Angular Router navigation instead.
|
|
430
|
-
|
|
431
|
-
6. **Do NOT forget `CUSTOM_ELEMENTS_SCHEMA` in every module/component that uses `<cometchat-*>` tags.** Each standalone component and each NgModule needs it independently.
|
|
236
|
+
(Inside Angular providers/components, use `isPlatformBrowser(inject(PLATFORM_ID))` for the same guard.)
|
|
237
|
+
- Lazy-load the chat route (`loadComponent`) so the kit's bundle never enters the server build's initial chunk.
|
|
238
|
+
- With `@angular/ssr`, render the chat route client-side only (it's behind the auth guard + browser check above).
|
|
432
239
|
|
|
433
240
|
---
|
|
434
241
|
|
|
435
|
-
##
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
242
|
+
## 7. Anti-patterns
|
|
243
|
+
|
|
244
|
+
1. **Don't use NgModule wiring** (`@NgModule`, `AppModule`, `declarations`, `forRoot`, `CUSTOM_ELEMENTS_SCHEMA`) — those are v4. v5 is standalone: `app.config.ts` providers + `imports: []` on standalone components.
|
|
245
|
+
2. **Don't put `CometChatUIKit.init()` in `APP_INITIALIZER`** — the v5 canonical inits in `main.ts` and bootstraps inside the resolved promise. `app.config.ts` carries providers only.
|
|
246
|
+
3. **Don't use a class `CanActivate` guard** when a functional `CanActivateFn` is cleaner (v17+). Match the standalone idiom — no `Injectable` guard class.
|
|
247
|
+
4. **Don't init on the server** — gate `main.ts` init on the platform (`typeof window`/`isPlatformBrowser`).
|
|
248
|
+
5. **Don't forget `zone.run()`** around view-state mutations inside raw SDK listener callbacks — or use `loggedInUser$` + `async` pipe.
|
|
249
|
+
6. **Don't `loadChildren` a chat NgModule** — there isn't one; `loadComponent` a standalone component.
|
|
250
|
+
7. **Don't call `login({ uid })`** — v5 takes a bare UID string (see `cometchat-angular-core`).
|
|
251
|
+
|
|
252
|
+
## Pointers
|
|
253
|
+
- `cometchat-angular-core` — init/login, standalone setup, env
|
|
254
|
+
- `cometchat-angular-components` — the component catalog
|
|
255
|
+
- `cometchat-angular-placement` — where to mount chat (route/modal/drawer)
|
|
256
|
+
- `cometchat-angular-production` — server-minted auth tokens
|