import { useEffect, useState } from 'react';
import { database } from 'src/watermelondb';
import { Q } from '@nozbe/watermelondb';

export function useBlockedUsersLive() {
  const [users, setUsers] = useState<any[]>([]);

  useEffect(() => {
    const collection = database.get('blocked_users');
    const subscription = collection.query(Q.where('removed', false)).observe().subscribe(setUsers);
    return () => subscription.unsubscribe();
  }, []);

  return users;
}
