diff --git a/src/api/gramjs/apiBuilders/payments.ts b/src/api/gramjs/apiBuilders/payments.ts index 8e60c9b17..71fca6dc7 100644 --- a/src/api/gramjs/apiBuilders/payments.ts +++ b/src/api/gramjs/apiBuilders/payments.ts @@ -171,7 +171,7 @@ export function buildApiPremiumPromo(promo: GramJs.help.PremiumPromo): ApiPremiu return { statusText, - statusEntities: statusEntities.map((l) => buildApiMessageEntity(l)), + statusEntities: statusEntities.map(buildApiMessageEntity), videoSections, videos: videos.map(buildApiDocument).filter(Boolean), options: periodOptions.map(buildApiPremiumSubscriptionOption), diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 73fc4f510..022e43ed4 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -771,7 +771,7 @@ export async function fetchChatFolders() { return undefined; } - const defaultFolderPosition = result.findIndex((l) => l instanceof GramJs.DialogFilterDefault); + const defaultFolderPosition = result.findIndex((folder) => folder instanceof GramJs.DialogFilterDefault); const dialogFilters = result.filter((df): df is GramJs.DialogFilter => df instanceof GramJs.DialogFilter); const orderedIds = dialogFilters.map(({ id }) => id); if (defaultFolderPosition !== -1) { diff --git a/src/api/gramjs/methods/management.ts b/src/api/gramjs/methods/management.ts index c390636e7..1c3d31923 100644 --- a/src/api/gramjs/methods/management.ts +++ b/src/api/gramjs/methods/management.ts @@ -104,7 +104,7 @@ export async function fetchExportedChatInvites({ addEntitiesWithPhotosToLocalDb(exportedInvites.users); // TODO Verify Exported Invite logic return (exportedInvites.invites - .filter((l) => l instanceof GramJs.ChatInviteExported) as GramJs.ChatInviteExported[]) + .filter((invite): invite is GramJs.ChatInviteExported => invite instanceof GramJs.ChatInviteExported)) .map(buildApiExportedInvite); } diff --git a/src/components/calls/group/GroupCall.tsx b/src/components/calls/group/GroupCall.tsx index 1c9a65050..aa39cf6b4 100644 --- a/src/components/calls/group/GroupCall.tsx +++ b/src/components/calls/group/GroupCall.tsx @@ -88,7 +88,7 @@ const GroupCall: FC = ({ const [isLeaving, setIsLeaving] = useState(false); const [isFullscreen, openFullscreen, closeFullscreen] = useFlag(); const [isSidebarOpen, openSidebar, closeSidebar] = useFlag(true); - const hasVideoParticipants = participants && Object.values(participants).some((l) => l.video || l.presentation); + const hasVideoParticipants = Object.values(participants).some(({ video, presentation }) => video || presentation); const isLandscape = isFullscreen && !IS_SINGLE_COLUMN_LAYOUT && hasVideoParticipants; const [participantMenu, setParticipantMenu] = useState<{ diff --git a/src/components/calls/group/GroupCallParticipantStreams.tsx b/src/components/calls/group/GroupCallParticipantStreams.tsx index d3c842106..f5f11f0af 100644 --- a/src/components/calls/group/GroupCallParticipantStreams.tsx +++ b/src/components/calls/group/GroupCallParticipantStreams.tsx @@ -27,10 +27,10 @@ const GroupCallParticipantStreams: FC = ({ }) => { const [selectedVideo, setSelectedVideo] = useState(undefined); const presentationParticipants = useMemo(() => { - return Object.values(participants || {}).filter((l) => l.hasPresentationStream); + return Object.values(participants || {}).filter((participant) => participant.hasPresentationStream); }, [participants]); const videoParticipants = useMemo(() => { - return Object.values(participants || {}).filter((l) => l.hasVideoStream); + return Object.values(participants || {}).filter((participant) => participant.hasVideoStream); }, [participants]); const totalVideoCount = videoParticipants.length + presentationParticipants.length; diff --git a/src/components/middle/composer/AttachBotIcon.tsx b/src/components/middle/composer/AttachBotIcon.tsx index 71140a48e..b214b4523 100644 --- a/src/components/middle/composer/AttachBotIcon.tsx +++ b/src/components/middle/composer/AttachBotIcon.tsx @@ -33,9 +33,9 @@ const AttachBotIcon: FC = ({ const mediaDataWithReplacedColors = mediaData.replace(COLOR_REPLACE_PATTERN, color); const doc = new DOMParser().parseFromString(mediaDataWithReplacedColors, 'image/svg+xml'); - doc.querySelectorAll('path').forEach((l) => { - l.style.stroke = color; - l.style.strokeWidth = ADDITIONAL_STROKE_WIDTH; + doc.querySelectorAll('path').forEach((path) => { + path.style.stroke = color; + path.style.strokeWidth = ADDITIONAL_STROKE_WIDTH; }); return `data:image/svg+xml;utf8,${doc.documentElement.outerHTML}`; diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index 0f6dc05b3..de043f5ad 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -358,7 +358,7 @@ const Composer: FC = ({ const handleSetAttachments = useCallback( (newValue: ApiAttachment[] | ((current: ApiAttachment[]) => ApiAttachment[])) => { const newAttachments = typeof newValue === 'function' ? newValue(attachments) : newValue; - if (newAttachments && newAttachments.some((l) => l.size > fileSizeLimit)) { + if (newAttachments.some(({ size }) => size > fileSizeLimit)) { openLimitReachedModal({ limit: 'uploadMaxFileparts', }); diff --git a/src/components/middle/composer/StickerSet.tsx b/src/components/middle/composer/StickerSet.tsx index 1025c5a24..0be81a9dc 100644 --- a/src/components/middle/composer/StickerSet.tsx +++ b/src/components/middle/composer/StickerSet.tsx @@ -111,7 +111,7 @@ const StickerSet: FC = ({ }, [isCurrentUserPremium, isPremiumSet, openPremiumModal, stickerSet, toggleStickerSet]); const isLocked = !isSavedMessages && !isRecent && isEmoji && !isCurrentUserPremium - && stickerSet.stickers?.some((l) => !l.isFree); + && stickerSet.stickers?.some(({ isFree }) => !isFree); const itemSize = isEmoji ? EMOJI_SIZE_PICKER : STICKER_SIZE_PICKER; const itemsPerRow = isEmoji ? EMOJI_PER_ROW_ON_DESKTOP : STICKERS_PER_ROW_ON_DESKTOP; const margin = isEmoji ? EMOJI_MARGIN : STICKER_MARGIN; diff --git a/src/components/right/management/ManageChatPrivacyType.tsx b/src/components/right/management/ManageChatPrivacyType.tsx index ad13599e7..b8375d489 100644 --- a/src/components/right/management/ManageChatPrivacyType.tsx +++ b/src/components/right/management/ManageChatPrivacyType.tsx @@ -109,7 +109,7 @@ const ManageChatPrivacyType: FC = ({ const handleOptionChange = useCallback((value: string, e: ChangeEvent) => { const myChats = Object.values(getGlobal().chats.byId) - .filter((l) => l.isCreator && l.usernames?.some((c) => c.isActive)); + .filter(({ isCreator, usernames }) => isCreator && usernames?.some((c) => c.isActive)); if (myChats.length >= maxPublicLinks && value === 'public') { openLimitReachedModal({ limit: 'channelsPublic' }); diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index ec89f9629..f4a3ff5d4 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -617,7 +617,7 @@ addActionHandler('openTelegramLink', (global, actions, payload) => { const hostParts = uri.hostname.split('.'); if (hostParts.length > 3) return; const pathname = hostParts.length === 3 ? `${hostParts[0]}/${uri.pathname}` : uri.pathname; - const [part1, part2, part3] = pathname.split('/').filter(Boolean).map((l) => decodeURI(l)); + const [part1, part2, part3] = pathname.split('/').filter(Boolean).map((part) => decodeURI(part)); const params = Object.fromEntries(uri.searchParams); let hash: string | undefined; diff --git a/src/global/actions/api/reactions.ts b/src/global/actions/api/reactions.ts index 4beb0334a..8c109ba61 100644 --- a/src/global/actions/api/reactions.ts +++ b/src/global/actions/api/reactions.ts @@ -265,7 +265,8 @@ addActionHandler('sendWatchingEmojiInteraction', (global, actions, payload) => { const chat = selectChat(global, chatId); - if (!chat || !global.activeEmojiInteractions?.some((l) => l.id === id) || chatId === global.currentUserId) { + if (!chat || !global.activeEmojiInteractions?.some((interaction) => interaction.id === id) + || chatId === global.currentUserId) { return undefined; } diff --git a/src/global/actions/ui/calls.ts b/src/global/actions/ui/calls.ts index d0c0ff492..9b53a59f5 100644 --- a/src/global/actions/ui/calls.ts +++ b/src/global/actions/ui/calls.ts @@ -53,14 +53,14 @@ export const initializeSoundsForSafari = () => { ringing: ringingAudio, }; - initializationPromise = Promise.all(Object.values(sounds).map((l) => { - l.muted = true; - l.volume = 0.0001; - return l.play().then(() => { - l.pause(); - l.volume = 1; - l.currentTime = 0; - l.muted = false; + initializationPromise = Promise.all(Object.values(sounds).map((sound) => { + sound.muted = true; + sound.volume = 0.0001; + return sound.play().then(() => { + sound.pause(); + sound.volume = 1; + sound.currentTime = 0; + sound.muted = false; }); })).then(() => { initializationPromise = undefined; diff --git a/src/global/helpers/reactions.ts b/src/global/helpers/reactions.ts index 04096c257..c22bd71c9 100644 --- a/src/global/helpers/reactions.ts +++ b/src/global/helpers/reactions.ts @@ -18,7 +18,7 @@ export function checkIfHasUnreadReactions(global: GlobalState, reactions: ApiRea } export function areReactionsEmpty(reactions: ApiReactions) { - return !reactions.results.some((l) => l.count > 0); + return !reactions.results.some(({ count }) => count > 0); } export function isSameReaction(first?: ApiReaction, second?: ApiReaction) { diff --git a/src/global/reducers/calls.ts b/src/global/reducers/calls.ts index 153bef78d..5775c81ca 100644 --- a/src/global/reducers/calls.ts +++ b/src/global/reducers/calls.ts @@ -17,7 +17,7 @@ export function updateGroupCall( ...global.groupCalls.byId[groupCallId]?.participants, ...groupCallUpdate.participants, }); - const filtered = unfiltered.filter((l) => !l.isLeft); + const filtered = unfiltered.filter(({ isLeft }) => isLeft); const participants = filtered.reduce((acc: Record, el) => { acc[el.id] = el; return acc; diff --git a/src/lib/gramjs/client/MockClient.ts b/src/lib/gramjs/client/MockClient.ts index 58f5fdb84..4f8c0e833 100644 --- a/src/lib/gramjs/client/MockClient.ts +++ b/src/lib/gramjs/client/MockClient.ts @@ -328,7 +328,7 @@ class TelegramClient { if (!id) return undefined; - return this.peers.findIndex((l) => l.peer.id.toString() === id.toString()); + return this.peers.findIndex((localPeer) => localPeer.peer.id.toString() === id.toString()); } private getPeer(peer: Api.TypeInputPeer) { @@ -346,11 +346,11 @@ class TelegramClient { } private getChats() { - return this.peers.filter((l) => !(l.peer instanceof Api.User)).map((l) => l.peer); + return this.peers.filter(({ peer }) => !(peer instanceof Api.User)).map(({ peer }) => peer); } private getUsers() { - return this.peers.filter((l) => l.peer instanceof Api.User).map((l) => l.peer); + return this.peers.filter(({ peer }) => peer instanceof Api.User).map(({ peer }) => peer); } } diff --git a/src/lib/gramjs/client/downloadFile.ts b/src/lib/gramjs/client/downloadFile.ts index d6e31cb74..ae16525ba 100644 --- a/src/lib/gramjs/client/downloadFile.ts +++ b/src/lib/gramjs/client/downloadFile.ts @@ -159,7 +159,7 @@ async function downloadFile2( // Pick the least busy foreman // For some reason, fresh connections give out a higher speed for the first couple of seconds // I have no idea why, but this may speed up the download of small files - const activeCounts = foremans.map((l) => l.activeWorkers); + const activeCounts = foremans.map(({ activeWorkers }) => activeWorkers); let currentForemanIndex = activeCounts.indexOf(Math.min(...activeCounts)); // Used for files with unknown size and for manual cancellations let hasEnded = false; diff --git a/src/lib/gramjs/client/uploadFile.ts b/src/lib/gramjs/client/uploadFile.ts index f140df7a3..7df7805f5 100644 --- a/src/lib/gramjs/client/uploadFile.ts +++ b/src/lib/gramjs/client/uploadFile.ts @@ -48,7 +48,7 @@ export async function uploadFile( // Pick the least busy foreman // For some reason, fresh connections give out a higher speed for the first couple of seconds // I have no idea why, but this may speed up the download of small files - const activeCounts = foremans.map((l) => l.activeWorkers); + const activeCounts = foremans.map(({ activeWorkers }) => activeWorkers); let currentForemanIndex = activeCounts.indexOf(Math.min(...activeCounts)); let progress = 0; diff --git a/src/util/dateFormat.ts b/src/util/dateFormat.ts index a930432f6..78b332ffb 100644 --- a/src/util/dateFormat.ts +++ b/src/util/dateFormat.ts @@ -159,7 +159,7 @@ export function formatTimeDuration(lang: LangFn, duration: number, showLast = 2) } // TODO In arabic we don't use "," as delimiter rather we use "and" each time - return out.map((l) => lang(l.type, l.duration, 'i')).join(', '); + return out.map((part) => lang(part.type, part.duration, 'i')).join(', '); } export function formatHumanDate( diff --git a/src/util/langProvider.ts b/src/util/langProvider.ts index d2ac3aa83..37d7ecbb3 100644 --- a/src/util/langProvider.ts +++ b/src/util/langProvider.ts @@ -161,7 +161,7 @@ export async function setLanguage(langCode: LangCode, callback?: NoneToVoidFunct document.documentElement.lang = langCode; const { languages, timeFormat } = getGlobal().settings.byKey; - const langInfo = languages?.find((l) => l.langCode === langCode); + const langInfo = languages?.find((lang) => lang.langCode === langCode); getTranslation.isRtl = Boolean(langInfo?.rtl); getTranslation.code = langCode.replace('-raw', '') as LangCode; getTranslation.langName = langInfo?.nativeName;