Refactor toggleShowResults method to persist showResultsToParticipants flag correctly

This commit is contained in:
Dimas Wiese
2026-03-16 00:55:03 +01:00
parent d27c8382de
commit 81f88f10f8

View File

@@ -109,20 +109,17 @@ export class SurveyDetailPage implements OnInit, OnDestroy {
// Settings // Settings
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** Toggle and persist the showResultsToParticipants flag */ /** Persist the showResultsToParticipants flag after ngModel has updated it */
async toggleShowResults(): Promise<void> { async toggleShowResults(): Promise<void> {
if (!this.survey) return; if (!this.survey) return;
const newValue = !this.survey.showResultsToParticipants;
await this.surveyService.updateSurvey(this.surveyId, { await this.surveyService.updateSurvey(this.surveyId, {
showResultsToParticipants: newValue, showResultsToParticipants: this.survey.showResultsToParticipants,
}); });
this.survey.showResultsToParticipants = newValue;
} }
async changeSurveyStatus(status: Survey['status']): Promise<void> { async changeSurveyStatus(status: Survey['status']): Promise<void> {
if (!this.survey) return; if (!this.survey) return;
await this.surveyService.updateSurvey(this.surveyId, { status }); await this.surveyService.updateSurvey(this.surveyId, { status });
this.survey.status = status;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------