Commit 51d34251 authored by Christopher Fullarton's avatar Christopher Fullarton

Fixes error message when joining a quiz

parent d1ee4927
Pipeline #34031 passed with stages
in 16 minutes and 21 seconds
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { distinctUntilChanged, filter, map, switchMap, takeUntil } from 'rxjs/operators';
import { distinctUntilChanged, filter, map, switchMapTo, takeUntil } from 'rxjs/operators';
import { QuizEntity } from '../../lib/entities/QuizEntity';
import { UserRole } from '../../lib/enums/UserRole';
import { QuizApiService } from '../../service/api/quiz/quiz-api.service';
......@@ -28,16 +28,18 @@ export class QuizDuplicateComponent implements OnInit, OnDestroy {
public ngOnInit(): void {
this.route.paramMap.pipe(map(params => params.get('name')), filter(() => this.userService.isAuthorizedFor(UserRole.CreateQuiz)),
distinctUntilChanged(), takeUntil(this._destroy), switchMap(name => this.quizApiService.initQuizInstance(name)))
distinctUntilChanged(), switchMapTo(this.quizApiService.initQuizInstance(name)), takeUntil(this._destroy))
.subscribe(async data => {
await this.storageService.db.Quiz.put(data.payload.quiz);
this.quizService.quiz = new QuizEntity(data.payload.quiz);
this.quizService.isOwner = true;
console.log('router navigate duplicate');
this.router.navigate(['/quiz', 'flow']);
});
}
public ngOnDestroy(): void {
console.log('ondestroy duplicate');
this._destroy.next();
this._destroy.complete();
}
......
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
import { distinctUntilChanged, filter, map, switchMapTo, takeUntil } from 'rxjs/operators';
import { DbState } from '../../lib/enums/enums';
import { MessageProtocol, StatusProtocol } from '../../lib/enums/Message';
import { IMessage } from '../../lib/interfaces/communication/IMessage';
import { QuizApiService } from '../../service/api/quiz/quiz-api.service';
import { CasLoginService } from '../../service/login/cas-login.service';
import { QuizService } from '../../service/quiz/quiz.service';
import { SharedService } from '../../service/shared/shared.service';
import { StorageService } from '../../service/storage/storage.service';
import { ThemesService } from '../../service/themes/themes.service';
@Component({
......@@ -27,7 +29,7 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
private casService: CasLoginService,
private themesService: ThemesService,
private quizApiService: QuizApiService,
private sharedService: SharedService,
private sharedService: SharedService, private storageService: StorageService,
) {
}
......@@ -37,14 +39,16 @@ export class QuizJoinComponent implements OnInit, OnDestroy {
});
this.route.paramMap.pipe(map(val => val.get('quizName')), distinctUntilChanged(), takeUntil(this._destroy)).subscribe(quizname => {
console.log(quizname);
if (!quizname) {
this.router.navigate(['/']);
return;
}
this.sharedService.isLoadingEmitter.next(true);
this.quizApiService.getFullQuizStatusData(quizname).subscribe(quizStatusData => this.resolveQuizStatusData(quizStatusData));
const quizData$ = this.quizApiService.getFullQuizStatusData(quizname);
this.storageService.stateNotifier.pipe(filter(val => val === DbState.Initialized), distinctUntilChanged(), switchMapTo(quizData$),
takeUntil(this._destroy)).subscribe(quizStatusData => this.resolveQuizStatusData(quizStatusData));
});
}
......
<div *ngIf="!isLoading;else loadingSpinner">
<div [class.d-none]="isLoading">
<div class="px-1 px-sm-4">
<app-header></app-header>
</div>
......@@ -22,10 +22,9 @@
</div>
</div>
<ng-template #loadingSpinner>
<div id="loader-wrapper">
<div id="loader"></div>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>
</ng-template>
<div [class.d-none]="!isLoading"
id="loader-wrapper">
<div id="loader"></div>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHandler, Injectable } from '@angular/core';
import { captureException, init as SentryInit, setExtra, showReportDialog } from '@sentry/browser';
import { captureException, Event as SentryEvent, init as SentryInit, setExtra, showReportDialog } from '@sentry/browser';
import { EventHint } from '@sentry/types';
import { environment } from '../../environments/environment';
@Injectable({ providedIn: 'root' })
export class SentryErrorHandler implements ErrorHandler {
private readonly _enabled = environment.production && environment.sentryDSN && !['localhost', '127.0.0.1'].includes(location.hostname);
private readonly _enabled = !!environment.sentryDSN;
constructor() {
if (!environment.sentryDSN) {
......@@ -15,16 +17,24 @@ export class SentryErrorHandler implements ErrorHandler {
dsn: environment.sentryDSN,
enabled: this._enabled,
release: environment.version,
beforeSend(event: SentryEvent, hint?: EventHint): PromiseLike<SentryEvent | null> | SentryEvent | null {
if (event.exception.values.some(val => !val.mechanism.handled)) {
console.log('sending error event', event, hint);
return event;
}
return null;
},
});
setExtra('nonErrorException', false);
}
public handleError(error): void {
if (!this._enabled) {
if (!this._enabled || error instanceof HttpErrorResponse) {
return;
}
console.log('error occured', error);
const eventId = captureException(error.originalError || error);
showReportDialog({ eventId });
}
......
......@@ -11,6 +11,7 @@ export const environment: IEnvironment = {
production: false,
version: 'VERSION',
enableCasLogin: true,
sentryDSN: 'https://f16c02fdefe64c018f5d580d1cf05b56@sentry.io/1819496',
ssrEndpoint: 'http://192.168.2.106:4000',
serverEndpoint: 'http://192.168.2.106:3010',
httpApiEndpoint: 'http://192.168.2.106:3010/api/v1',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment