[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 {
|
import {
|
||||||
selectBot,
|
selectBot,
|
||||||
selectIsCurrentUserPremium,
|
selectIsCurrentUserPremium,
|
||||||
selectIsUserOrChatContact,
|
|
||||||
selectUser,
|
selectUser,
|
||||||
selectUserStatus,
|
selectUserStatus,
|
||||||
} from './users';
|
} from './users';
|
||||||
@ -1197,7 +1196,7 @@ function canAutoLoadMedia<T extends GlobalState>({
|
|||||||
sender?: ApiPeer;
|
sender?: ApiPeer;
|
||||||
}) {
|
}) {
|
||||||
const isMediaFromContact = Boolean(sender && (
|
const isMediaFromContact = Boolean(sender && (
|
||||||
selectIsChatWithSelf(global, sender.id) || selectIsUserOrChatContact(global, sender)
|
selectIsChatWithSelf(global, sender.id) || selectUser(global, sender.id)?.isContact
|
||||||
));
|
));
|
||||||
|
|
||||||
return Boolean(
|
return Boolean(
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
ApiPeer, ApiUser, ApiUserFullInfo, ApiUserStatus,
|
ApiUser, ApiUserFullInfo, ApiUserStatus,
|
||||||
} from '../../api/types';
|
} from '../../api/types';
|
||||||
import type { GlobalState } from '../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);
|
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 {
|
export function selectBot<T extends GlobalState>(global: T, userId: string): ApiUser | undefined {
|
||||||
const user = selectUser(global, userId);
|
const user = selectUser(global, userId);
|
||||||
if (!user || !isUserBot(user)) {
|
if (!user || !isUserBot(user)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user