"use strict";

import { getUserByXmppUsername } from '../networking/api-requests/roomMembers.api';
import { store } from '../roomStore';
function getUniqueUsers(messages) {
  const userMap = new Map();
  messages.forEach(({
    user
  }) => {
    if (!userMap.has(user.id)) {
      userMap.set(user.id, user);
    }
  });
  return new Set(userMap.values());
}
export const getUnnamedUsers = messages => {
  const uniqueUsers = getUniqueUsers(messages);
  return [...uniqueUsers].filter(user => user?.name?.toLowerCase().includes('deleted'));
};
export const fixUnnamedArrayFromApi = async unnamedUsers => {
  const fetchedUsers = await Promise.all(unnamedUsers.map(async user => {
    const apiUser = await getUserByXmppUsername(user.id, store.getState().chatSettingStore.user.token);
    return apiUser;
  }));
  return fetchedUsers.filter(u => u !== null);
};
//# sourceMappingURL=getUnnamedUsers.js.map