From 66a7829e64fb1057eb4a3239d20257e07abd5869 Mon Sep 17 00:00:00 2001 From: Saniya <37302318+Saby-Bishops@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:51:58 -0600 Subject: [PATCH 1/3] refactor: use typed forms in chat share dialog --- .../dialogs/dialogs-chat-share.component.ts | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/app/shared/dialogs/dialogs-chat-share.component.ts b/src/app/shared/dialogs/dialogs-chat-share.component.ts index 4d3ca4baeb..18df20aeba 100644 --- a/src/app/shared/dialogs/dialogs-chat-share.component.ts +++ b/src/app/shared/dialogs/dialogs-chat-share.component.ts @@ -1,6 +1,7 @@ import { Component, Inject, OnInit, ViewChild } from '@angular/core'; +import { StepperSelectionEvent } from '@angular/cdk/stepper'; import { MatStepper } from '@angular/material/stepper'; -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, MatLegacyDialogRef as MatDialogRef, MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; @@ -22,6 +23,16 @@ import { DialogsAnnouncementSuccessComponent } from '../../shared/dialogs/dialog } ` ] }) +interface TeamForm { + message: FormControl; + linkId: FormControl; + teamType: FormControl; +} + +interface CommunityForm { + message: FormControl; +} + export class DialogsChatShareComponent implements OnInit { user = this.userService.get(); conversation: any; @@ -29,8 +40,8 @@ export class DialogsChatShareComponent implements OnInit { membersInfo: any; excludeIds: any[] = []; showForm: boolean; - teamForm: UntypedFormGroup; - communityForm: UntypedFormGroup; + teamForm: FormGroup; + communityForm: FormGroup; @ViewChild('linkStepper') linkStepper: MatStepper; selectedLink: { db, title, selector? }; @@ -43,7 +54,7 @@ export class DialogsChatShareComponent implements OnInit { public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, private couchService: CouchService, - private formBuilder: UntypedFormBuilder, + private formBuilder: FormBuilder, private newsService: NewsService, private teamsService: TeamsService, private userService: UserService, @@ -54,10 +65,10 @@ export class DialogsChatShareComponent implements OnInit { } ngOnInit() { - this.communityForm = this.formBuilder.group({ + this.communityForm = this.formBuilder.nonNullable.group({ message: '' }); - this.teamForm = this.formBuilder.group({ + this.teamForm = this.formBuilder.nonNullable.group({ message: '', linkId: '', teamType: '' @@ -65,16 +76,20 @@ export class DialogsChatShareComponent implements OnInit { this.getTeams(); } - teamSelect({ teamId, teamType }) { + teamSelect({ teamId, teamType }: { teamId: string; teamType: string }) { this.teamForm.controls.linkId.setValue(teamId); this.teamForm.controls.teamType.setValue(teamType); this.linkStepper.selected.completed = true; this.linkStepper.next(); } - linkStepperChange({ selectedIndex }) { + linkStepperChange({ selectedIndex }: StepperSelectionEvent) { if (selectedIndex === 0 && this.teamForm.pristine !== true) { - this.teamForm.reset(); + this.teamForm.reset({ + message: '', + linkId: '', + teamType: '' + }); } } @@ -111,13 +126,14 @@ export class DialogsChatShareComponent implements OnInit { } shareWithTeam() { - let linkId, teamType; - if (this.teamForm.valid) { - const team = this.teamForm.value; - this.conversation.message = team.message ? team.message : '
'; - ({ linkId, teamType } = team); + if (!this.teamForm.valid) { + return; } + const team = this.teamForm.getRawValue(); + this.conversation.message = team.message ? team.message : '
'; + const { linkId, teamType } = team; + this.getTeam(linkId).pipe( switchMap((teamData) => { this.teamInfo = teamData; @@ -139,7 +155,7 @@ export class DialogsChatShareComponent implements OnInit { shareWithCommunity() { if (this.communityForm.valid) { - const message = this.communityForm.get('message').value; + const message = this.communityForm.controls.message.value; this.conversation.message = message ? { text: message, images: [] } : { text: '
', images: [] }; } this.conversation.chat = true; From 7f206fb085a0abbc1fff1953f89bd7ac780e4593 Mon Sep 17 00:00:00 2001 From: Saniya <37302318+Saby-Bishops@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:43:37 -0600 Subject: [PATCH 2/3] Fix chat share component decorator placement --- .../dialogs/dialogs-chat-share.component.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/shared/dialogs/dialogs-chat-share.component.ts b/src/app/shared/dialogs/dialogs-chat-share.component.ts index 18df20aeba..f6c73626ec 100644 --- a/src/app/shared/dialogs/dialogs-chat-share.component.ts +++ b/src/app/shared/dialogs/dialogs-chat-share.component.ts @@ -15,14 +15,6 @@ import { UserService } from '../../shared/user.service'; import { UserChallengeStatusService } from '../user-challenge-status.service'; import { DialogsAnnouncementSuccessComponent } from '../../shared/dialogs/dialogs-announcement.component'; -@Component({ - templateUrl: './dialogs-chat-share.component.html', - styles: [ ` - .mat-expansion-panel { - box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.1); - } - ` ] -}) interface TeamForm { message: FormControl; linkId: FormControl; @@ -33,6 +25,14 @@ interface CommunityForm { message: FormControl; } +@Component({ + templateUrl: './dialogs-chat-share.component.html', + styles: [ ` + .mat-expansion-panel { + box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.1); + } + ` ] +}) export class DialogsChatShareComponent implements OnInit { user = this.userService.get(); conversation: any; From 5b6dce2af08886507cbd7e3c99cec837db250a33 Mon Sep 17 00:00:00 2001 From: mutugiii Date: Fri, 28 Nov 2025 23:03:23 +0300 Subject: [PATCH 3/3] cleanup --- src/app/shared/dialogs/dialogs-chat-share.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/shared/dialogs/dialogs-chat-share.component.ts b/src/app/shared/dialogs/dialogs-chat-share.component.ts index f6c73626ec..a85a4c79e1 100644 --- a/src/app/shared/dialogs/dialogs-chat-share.component.ts +++ b/src/app/shared/dialogs/dialogs-chat-share.component.ts @@ -1,7 +1,7 @@ import { Component, Inject, OnInit, ViewChild } from '@angular/core'; import { StepperSelectionEvent } from '@angular/cdk/stepper'; import { MatStepper } from '@angular/material/stepper'; -import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { NonNullableFormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, MatLegacyDialogRef as MatDialogRef, MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; @@ -54,7 +54,7 @@ export class DialogsChatShareComponent implements OnInit { public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, private couchService: CouchService, - private formBuilder: FormBuilder, + private fb: NonNullableFormBuilder, private newsService: NewsService, private teamsService: TeamsService, private userService: UserService, @@ -65,10 +65,10 @@ export class DialogsChatShareComponent implements OnInit { } ngOnInit() { - this.communityForm = this.formBuilder.nonNullable.group({ + this.communityForm = this.fb.group({ message: '' }); - this.teamForm = this.formBuilder.nonNullable.group({ + this.teamForm = this.fb.group({ message: '', linkId: '', teamType: ''