Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

599 B
Raw Blame
import { usePathname, useRouter } from 'expo-router';
import { useShareIntentContext } from 'expo-share-intent';
import { useEffect } from 'react';

import { shouldRedirectShareIntent } from '../share-intent.models';

export function ShareIntentHandler() {
  const router = useRouter();
  const pathname = usePathname();
  const { hasShareIntent } = useShareIntentContext();

  useEffect(() => {
    if (!shouldRedirectShareIntent({ hasShareIntent, pathname })) {
      return;
    }

    router.push('/(app)/(with-organizations)/share');
  }, [hasShareIntent, pathname, router]);

  return null;
}