|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
|
import { NavigationEnd, Router } from '@angular/router';
|
|
|
|
|
import { Subject, Subscription } from 'rxjs';
|
|
|
|
|
import { filter } from 'rxjs/operators';
|
|
|
|
|
import { FriendsService } from '../../services/friends/friends.service';
|
|
|
|
|
import { ModalService } from '../../services/modal/modal.service';
|
|
|
|
|
import { PinService } from '../../services/pin/pin.service';
|
|
|
|
@ -16,6 +18,7 @@ export class ShareModalComponent implements OnInit, OnDestroy {
|
|
|
|
|
modalId: string = 'share-modal';
|
|
|
|
|
isShareModalOpen = false;
|
|
|
|
|
private modalSub!: Subscription;
|
|
|
|
|
private routerSubscription!: Subscription;
|
|
|
|
|
isFriendModalOpen: boolean = false;
|
|
|
|
|
hasAcceptedFriends: boolean = false;
|
|
|
|
|
hasPendingFriends: boolean = false;
|
|
|
|
@ -28,7 +31,8 @@ export class ShareModalComponent implements OnInit, OnDestroy {
|
|
|
|
|
constructor(
|
|
|
|
|
private modalService: ModalService,
|
|
|
|
|
private friendService: FriendsService,
|
|
|
|
|
private pinService: PinService
|
|
|
|
|
private pinService: PinService,
|
|
|
|
|
private router: Router
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
@ -39,12 +43,24 @@ export class ShareModalComponent implements OnInit, OnDestroy {
|
|
|
|
|
if (open) {
|
|
|
|
|
this.getFriend();
|
|
|
|
|
this.pinId = this.modalService.getCurrentPinId();
|
|
|
|
|
setTimeout(() => this.moveModalToBody(), 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// S'abonner aux événements de navigation du router
|
|
|
|
|
this.routerSubscription = this.router.events
|
|
|
|
|
.pipe(filter((event) => event instanceof NavigationEnd))
|
|
|
|
|
.subscribe(() => {
|
|
|
|
|
// Attendre que le DOM soit mis à jour après la navigation
|
|
|
|
|
setTimeout(() => this.moveModalToBody(), 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.modalSub?.unsubscribe();
|
|
|
|
|
if (this.routerSubscription) {
|
|
|
|
|
this.routerSubscription.unsubscribe();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openShareModal() {
|
|
|
|
|