bug fixed
This commit is contained in:
parent
64ea49ae09
commit
106ba524fb
|
@ -34,7 +34,8 @@
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
'group.errors.bannedWords'
|
'group.errors.bannedWords'
|
||||||
| translate: { bannedWords: bannedWords.join(',') }
|
| translate
|
||||||
|
: { bannedWords: appService.bannedGroupNames.join(',') }
|
||||||
}}
|
}}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error
|
<mat-error
|
||||||
|
|
|
@ -4,7 +4,8 @@ import {
|
||||||
OnInit,
|
OnInit,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
Inject,
|
Inject,
|
||||||
ChangeDetectorRef
|
ChangeDetectorRef,
|
||||||
|
NgZone
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
FormGroup,
|
FormGroup,
|
||||||
|
@ -73,6 +74,7 @@ import {
|
||||||
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
||||||
import { environment } from '../../../../../environments/environment';
|
import { environment } from '../../../../../environments/environment';
|
||||||
import { StringUtil } from '@ucap-webmessenger/core';
|
import { StringUtil } from '@ucap-webmessenger/core';
|
||||||
|
import { AppService } from '@app/services/app.service';
|
||||||
|
|
||||||
export interface CreateChatDialogData {
|
export interface CreateChatDialogData {
|
||||||
type?: string;
|
type?: string;
|
||||||
|
@ -124,44 +126,13 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
||||||
private logger: NGXLogger,
|
private logger: NGXLogger,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private translateParser: TranslateParser,
|
public appService: AppService,
|
||||||
private changeDetectorRef: ChangeDetectorRef
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private ngZone: NgZone
|
||||||
) {
|
) {
|
||||||
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
|
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
|
||||||
KEY_VER_INFO
|
KEY_VER_INFO
|
||||||
);
|
);
|
||||||
|
|
||||||
const banKeys: string[] = [
|
|
||||||
'group.nameFavorite',
|
|
||||||
'group.nameMyDept',
|
|
||||||
'group.nameDefault'
|
|
||||||
];
|
|
||||||
|
|
||||||
const currentLang = this.translateService.currentLang;
|
|
||||||
const langs = ['ko', 'en'];
|
|
||||||
const translationObservables: Observable<any>[] = [];
|
|
||||||
|
|
||||||
langs.forEach(lang => {
|
|
||||||
translationObservables.push(this.translateService.getTranslation(lang));
|
|
||||||
});
|
|
||||||
|
|
||||||
forkJoin(translationObservables)
|
|
||||||
.pipe(take(1))
|
|
||||||
.subscribe(
|
|
||||||
translations => {
|
|
||||||
for (const translation of translations) {
|
|
||||||
banKeys.forEach(banKey => {
|
|
||||||
this.bannedWords.push(
|
|
||||||
this.translateParser.getValue(translation, banKey)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => {},
|
|
||||||
() => {
|
|
||||||
this.translateService.use(currentLang);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTabIndex: number;
|
currentTabIndex: number;
|
||||||
|
@ -205,8 +176,6 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
inputForm: FormGroup;
|
inputForm: FormGroup;
|
||||||
|
|
||||||
bannedWords: string[] = [];
|
|
||||||
|
|
||||||
groupTreeActivatedSubject = new BehaviorSubject<boolean>(false);
|
groupTreeActivatedSubject = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -356,7 +325,10 @@ export class CreateChatDialogComponent implements OnInit, OnDestroy {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const ban =
|
const ban =
|
||||||
-1 < this.bannedWords.indexOf((control.value as string).trim());
|
-1 <
|
||||||
|
this.appService.bannedGroupNames.indexOf(
|
||||||
|
(control.value as string).trim()
|
||||||
|
);
|
||||||
return ban ? { groupNameBanned: { value: control.value } } : null;
|
return ban ? { groupNameBanned: { value: control.value } } : null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,25 @@ import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
||||||
import { AppNativeService } from './native.service';
|
import { AppNativeService } from './native.service';
|
||||||
import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui';
|
import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui';
|
||||||
import { DateService as UCapDateService } from '@ucap-webmessenger/ui';
|
import { DateService as UCapDateService } from '@ucap-webmessenger/ui';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService, TranslateParser } from '@ngx-translate/core';
|
||||||
import { EnviromentsService } from '@ucap-webmessenger/enviroments';
|
import { EnviromentsService } from '@ucap-webmessenger/enviroments';
|
||||||
import { NGXLogger, NgxLoggerLevel } from 'ngx-logger';
|
import { NGXLogger, NgxLoggerLevel } from 'ngx-logger';
|
||||||
|
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
|
import { Observable, forkJoin } from 'rxjs';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppService {
|
export class AppService {
|
||||||
|
bannedGroupNames: string[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private enviromentsService: EnviromentsService,
|
private enviromentsService: EnviromentsService,
|
||||||
private sessionStorageService: SessionStorageService,
|
private sessionStorageService: SessionStorageService,
|
||||||
private appNotificationService: AppNotificationService,
|
private appNotificationService: AppNotificationService,
|
||||||
private appNativeService: AppNativeService,
|
private appNativeService: AppNativeService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
|
private translateParser: TranslateParser,
|
||||||
private ucapTranslateService: UCapTranslateService,
|
private ucapTranslateService: UCapTranslateService,
|
||||||
private ucapDateService: UCapDateService,
|
private ucapDateService: UCapDateService,
|
||||||
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
||||||
|
@ -42,6 +47,41 @@ export class AppService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public postInit(): Promise<any> {
|
public postInit(): Promise<any> {
|
||||||
|
const bannedGroupNamesPromise = new Promise<void>((resolve, reject) => {
|
||||||
|
const banKeys: string[] = [
|
||||||
|
'group.nameFavorite',
|
||||||
|
'group.nameMyDept',
|
||||||
|
'group.nameDefault'
|
||||||
|
];
|
||||||
|
|
||||||
|
const currentLang = this.translateService.currentLang;
|
||||||
|
const langs = ['ko', 'en'];
|
||||||
|
const translationObservables: Observable<any>[] = [];
|
||||||
|
|
||||||
|
langs.forEach(lang => {
|
||||||
|
translationObservables.push(this.translateService.getTranslation(lang));
|
||||||
|
});
|
||||||
|
|
||||||
|
forkJoin(translationObservables)
|
||||||
|
.pipe(take(1))
|
||||||
|
.subscribe(
|
||||||
|
translations => {
|
||||||
|
for (const translation of translations) {
|
||||||
|
banKeys.forEach(banKey => {
|
||||||
|
this.bannedGroupNames.push(
|
||||||
|
this.translateParser.getValue(translation, banKey)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {},
|
||||||
|
() => {
|
||||||
|
this.translateService.use(currentLang);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const initPromise = new Promise<void>((resolve, reject) => {
|
const initPromise = new Promise<void>((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
let deviceType: DeviceType;
|
let deviceType: DeviceType;
|
||||||
|
@ -71,6 +111,6 @@ export class AppService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all([initPromise]);
|
return Promise.all([initPromise, bannedGroupNamesPromise]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user