Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DSD-DBS/capella-collab-manager
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2adb55efffdacdff0ad2a69ff5fa226cd14f295d
Choose a base ref
..
head repository: DSD-DBS/capella-collab-manager
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4b70bc8fcf786dae953b5f53dfc4b88b78ef0aea
Choose a head ref
Showing with 22 additions and 15 deletions.
  1. +8 −3 frontend/src/app/services/unified-config-wrapper/unified-config-wrapper.service.ts
  2. +14 −12 frontend/src/app/sessions/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
@@ -17,10 +17,15 @@ export class UnifiedConfigWrapperService {
loadUnifiedConfig(): Observable<UnifiedConfig> {
return this.configurationService
.getUnifiedConfig()
.pipe(tap((unified) => this.unifiedConfig.next(unified)));
.pipe(tap((unified) => this._unifiedConfig.next(unified)));
}
private _unifiedConfig = new BehaviorSubject<UnifiedConfig | undefined>(
undefined,
);

unifiedConfig = new BehaviorSubject<UnifiedConfig | undefined>(undefined);
get unifiedConfig() {
return this._unifiedConfig.value;
}

readonly unifiedConfig$ = this.unifiedConfig.asObservable();
readonly unifiedConfig$ = this._unifiedConfig.asObservable();
}
26 changes: 14 additions & 12 deletions frontend/src/app/sessions/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
@@ -4,9 +4,10 @@
*/
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { map } from 'rxjs';
import { map, take } from 'rxjs';
import { filter } from 'rxjs/operators';
import { AuthenticationWrapperService } from 'src/app/services/auth/auth.service';
import { Session } from '../../openapi';
import { FeedbackConfigurationOutput, Session } from '../../openapi';
import { UnifiedConfigWrapperService } from '../../services/unified-config-wrapper/unified-config-wrapper.service';
import { FeedbackDialogComponent } from './feedback-dialog/feedback-dialog.component';

@@ -30,10 +31,13 @@ export class FeedbackWrapperService {
);

triggerFeedbackPrompt(): void {
if (this.shouldShowIntervalPrompt() && this.authService.isLoggedIn()) {
this.showDialog([], 'On interval');
this.saveFeedbackPromptDate();
}
if (!this.authService.isLoggedIn()) return;
this.feedbackConfig$.pipe(filter(Boolean), take(1)).subscribe((config) => {
if (this.shouldShowIntervalPrompt(config)) {
this.showDialog([], 'On interval');
this.saveFeedbackPromptDate();
}
});
}

public showDialog(sessions: Session[], trigger: string) {
@@ -43,17 +47,15 @@ export class FeedbackWrapperService {
});
}

public shouldShowIntervalPrompt() {
const feedbackConfig =
this.unifiedConfigWrapperService.unifiedConfig?.value?.feedback;
if (!feedbackConfig?.interval?.enabled) return false;
public shouldShowIntervalPrompt(config: FeedbackConfigurationOutput) {
if (!config?.interval?.enabled) return false;
const lastPrompt = localStorage.getItem('feedbackPrompt');
if (!lastPrompt) {
return true;
}
const lastPromptDate = new Date(parseInt(lastPrompt));

const hoursInterval = feedbackConfig.interval.hours_between_prompt;
const hoursInterval = config.interval.hours_between_prompt;
const diff = new Date().getTime() - lastPromptDate.getTime();
const hours = diff / (1000 * 60 * 60);
return hours >= hoursInterval;
@@ -64,7 +66,7 @@ export class FeedbackWrapperService {
}

public shouldShowPostSessionPrompt() {
return !!this.unifiedConfigWrapperService.unifiedConfig?.value?.feedback
return !!this.unifiedConfigWrapperService.unifiedConfig?.feedback
?.after_session;
}
}