fixed state corner cases
This commit is contained in:
parent
0f7a6d136e
commit
5d14dfeeb8
@ -95,10 +95,6 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
return this.instance?.docViewer?.getCurrentPage();
|
||||
}
|
||||
|
||||
get canPerformAnnotationActions() {
|
||||
return this.appStateService.canPerformAnnotationActionsOnCurrentFile();
|
||||
}
|
||||
|
||||
private projectId: string;
|
||||
private _activeViewer: 'ANNOTATED' | 'REDACTED' = 'ANNOTATED';
|
||||
private instance: WebViewerInstance;
|
||||
@ -120,9 +116,12 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
private _activeMenuAnnotation: AnnotationWrapper;
|
||||
loadingMessage: string;
|
||||
|
||||
canPerformAnnotationActions: boolean;
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.canPerformAnnotationActions = this.appStateService.canPerformAnnotationActionsOnCurrentFile();
|
||||
this._loadFileData().subscribe(() => {});
|
||||
this.appStateService.fileStatusChanged.subscribe((fileStatus: FileStatusWrapper) => {
|
||||
this.appStateService.fileReanalysed.subscribe((fileStatus: FileStatusWrapper) => {
|
||||
if (fileStatus.fileId === this.fileId) {
|
||||
this._loadFileData().subscribe(() => {
|
||||
this.viewReady = true;
|
||||
@ -192,7 +191,10 @@ export class FilePreviewScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
public assignReviewer() {
|
||||
this._fileActionService.assignProjectReviewer();
|
||||
this._fileActionService.assignProjectReviewer(null, () => {
|
||||
console.log(this.appStateService.canPerformAnnotationActionsOnCurrentFile());
|
||||
this.canPerformAnnotationActions = this.appStateService.canPerformAnnotationActionsOnCurrentFile();
|
||||
});
|
||||
}
|
||||
|
||||
public handleAnnotationSelected(annotationId: string) {
|
||||
|
||||
@ -22,7 +22,8 @@ export class FileActionService {
|
||||
if (this._appStateService.isActiveProjectOwnerAndManager) {
|
||||
this._dialogService.openAssignFileReviewerDialog(
|
||||
file ? file : this._appStateService.activeFile,
|
||||
() => {
|
||||
async () => {
|
||||
await this._appStateService.reloadActiveProjectFiles();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
@ -35,7 +36,8 @@ export class FileActionService {
|
||||
file ? file.fileId : this._appStateService.activeFileId,
|
||||
this._userService.userId
|
||||
)
|
||||
.subscribe(() => {
|
||||
.subscribe(async () => {
|
||||
await this._appStateService.reloadActiveProjectFiles();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ export class AppStateService {
|
||||
private _appState: AppState;
|
||||
private _dictionaryData: { [key: string]: TypeValue } = null;
|
||||
public fileStatusChanged = new EventEmitter<FileStatusWrapper>();
|
||||
public fileReanalysed = new EventEmitter<FileStatusWrapper>();
|
||||
|
||||
constructor(
|
||||
private readonly _router: Router,
|
||||
@ -189,7 +190,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
get activeFileId(): string {
|
||||
return this._appState.activeFile.fileId;
|
||||
return this._appState.activeFile?.fileId;
|
||||
}
|
||||
|
||||
get totalAnalysedPages() {
|
||||
@ -256,12 +257,15 @@ export class AppStateService {
|
||||
if (oldFile.fileId === file.fileId) {
|
||||
// emit when analysis count changed
|
||||
if (oldFile.lastUpdated !== file.lastUpdated) {
|
||||
this.fileStatusChanged.emit(
|
||||
new FileStatusWrapper(
|
||||
file,
|
||||
this._userService.getNameForId(file.currentReviewer)
|
||||
)
|
||||
const fileStatusWrapper = new FileStatusWrapper(
|
||||
file,
|
||||
this._userService.getNameForId(file.currentReviewer)
|
||||
);
|
||||
this.fileStatusChanged.emit(fileStatusWrapper);
|
||||
|
||||
if (oldFile.lastProcessed !== file.lastProcessed) {
|
||||
this.fileReanalysed.emit(fileStatusWrapper);
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
@ -395,6 +399,10 @@ export class AppStateService {
|
||||
this._appState.totalPeople = totalPeople.size;
|
||||
this._appState.totalAnalysedPages = totalAnalysedPages;
|
||||
this._appState.totalDocuments = totalDocuments;
|
||||
|
||||
if (this.activeProjectId && this.activeFileId) {
|
||||
this.activateFile(this.activeProjectId, this.activeFileId);
|
||||
}
|
||||
}
|
||||
|
||||
async reloadActiveProjectFiles() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user