TGD-43 fix
This commit is contained in:
parent
ab63f62d4e
commit
a2788e340a
2 changed files with 19 additions and 10 deletions
|
|
@ -1,14 +1,24 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders, HttpParams } from "@angular/common/http";
|
import { HttpClient, HttpHeaders, HttpParams } from "@angular/common/http";
|
||||||
import { API_URL } from "../../app.constants";
|
import { API_URL } from "../../app.constants";
|
||||||
import {Observable, of, Subject} from "rxjs";
|
import {delay, delayWhen, interval, Observable, of, Subject} from "rxjs";
|
||||||
|
import {ApiService} from "./api.service";
|
||||||
|
import {takeUntil, tap} from "rxjs/operators";
|
||||||
|
import {SharedMethods} from "../shared/sharedmethods";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class VoiceService {
|
export class VoiceService {
|
||||||
|
destroyed$ = new Subject();
|
||||||
|
voiceDisabled = false;
|
||||||
|
|
||||||
constructor(private httpClient: HttpClient) { }
|
constructor(private httpClient: HttpClient, private apiService: ApiService) {
|
||||||
|
this.apiService.getFeatureFlagState("DisableVoice").pipe(takeUntil(this.destroyed$))
|
||||||
|
.subscribe((result) => {
|
||||||
|
this.voiceDisabled = result.state;
|
||||||
|
})
|
||||||
|
}
|
||||||
public voiceSubject = new Subject<string>();
|
public voiceSubject = new Subject<string>();
|
||||||
public audioEndedSubject = new Subject<void>();
|
public audioEndedSubject = new Subject<void>();
|
||||||
|
|
||||||
|
|
@ -20,6 +30,10 @@ export class VoiceService {
|
||||||
playAudio$(url: string) {
|
playAudio$(url: string) {
|
||||||
this.voiceSubject.next(url);
|
this.voiceSubject.next(url);
|
||||||
return new Observable((observer) => {
|
return new Observable((observer) => {
|
||||||
|
if(this.voiceDisabled) {
|
||||||
|
observer.next(null);
|
||||||
|
observer.complete();
|
||||||
|
}
|
||||||
const subscription = this.audioEndedSubject.subscribe({
|
const subscription = this.audioEndedSubject.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
observer.next(null);
|
observer.next(null);
|
||||||
|
|
@ -27,7 +41,7 @@ export class VoiceService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
})
|
}).pipe(delayWhen(val => this.voiceDisabled ? interval(5000) : interval(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getAudioUrl(text: string,voice: number = 1) {
|
getAudioUrl(text: string,voice: number = 1) {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,14 @@
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ApiService, EndgameResultsDto, FeatureFlagStateDto} from "../../services/api.service";
|
import {ApiService, EndgameResultsDto, FeatureFlagStateDto} from "../../services/api.service";
|
||||||
import {
|
import {
|
||||||
of,
|
|
||||||
Subject,
|
Subject,
|
||||||
lastValueFrom,
|
|
||||||
firstValueFrom,
|
firstValueFrom,
|
||||||
mergeWith,
|
|
||||||
combineLatestAll,
|
|
||||||
combineLatest,
|
combineLatest,
|
||||||
mergeMap,
|
merge
|
||||||
forkJoin, merge
|
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import { takeUntil} from "rxjs/operators";
|
import { takeUntil} from "rxjs/operators";
|
||||||
import {VoiceService} from "../../services/voice.service";
|
import {VoiceService} from "../../services/voice.service";
|
||||||
import {animate, keyframes, style, transition, trigger} from "@angular/animations";
|
import {animate, style, transition, trigger} from "@angular/animations";
|
||||||
import {Participant} from "../../../types/participant";
|
import {Participant} from "../../../types/participant";
|
||||||
import {SharedMethods} from "../../shared/sharedmethods";
|
import {SharedMethods} from "../../shared/sharedmethods";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue