fix wordbubble sticking
This commit is contained in:
parent
8394920d4d
commit
d3aba5c519
2 changed files with 5 additions and 5 deletions
|
@ -51,7 +51,6 @@ export class MSAgentClient {
|
||||||
private charlimit: number = 0;
|
private charlimit: number = 0;
|
||||||
private admin: boolean;
|
private admin: boolean;
|
||||||
private loginCb: (e: KeyboardEvent) => void;
|
private loginCb: (e: KeyboardEvent) => void;
|
||||||
private currentMsgId: number = 0;
|
|
||||||
|
|
||||||
private username: string | null = null;
|
private username: string | null = null;
|
||||||
private agentContainer: HTMLElement;
|
private agentContainer: HTMLElement;
|
||||||
|
@ -345,12 +344,12 @@ export class MSAgentClient {
|
||||||
|
|
||||||
this.playingAudio.set(user!.username, audio);
|
this.playingAudio.set(user!.username, audio);
|
||||||
|
|
||||||
let msgId = ++this.currentMsgId;
|
let msgId = ++user!.msgId;
|
||||||
|
|
||||||
audio.addEventListener('ended', () => {
|
audio.addEventListener('ended', () => {
|
||||||
// give a bit of time before the wordballoon disappears
|
// give a bit of time before the wordballoon disappears
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.currentMsgId === msgId) {
|
if (user!.msgId === msgId) {
|
||||||
user!.agent.stopSpeaking();
|
user!.agent.stopSpeaking();
|
||||||
this.playingAudio.delete(user!.username);
|
this.playingAudio.delete(user!.username);
|
||||||
}
|
}
|
||||||
|
@ -367,12 +366,12 @@ export class MSAgentClient {
|
||||||
let user = this.users.find((u) => u.username === imgMsg.data.username);
|
let user = this.users.find((u) => u.username === imgMsg.data.username);
|
||||||
if (!user || user.muted) return;
|
if (!user || user.muted) return;
|
||||||
let img = new Image();
|
let img = new Image();
|
||||||
let msgId = ++this.currentMsgId;
|
let msgId = ++user!.msgId;
|
||||||
img.addEventListener('load', () => {
|
img.addEventListener('load', () => {
|
||||||
this.playingAudio.get(user.username)?.pause();
|
this.playingAudio.get(user.username)?.pause();
|
||||||
user.agent.speakImage(img);
|
user.agent.speakImage(img);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.currentMsgId === msgId) {
|
if (user!.msgId === msgId) {
|
||||||
user.agent.stopSpeaking();
|
user.agent.stopSpeaking();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
|
@ -5,6 +5,7 @@ export class User {
|
||||||
agent: Agent;
|
agent: Agent;
|
||||||
muted: boolean;
|
muted: boolean;
|
||||||
admin: boolean;
|
admin: boolean;
|
||||||
|
msgId: number = 0;
|
||||||
|
|
||||||
constructor(username: string, agent: Agent) {
|
constructor(username: string, agent: Agent) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
|
Loading…
Reference in a new issue