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
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,
20 processedEventCounter(eventId, event);
25 return { convertExternalInvitationsFromEvents };