@@ -21,7 +21,7 @@ import { MatDialogRef } from '@angular/material/dialog'
2121import { cloneDeep } from 'lodash'
2222import * as _ from 'lodash'
2323import { Subject } from 'rxjs'
24- import { first , takeUntil } from 'rxjs/operators'
24+ import { finalize , first , takeUntil } from 'rxjs/operators'
2525import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
2626
2727import { URL_REGEXP } from '../../../../constants'
@@ -65,6 +65,7 @@ export class ModalWebsitesComponent implements OnInit, OnDestroy {
6565 screenDirection = 'ltr'
6666 addedWebsiteCount = 0
6767 loadingWebsites = true
68+ isSavingWebsites = false
6869 urlMaxLength = 1999
6970 urlTitleMaxLength = 354
7071
@@ -177,18 +178,27 @@ export class ModalWebsitesComponent implements OnInit, OnDestroy {
177178 }
178179
179180 saveEvent ( ) {
181+ if ( this . isSavingWebsites ) {
182+ return
183+ }
184+
180185 this . websitesForm . markAllAsTouched ( )
181186 this . websitesForm . updateValueAndValidity ( )
182187
183188 if ( this . websitesForm . valid ) {
184- this . loadingWebsites = true
189+ this . isSavingWebsites = true
185190 this . _recordWebsitesService
186191 . postWebsites ( this . formToBackend ( this . websitesForm ) )
192+ . pipe (
193+ finalize ( ( ) => {
194+ this . isSavingWebsites = false
195+ } )
196+ )
187197 . subscribe (
188198 ( ) => {
189199 this . closeEvent ( )
190200 } ,
191- ( error ) => { }
201+ ( ) => { }
192202 )
193203 } else {
194204 this . _snackBar . showValidationError ( )
0 commit comments