Scroll next user avatars in media viewer
Don't save chat position if scrolled down
This commit is contained in:
parent
b42a797ac2
commit
29b358c27e
@ -1546,13 +1546,13 @@ export class AppMediaViewerAvatar extends AppMediaViewerBase<'', 'delete', AppMe
|
|||||||
return this.loadMediaPromiseDown = promise;
|
return this.loadMediaPromiseDown = promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
public async openMedia(photoId: string, target?: HTMLElement, fromRight = 0) {
|
public async openMedia(photoId: string, target?: HTMLElement, fromRight = 0, prevTargets?: AppMediaViewerAvatarTargetType[], nextTargets?: AppMediaViewerAvatarTargetType[]) {
|
||||||
if(this.setMoverPromise) return this.setMoverPromise;
|
if(this.setMoverPromise) return this.setMoverPromise;
|
||||||
|
|
||||||
const photo = appPhotosManager.getPhoto(photoId);
|
const photo = appPhotosManager.getPhoto(photoId);
|
||||||
|
|
||||||
this.currentPhotoId = photo.id;
|
this.currentPhotoId = photo.id;
|
||||||
|
|
||||||
return super._openMedia(photo, photo.date, this.peerId, fromRight, target, false);
|
return super._openMedia(photo, photo.date, this.peerId, fromRight, target, false, prevTargets, nextTargets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { attachClickEvent, cancelEvent } from "../helpers/dom";
|
|||||||
import AppMediaViewer, { AppMediaViewerAvatar } from "./appMediaViewer";
|
import AppMediaViewer, { AppMediaViewerAvatar } from "./appMediaViewer";
|
||||||
import { Message, Photo } from "../layer";
|
import { Message, Photo } from "../layer";
|
||||||
import appPeersManager from "../lib/appManagers/appPeersManager";
|
import appPeersManager from "../lib/appManagers/appPeersManager";
|
||||||
|
import appPhotosManager from "../lib/appManagers/appPhotosManager";
|
||||||
//import type { LazyLoadQueueIntersector } from "./lazyLoadQueue";
|
//import type { LazyLoadQueueIntersector } from "./lazyLoadQueue";
|
||||||
|
|
||||||
const onAvatarUpdate = (peerId: number) => {
|
const onAvatarUpdate = (peerId: number) => {
|
||||||
@ -25,7 +26,7 @@ rootScope.on('avatar_update', onAvatarUpdate);
|
|||||||
rootScope.on('peer_title_edit', onAvatarUpdate);
|
rootScope.on('peer_title_edit', onAvatarUpdate);
|
||||||
|
|
||||||
export async function openAvatarViewer(target: HTMLElement, peerId: number, middleware: () => boolean, message?: any, prevTargets?: {element: HTMLElement, item: string | Message.messageService}[], nextTargets?: typeof prevTargets) {
|
export async function openAvatarViewer(target: HTMLElement, peerId: number, middleware: () => boolean, message?: any, prevTargets?: {element: HTMLElement, item: string | Message.messageService}[], nextTargets?: typeof prevTargets) {
|
||||||
const photo = await appProfileManager.getFullPhoto(peerId);
|
let photo = await appProfileManager.getFullPhoto(peerId);
|
||||||
if(!middleware() || !photo) {
|
if(!middleware() || !photo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,7 +85,16 @@ export async function openAvatarViewer(target: HTMLElement, peerId: number, midd
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(photo) {
|
if(photo) {
|
||||||
new AppMediaViewerAvatar(peerId).openMedia(photo.id, getTarget());
|
if(typeof(message) === 'string') {
|
||||||
|
photo = appPhotosManager.getPhoto(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const f = (arr: typeof prevTargets) => arr.map(el => ({
|
||||||
|
element: el.element,
|
||||||
|
photoId: el.item as string
|
||||||
|
}));
|
||||||
|
|
||||||
|
new AppMediaViewerAvatar(peerId).openMedia(photo.id, getTarget(), undefined, prevTargets ? f(prevTargets) : undefined, nextTargets ? f(nextTargets) : undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,8 +1090,8 @@ export default class AppSharedMediaTab extends SliderSuperTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadSidebarMedia(single: boolean) {
|
public loadSidebarMedia(single: boolean, justLoad = false) {
|
||||||
this.searchSuper.load(single);
|
this.searchSuper.load(single, justLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpenAfterTimeout() {
|
onOpenAfterTimeout() {
|
||||||
|
@ -249,12 +249,20 @@ export class AppImManager {
|
|||||||
const key = chat.peerId + (chat.threadId ? '_' + chat.threadId : '');
|
const key = chat.peerId + (chat.threadId ? '_' + chat.threadId : '');
|
||||||
|
|
||||||
const chatPositions = sessionStorage.getFromCache('chatPositions');
|
const chatPositions = sessionStorage.getFromCache('chatPositions');
|
||||||
chatPositions[key] = {
|
if(!(chat.bubbles.scrollable.getDistanceToEnd() <= 16 && chat.bubbles.scrollable.loadedAll.bottom)) {
|
||||||
mids: getObjectKeysAndSort(chat.bubbles.bubbles, 'desc'),
|
const position = {
|
||||||
top
|
mids: getObjectKeysAndSort(chat.bubbles.bubbles, 'desc'),
|
||||||
} as ChatSavedPosition;
|
top
|
||||||
|
};
|
||||||
|
|
||||||
this.log('saved chat position:', chatPositions[key]);
|
chatPositions[key] = position;
|
||||||
|
|
||||||
|
this.log('saved chat position:', position);
|
||||||
|
} else {
|
||||||
|
delete chatPositions[key];
|
||||||
|
|
||||||
|
this.log('deleted chat position');
|
||||||
|
}
|
||||||
|
|
||||||
sessionStorage.set({chatPositions}, true);
|
sessionStorage.set({chatPositions}, true);
|
||||||
//}
|
//}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user