@meetelise/chat 1.12.9 → 1.12.10
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/package.json +1 -1
- package/public/dist/index.js +21 -21
- package/src/MEChat.ts +11 -0
- package/src/WebComponent/me-chat.ts +28 -2
package/src/MEChat.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ThemeIdString } from "./themes";
|
|
2
2
|
import "./WebComponent/me-chat";
|
|
3
|
+
import { MEChat as MEChatLitElement } from "./WebComponent/me-chat";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The interface to MeetElise chat.
|
|
@@ -14,6 +15,8 @@ import "./WebComponent/me-chat";
|
|
|
14
15
|
* });
|
|
15
16
|
*/
|
|
16
17
|
export default class MEChat {
|
|
18
|
+
static meChat: MEChatLitElement | null = null;
|
|
19
|
+
|
|
17
20
|
static start(opts: Options): void {
|
|
18
21
|
installFont();
|
|
19
22
|
const meChat = document.createElement("me-chat");
|
|
@@ -29,6 +32,14 @@ export default class MEChat {
|
|
|
29
32
|
meChat.useMiniWidget = opts.mini;
|
|
30
33
|
}
|
|
31
34
|
document.body.appendChild(meChat);
|
|
35
|
+
MEChat.meChat = meChat;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static async restartConversation(): Promise<void> {
|
|
39
|
+
if (!this.meChat) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
await this.meChat.restartConversation();
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
|
|
@@ -3,10 +3,10 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
4
|
import { createRef, ref, Ref } from "lit/directives/ref.js";
|
|
5
5
|
import Talk from "talkjs";
|
|
6
|
-
import { Launcher } from "
|
|
6
|
+
import { Launcher } from "./Launcher";
|
|
7
7
|
import "./Scheduler/tour-scheduler";
|
|
8
8
|
import Analytics from "../analytics";
|
|
9
|
-
import { getChatID } from "../chatID";
|
|
9
|
+
import { createChatID, getChatID } from "../chatID";
|
|
10
10
|
import createConversation from "../createConversation";
|
|
11
11
|
import fetchBuildingInfo, { Building } from "../fetchBuildingInfo";
|
|
12
12
|
import { getTheme, Theme, ThemeIdString } from "../themes";
|
|
@@ -145,6 +145,32 @@ export class MEChat extends LitElement {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
public async restartConversation(): Promise<void> {
|
|
149
|
+
if (
|
|
150
|
+
!this.analytics ||
|
|
151
|
+
!this.analytics.chatId ||
|
|
152
|
+
!this.building ||
|
|
153
|
+
!this.theme ||
|
|
154
|
+
!this.popup ||
|
|
155
|
+
!MEChat.session
|
|
156
|
+
) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.chatId = createChatID(this.orgSlug, this.buildingSlug);
|
|
160
|
+
const session = await MEChat.session;
|
|
161
|
+
this.analytics.chatId = this.chatId;
|
|
162
|
+
this.popup.select(
|
|
163
|
+
createConversation(
|
|
164
|
+
session,
|
|
165
|
+
this.building,
|
|
166
|
+
this.theme,
|
|
167
|
+
this.avatarSrc || this.building.avatarSrc,
|
|
168
|
+
this.chatId,
|
|
169
|
+
this.isMobile
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
148
174
|
private configureLauncherElement = () => {
|
|
149
175
|
if (!this.popup || !this.launcherRef.value) {
|
|
150
176
|
return;
|