From 1139a73fb5365ce1ab6ea9c215fcedea8d0d7c47 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Tue, 26 Jan 2021 03:26:28 +0200 Subject: [PATCH] Fix search reset Fix search in media viewer Maybe fixed blinking in media viewer --- src/components/appMediaViewer.ts | 16 +++++++++++----- src/components/chat/bubbles.ts | 8 ++++++-- src/components/sidebarLeft/index.ts | 2 +- src/lib/appManagers/appMessagesManager.ts | 2 +- src/scss/partials/_mediaViewer.scss | 5 +++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/components/appMediaViewer.ts b/src/components/appMediaViewer.ts index 739f9441..e768f0c6 100644 --- a/src/components/appMediaViewer.ts +++ b/src/components/appMediaViewer.ts @@ -895,17 +895,22 @@ class AppMediaViewerBase = Promise.resolve(); if(useContainerAsTarget) { const cacheContext = appPhotosManager.getCacheContext(media); + let img: HTMLImageElement; if(cacheContext.downloaded) { - const img = new Image(); + img = new Image(); img.src = cacheContext.url; - container.append(img); } else { const gotThumb = appPhotosManager.getStrippedThumbIfNeeded(media); if(gotThumb) { thumbPromise = gotThumb.loadPromise; - container.append(gotThumb.image); + img = gotThumb.image; } } + + if(img) { + img.classList.add('thumbnail'); + container.append(img); + } } const size = appPhotosManager.setAttachmentSize(media, container, maxWidth, maxHeight, mediaSizes.isMobile ? false : true); @@ -1106,6 +1111,7 @@ class AppMediaViewerBase { - /* if(DEBUG) { + if(DEBUG) { this.log('loaded more media by maxId:', maxId, value, older, this.reverse); - } */ + } if(value.next_rate) { this.searchContext.nextRate = value.next_rate; diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 823b41f5..2215359a 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -738,16 +738,20 @@ export default class ChatBubbles { ids.forEach(id => { let withTail = this.bubbles[id].classList.contains('with-media-tail'); - let str = '.album-item img, .album-item video, .preview img, .preview video, '; + let str = '.album-item video, .album-item img, .preview video, .preview img, '; if(withTail) { str += '.bubble__media-container'; } else { - str += '.attachment img, .attachment video'; + str += '.attachment video, .attachment img'; } let elements = this.bubbles[id].querySelectorAll(str) as NodeListOf; + const parents: Set = new Set(); Array.from(elements).forEach((element: HTMLElement) => { let albumItem = findUpClassName(element, 'album-item'); + const parent = albumItem || element.parentElement; + if(parents.has(parent)) return; + parents.add(parent); targets.push({ element, mid: +albumItem?.dataset.mid || id, diff --git a/src/components/sidebarLeft/index.ts b/src/components/sidebarLeft/index.ts index 6f0e7d1b..83978ccb 100644 --- a/src/components/sidebarLeft/index.ts +++ b/src/components/sidebarLeft/index.ts @@ -401,8 +401,8 @@ export class AppSidebarLeft extends SidebarSlider { if(hideNewBtnMenuTimeout) clearTimeout(hideNewBtnMenuTimeout); if(id === 0) { + searchSuper.selectTab(0, false); this.inputSearch.onClearClick(); - resetSearch(); hideNewBtnMenuTimeout = window.setTimeout(() => { hideNewBtnMenuTimeout = 0; this.newBtnMenu.classList.remove('is-hidden'); diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index c39057b9..ca351474 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -2933,7 +2933,7 @@ export class AppMessagesManager { if(!peerId) peerId = 0; if(!query) query = ''; if(!inputFilter) inputFilter = {_: 'inputMessagesFilterEmpty'}; - if(!limit) limit = 20; + if(limit === undefined) limit = 20; if(!nextRate) nextRate = 0; if(!backLimit) backLimit = 0; diff --git a/src/scss/partials/_mediaViewer.scss b/src/scss/partials/_mediaViewer.scss index 74798967..1e417e85 100644 --- a/src/scss/partials/_mediaViewer.scss +++ b/src/scss/partials/_mediaViewer.scss @@ -257,6 +257,7 @@ object-fit: cover; //object-fit: contain; opacity: 1; + transition: var(--open-duration) opacity; /* border-radius: inherit; transition: var(--open-duration) border-radius; */ @@ -350,7 +351,6 @@ &.hiding { img, video { - transition: var(--open-duration) opacity; opacity: 0; } } @@ -360,9 +360,10 @@ &-aspecter { width: 100%; height: 100%; - transform: scale(1); + transform: scale3d(1, 1, 1); //overflow: hidden; // WARNING position: absolute; + border-radius: 0; display: flex; align-items: center;