import { MatrixClient } from 'matrix-js-sdk';
import { allInvitesAtom, useBindAllInvitesAtom } from '../room-list/inviteList';
import { allRoomsAtom, useBindAllRoomsAtom } from '../room-list/roomList';
import { mDirectAtom, useBindMDirectAtom } from '../mDirectList';
import { roomToUnreadAtom } from '../room/roomToUnread';
import { useBindRoomToUnreadAtom } from '../room/useBindRoomToUnreadAtom';
import { roomToParentsAtom, useBindRoomToParentsAtom } from '../room/roomToParents';
import { roomIdToTypingMembersAtom, useBindRoomIdToTypingMembersAtom } from '../typingMembers';
import { useAutoDirectSync } from '../../hooks/useAutoDirectSync';
import { useUnreadThreadingEnabled } from '../../hooks/useClientConfig';

export const useBindAtoms = (mx: MatrixClient) => {
  const unreadThreadingEnabled = useUnreadThreadingEnabled();

  useBindMDirectAtom(mx, mDirectAtom);
  useAutoDirectSync(mx);
  useBindAllInvitesAtom(mx, allInvitesAtom);
  useBindAllRoomsAtom(mx, allRoomsAtom);
  useBindRoomToParentsAtom(mx, roomToParentsAtom);
  useBindRoomToUnreadAtom(mx, roomToUnreadAtom, unreadThreadingEnabled);

  useBindRoomIdToTypingMembersAtom(mx, roomIdToTypingMembersAtom);
};
