2021-07-07 11:24:51 +02:00
|
|
|
import { Subject } from "rxjs";
|
2021-02-02 18:19:51 +01:00
|
|
|
|
|
|
|
class BlackListManager {
|
2021-07-07 11:24:51 +02:00
|
|
|
private list: string[] = [];
|
|
|
|
public onBlockStream: Subject<string> = new Subject();
|
|
|
|
public onUnBlockStream: Subject<string> = new Subject();
|
|
|
|
|
|
|
|
isBlackListed(userUuid: string): boolean {
|
|
|
|
return this.list.find((data) => data === userUuid) !== undefined;
|
2021-02-02 18:19:51 +01:00
|
|
|
}
|
2021-07-07 11:24:51 +02:00
|
|
|
|
|
|
|
blackList(userUuid: string): void {
|
|
|
|
if (this.isBlackListed(userUuid)) return;
|
|
|
|
this.list.push(userUuid);
|
|
|
|
this.onBlockStream.next(userUuid);
|
2021-02-02 18:19:51 +01:00
|
|
|
}
|
|
|
|
|
2021-07-07 11:24:51 +02:00
|
|
|
cancelBlackList(userUuid: string): void {
|
|
|
|
this.list.splice(
|
|
|
|
this.list.findIndex((data) => data === userUuid),
|
|
|
|
1
|
|
|
|
);
|
|
|
|
this.onUnBlockStream.next(userUuid);
|
2021-02-02 18:19:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-07 11:24:51 +02:00
|
|
|
export const blackListManager = new BlackListManager();
|