Remove the last message before add a new chat peer

This commit is contained in:
Alexis Faizeau 2022-01-14 17:04:31 +01:00
parent ccfe049e6c
commit 30811e7702
2 changed files with 9 additions and 10 deletions

View file

@ -2,11 +2,13 @@ import { writable } from "svelte/store";
import { playersStore } from "./PlayersStore";
import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
import { iframeListener } from "../Api/IframeListener";
import { Subject } from "rxjs";
export const chatVisibilityStore = writable(false);
export const chatInputFocusStore = writable(false);
export const newChatMessageStore = writable<string | null>(null);
const _newChatMessageSubject = new Subject<string>();
export const newChatMessageSubject = _newChatMessageSubject.asObservable();
export enum ChatMessageTypes {
text = 1,
@ -67,10 +69,9 @@ function createChatMessagesStore() {
});
},
addPersonnalMessage(text: string) {
//post message iframe listener
iframeListener.sendUserInputChat(text);
newChatMessageStore.set(text);
_newChatMessageSubject.next(text);
update((list) => {
const lastMessage = list[list.length - 1];
if (lastMessage && lastMessage.type === ChatMessageTypes.me && lastMessage.text) {
@ -83,7 +84,6 @@ function createChatMessagesStore() {
});
}
iframeListener.sendUserInputChat(text);
return list;
});
},