From 46ff2ee5fcffabb63d5ebc25e201c4e6df092e6c Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 27 Aug 2021 03:01:22 +0300 Subject: [PATCH] Blur sending thumb if photo isn't fit Do not show 'Copy' if message is equal to link --- src/components/chat/contextMenu.ts | 2 +- src/components/wrappers.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index 4c5d6343..70eb60e5 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -218,7 +218,7 @@ export default class ChatContextMenu { icon: 'copy', text: 'Copy', onClick: this.onCopyClick, - verify: () => !!this.message.message && !this.isTextSelected + verify: () => !!this.message.message && !this.isTextSelected && (!this.isAnchorTarget || this.message.message !== this.target.innerText) }, { icon: 'copy', text: 'Chat.CopySelectedText', diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index dd95c463..265bde5b 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -43,6 +43,7 @@ import { attachClickEvent, simulateClickEvent } from '../helpers/dom/clickEvent' import isInDOM from '../helpers/dom/isInDOM'; import lottieLoader from '../lib/lottieLoader'; import { clearBadCharsAndTrim } from '../helpers/cleanSearchText'; +import blur from '../helpers/blur'; const MAX_VIDEO_AUTOPLAY_SIZE = 50 * 1024 * 1024; // 50 MB @@ -707,7 +708,7 @@ export function wrapDocument({message, withTime, fontWeight, voiceAsMusic, showS return img; } */ -export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withTail, isOut, lazyLoadQueue, middleware, size, withoutPreloader, loadPromises, noAutoDownload, noBlur, noThumb, noFadeIn}: { +export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withTail, isOut, lazyLoadQueue, middleware, size, withoutPreloader, loadPromises, noAutoDownload, noBlur, noThumb, noFadeIn, blurAfter}: { photo: MyPhoto | MyDocument, message?: any, container: HTMLElement, @@ -724,6 +725,7 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT noBlur?: boolean, noThumb?: boolean, noFadeIn?: boolean, + blurAfter?: boolean, }) { if(!((photo as MyPhoto).sizes || (photo as MyDocument).thumbs)) { if(boxWidth && boxHeight && !size && photo._ === 'document') { @@ -797,6 +799,7 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT noAutoDownload, noBlur, noThumb: true, + blurAfter: true //noFadeIn: true }); const thumbImage = res.images.full; @@ -851,10 +854,20 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT return promise; }; + const renderOnLoad = (url: string) => { + return renderImageWithFadeIn(container, image, url, needFadeIn, aspecter, thumbImage); + }; + const onLoad = (): Promise => { if(middleware && !middleware()) return Promise.resolve(); - return renderImageWithFadeIn(container, image, cacheContext.url, needFadeIn, aspecter, thumbImage); + if(blurAfter) { + return blur(cacheContext.url, 12).then(url => { + return renderOnLoad(url); + }); + } + + return renderOnLoad(cacheContext.url); }; let loadPromise: Promise;