Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / applications / drive / src / app / store / _views / useShareBackgroundActions.tsx
blobb0094e202b81afeb15101fb9e92548537d25f80b
1 import { EVENT_TYPES } from '@proton/shared/lib/drive/constants';
3 import type { DriveEvent } from '../_events';
4 import { type DriveEvents } from '../_events';
5 import { useInvitations } from '../_invitations';
7 export const useShareBackgroundActions = () => {
8     const { convertExternalInvitation } = useInvitations();
9     const convertExternalInvitationsFromEvents = (
10         { events, eventId }: DriveEvents,
11         processedEventCounter: (eventId: string, event: DriveEvent) => void
12     ) => {
13         const abortController = new AbortController();
14         for (let event of events) {
15             if (event.eventType === EVENT_TYPES.UPDATE_METADATA && event.data?.externalInvitationSignup) {
16                 void convertExternalInvitation(abortController.signal, {
17                     externalInvitationId: event.data.externalInvitationSignup,
18                     linkId: event.encryptedLink.linkId,
19                 });
20                 processedEventCounter(eventId, event);
21             }
22         }
23     };
25     return { convertExternalInvitationsFromEvents };