2021-07-22 16:14:27 +02:00
|
|
|
import { AdminMessageEventTypes, adminMessagesService } from "../Connexion/AdminMessagesService";
|
2021-12-24 12:15:54 +01:00
|
|
|
import { textMessageStore } from "../Stores/TypeMessageStore/TextMessageStore";
|
2021-07-22 16:14:27 +02:00
|
|
|
import { soundPlayingStore } from "../Stores/SoundPlayingStore";
|
|
|
|
import { UPLOADER_URL } from "../Enum/EnvironmentVariable";
|
2021-12-24 12:15:54 +01:00
|
|
|
import { banMessageStore } from "../Stores/TypeMessageStore/BanMessageStore";
|
2020-10-19 19:32:47 +02:00
|
|
|
|
2021-03-01 17:47:00 +01:00
|
|
|
class UserMessageManager {
|
|
|
|
receiveBannedMessageListener!: Function;
|
2020-10-19 19:32:47 +02:00
|
|
|
|
2021-03-01 17:47:00 +01:00
|
|
|
constructor() {
|
|
|
|
adminMessagesService.messageStream.subscribe((event) => {
|
2021-07-22 16:14:27 +02:00
|
|
|
if (event.type === AdminMessageEventTypes.admin) {
|
2021-12-24 12:15:54 +01:00
|
|
|
textMessageStore.addMessage(event.text);
|
2021-07-22 16:14:27 +02:00
|
|
|
} else if (event.type === AdminMessageEventTypes.audio) {
|
|
|
|
soundPlayingStore.playSound(UPLOADER_URL + event.text);
|
|
|
|
} else if (event.type === AdminMessageEventTypes.ban) {
|
2021-12-24 12:15:54 +01:00
|
|
|
banMessageStore.addMessage(event.text);
|
2021-07-22 16:14:27 +02:00
|
|
|
} else if (event.type === AdminMessageEventTypes.banned) {
|
2021-12-24 12:15:54 +01:00
|
|
|
banMessageStore.addMessage(event.text);
|
2021-03-01 17:47:00 +01:00
|
|
|
this.receiveBannedMessageListener();
|
2021-01-25 14:10:16 +01:00
|
|
|
}
|
2021-07-22 16:14:27 +02:00
|
|
|
});
|
2021-01-25 14:10:16 +01:00
|
|
|
}
|
|
|
|
|
2021-07-22 16:14:27 +02:00
|
|
|
setReceiveBanListener(callback: Function) {
|
2021-03-01 17:47:00 +01:00
|
|
|
this.receiveBannedMessageListener = callback;
|
2020-10-19 19:32:47 +02:00
|
|
|
}
|
2021-03-01 17:47:00 +01:00
|
|
|
}
|
2021-07-22 16:14:27 +02:00
|
|
|
export const userMessageManager = new UserMessageManager();
|