Browse Source

Fix loading next items in empty media viewer

master
morethanwords 3 years ago
parent
commit
ac8e36a20b
  1. 13
      src/components/appMediaViewerBase.ts
  2. 2
      src/components/avatar.ts
  3. 2
      src/helpers/avatarListLoader.ts

13
src/components/appMediaViewerBase.ts

@ -245,6 +245,11 @@ export default class AppMediaViewerBase< @@ -245,6 +245,11 @@ export default class AppMediaViewerBase<
// * constructing html end
this.listLoader.onLoadedMore = () => {
this.buttons.prev.classList.toggle('hide', !this.listLoader.previous.length);
this.buttons.next.classList.toggle('hide', !this.listLoader.next.length);
};
this.setNewMover();
}
@ -1173,9 +1178,11 @@ export default class AppMediaViewerBase< @@ -1173,9 +1178,11 @@ export default class AppMediaViewerBase<
} */
}
/* if(this.nextTargets.length < 10 && this.loadMore) {
this.loadMore();
} */
if(this.listLoader.next.length < 10) {
setTimeout(() => {
this.listLoader.load(true);
}, 0);
}
//if(prevTarget && (!prevTarget.parentElement || !this.isElementVisible(this.targetContainer, prevTarget))) prevTarget = null;
//if(nextTarget && (!nextTarget.parentElement || !this.isElementVisible(this.targetContainer, nextTarget))) nextTarget = null;

2
src/components/avatar.ts

@ -101,7 +101,7 @@ export async function openAvatarViewer( @@ -101,7 +101,7 @@ export async function openAvatarViewer(
}
if(photo) {
if(!isObject(message)) {
if(!isObject(message) && message) {
photo = appPhotosManager.getPhoto(message);
}

2
src/helpers/avatarListLoader.ts

@ -17,7 +17,7 @@ export default class AvatarListLoader<Item extends {photoId: Photo.photo['id']}> @@ -17,7 +17,7 @@ export default class AvatarListLoader<Item extends {photoId: Photo.photo['id']}>
loadMore: (anchor, older, loadCount) => {
if(this.peerId.isAnyChat() || !older) return Promise.resolve({count: 0, items: []}); // ! это значит, что открыло аватар чата, но следующих фотографий нет.
const maxId = anchor?.photoId;
const maxId = anchor?.photoId || this.current?.photoId;
return appPhotosManager.getUserPhotos(this.peerId, maxId, loadCount).then(value => {
const items = value.photos.map(photoId => {
return {element: null as HTMLElement, photoId} as any;

Loading…
Cancel
Save