[Perf] Message: Remove n^2 for detecting contacts
This commit is contained in:
parent
1e4950c7e3
commit
67bdfe318b
@ -72,7 +72,6 @@ import { selectTabState } from './tabs';
|
||||
import {
|
||||
selectBot,
|
||||
selectIsCurrentUserPremium,
|
||||
selectIsUserOrChatContact,
|
||||
selectUser,
|
||||
selectUserStatus,
|
||||
} from './users';
|
||||
@ -1197,7 +1196,7 @@ function canAutoLoadMedia<T extends GlobalState>({
|
||||
sender?: ApiPeer;
|
||||
}) {
|
||||
const isMediaFromContact = Boolean(sender && (
|
||||
selectIsChatWithSelf(global, sender.id) || selectIsUserOrChatContact(global, sender)
|
||||
selectIsChatWithSelf(global, sender.id) || selectUser(global, sender.id)?.isContact
|
||||
));
|
||||
|
||||
return Boolean(
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type {
|
||||
ApiPeer, ApiUser, ApiUserFullInfo, ApiUserStatus,
|
||||
ApiUser, ApiUserFullInfo, ApiUserStatus,
|
||||
} from '../../api/types';
|
||||
import type { GlobalState } from '../types';
|
||||
|
||||
@ -42,10 +42,6 @@ export function selectUserByPhoneNumber<T extends GlobalState>(global: T, phoneN
|
||||
return Object.values(global.users.byId).find((user) => user?.phoneNumber === phoneNumberCleaned);
|
||||
}
|
||||
|
||||
export function selectIsUserOrChatContact<T extends GlobalState>(global: T, peer: ApiPeer) {
|
||||
return global.contactList && global.contactList.userIds.includes(peer.id);
|
||||
}
|
||||
|
||||
export function selectBot<T extends GlobalState>(global: T, userId: string): ApiUser | undefined {
|
||||
const user = selectUser(global, userId);
|
||||
if (!user || !isUserBot(user)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user