From 73a2d20712c6a9ef370dda28a8b466f89ba931ce Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Tue, 26 Jul 2022 08:20:30 +0200 Subject: [PATCH] omg3 --- .env | 4 ++-- src/components/appMediaViewer.ts | 12 +++++++----- src/components/appSelectPeers.ts | 4 ++-- src/components/sidebarLeft/tabs/includedChats.ts | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 57990215..435c2ba6 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ API_ID=1025907 API_HASH=452b0359b988148995f22ff0f4229750 VERSION=1.5.0 -VERSION_FULL=1.5.0 (213) -BUILD=213 +VERSION_FULL=1.5.0 (214) +BUILD=214 diff --git a/src/components/appMediaViewer.ts b/src/components/appMediaViewer.ts index 24effb99..73021873 100644 --- a/src/components/appMediaViewer.ts +++ b/src/components/appMediaViewer.ts @@ -7,6 +7,7 @@ import MEDIA_MIME_TYPES_SUPPORTED from "../environment/mediaMimeTypesSupport"; import cancelEvent from "../helpers/dom/cancelEvent"; import { attachClickEvent, detachClickEvent } from "../helpers/dom/clickEvent"; +import findUpTag from "../helpers/dom/findUpTag"; import setInnerHTML from "../helpers/dom/setInnerHTML"; import mediaSizes from "../helpers/mediaSizes"; import SearchListLoader from "../helpers/searchListLoader"; @@ -129,8 +130,9 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet attachClickEvent(this.author.container, this.onAuthorClick); const onCaptionClick = (e: MouseEvent) => { - if(e.target instanceof HTMLAnchorElement) { // close viewer if it's t.me/ redirect - const onclick = (e.target as HTMLElement).getAttribute('onclick'); + const a = findUpTag(e.target, 'A'); + if(a instanceof HTMLAnchorElement) { // close viewer if it's t.me/ redirect + const onclick = a.getAttribute('onclick'); if(!onclick || onclick.includes('showMaskedAlert')) { return; } @@ -138,15 +140,15 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet cancelEvent(e); this.close().then(() => { - detachClickEvent(this.content.caption, onCaptionClick, {capture: true}); - (e.target as HTMLAnchorElement).click(); + this.content.caption.removeEventListener('click', onCaptionClick, {capture: true}); + a.click(); }); return false; } }; - attachClickEvent(this.content.caption, onCaptionClick, {capture: true}); + this.content.caption.addEventListener('click', onCaptionClick, {capture: true}); } /* public close(e?: MouseEvent) { diff --git a/src/components/appSelectPeers.ts b/src/components/appSelectPeers.ts index 34716582..ccf91591 100644 --- a/src/components/appSelectPeers.ts +++ b/src/components/appSelectPeers.ts @@ -21,7 +21,7 @@ import debounce from "../helpers/schedulers/debounce"; import windowSize from "../helpers/windowSize"; import type { IsPeerType } from "../lib/appManagers/appPeersManager"; import { generateDelimiter, SettingSection } from "./sidebarLeft"; -import { attachClickEvent } from "../helpers/dom/clickEvent"; +import { attachClickEvent, simulateClickEvent } from "../helpers/dom/clickEvent"; import filterUnique from "../helpers/array/filterUnique"; import indexOfAndSplice from "../helpers/array/indexOfAndSplice"; import safeAssign from "../helpers/object/safeAssign"; @@ -187,7 +187,7 @@ export default class AppSelectPeers { if(!li) { this.remove(peerId.toPeerId()); } else { - li.click(); + simulateClickEvent(li); } }); diff --git a/src/components/sidebarLeft/tabs/includedChats.ts b/src/components/sidebarLeft/tabs/includedChats.ts index 9623f9c1..98bc3da8 100644 --- a/src/components/sidebarLeft/tabs/includedChats.ts +++ b/src/components/sidebarLeft/tabs/includedChats.ts @@ -19,7 +19,7 @@ import copy from "../../../helpers/object/copy"; import forEachReverse from "../../../helpers/array/forEachReverse"; import setInnerHTML from "../../../helpers/dom/setInnerHTML"; import wrapEmojiText from "../../../lib/richTextProcessor/wrapEmojiText"; -import { attachClickEvent } from "../../../helpers/dom/clickEvent"; +import { attachClickEvent, simulateClickEvent } from "../../../helpers/dom/clickEvent"; export default class AppIncludedChatsTab extends SliderSuperTab { private editFolderTab: AppEditFolderTab; @@ -251,7 +251,7 @@ export default class AppIncludedChatsTab extends SliderSuperTab { for(const flag in filter.pFlags) { // @ts-ignore if(details.hasOwnProperty(flag) && !!filter.pFlags[flag]) { - (categoriesSection.content.querySelector(`[data-peer-id="${flag}"]`) as HTMLElement).click(); + simulateClickEvent(categoriesSection.content.querySelector(`[data-peer-id="${flag}"]`) as HTMLElement); } } }