Browse Source

Preload tabs in shared media

Fix jumping empty context text in sidebar
master
Eduard Kuzmenko 4 years ago
parent
commit
5e13c8bd91
  1. 3
      src/components/chat/chat.ts
  2. 15
      src/components/sidebarRight/tabs/sharedMedia.ts
  3. 4
      src/lib/appManagers/appImManager.ts
  4. 4
      src/scss/partials/_rightSidebar.scss

3
src/components/chat/chat.ts

@ -165,6 +165,9 @@ export default class Chat extends EventListenerBase<{
appSidebarRight.sharedMediaTab.setLoadMutex(this.setPeerPromise); appSidebarRight.sharedMediaTab.setLoadMutex(this.setPeerPromise);
appSidebarRight.sharedMediaTab.loadSidebarMedia(true); appSidebarRight.sharedMediaTab.loadSidebarMedia(true);
this.setPeerPromise.then(() => {
appSidebarRight.sharedMediaTab.loadSidebarMedia(false);
});
return this.setPeerPromise; return this.setPeerPromise;
} }

15
src/components/sidebarRight/tabs/sharedMedia.ts

@ -314,6 +314,7 @@ export default class AppSharedMediaTab implements SliderTab {
const scrollBarWidth = container.offsetWidth - container.clientWidth; const scrollBarWidth = container.offsetWidth - container.clientWidth;
container.style.overflowY = 'hidden'; container.style.overflowY = 'hidden';
container.style.paddingRight = `${scrollBarWidth}px`; container.style.paddingRight = `${scrollBarWidth}px`;
this.contentContainer.classList.add('sliding');
} }
}; };
@ -322,6 +323,7 @@ export default class AppSharedMediaTab implements SliderTab {
const container = this.scroll.container; const container = this.scroll.container;
container.style.overflowY = ''; container.style.overflowY = '';
container.style.paddingRight = '0'; container.style.paddingRight = '0';
this.contentContainer.classList.remove('sliding');
}; };
public filterMessagesByType(ids: number[], type: SharedMediaType) { public filterMessagesByType(ids: number[], type: SharedMediaType) {
@ -688,7 +690,7 @@ export default class AppSharedMediaTab implements SliderTab {
const peerId = this.peerId; const peerId = this.peerId;
let typesToLoad = single ? [this.sharedMediaType] : this.sharedMediaTypes; let typesToLoad = single ? [this.sharedMediaType] : this.sharedMediaTypes.filter(t => t !== this.sharedMediaType);
typesToLoad = typesToLoad.filter(type => !this.loadedAllMedia[type] typesToLoad = typesToLoad.filter(type => !this.loadedAllMedia[type]
|| this.usedFromHistory[type] < this.historiesStorage[peerId][type].length); || this.usedFromHistory[type] < this.historiesStorage[peerId][type].length);
@ -769,10 +771,13 @@ export default class AppSharedMediaTab implements SliderTab {
this.loadSidebarMediaPromises[type].then(() => { this.loadSidebarMediaPromises[type].then(() => {
setTimeout(() => { setTimeout(() => {
this.log('will preload more'); this.log('will preload more');
this.loadSidebarMedia(true, true).then(() => { const promise = this.loadSidebarMedia(true, true);
this.log('preloaded more'); if(promise) {
this.scroll.checkForTriggers(); promise.then(() => {
}); this.log('preloaded more');
this.scroll.checkForTriggers();
});
}
}, 0); }, 0);
}); });
} }

4
src/lib/appManagers/appImManager.ts

@ -400,6 +400,10 @@ export class AppImManager {
appSidebarRight.sharedMediaTab.setPeer(this.chat.peerId); appSidebarRight.sharedMediaTab.setPeer(this.chat.peerId);
appSidebarRight.sharedMediaTab.loadSidebarMedia(true); appSidebarRight.sharedMediaTab.loadSidebarMedia(true);
appSidebarRight.sharedMediaTab.fillProfileElements(); appSidebarRight.sharedMediaTab.fillProfileElements();
setTimeout(() => {
appSidebarRight.sharedMediaTab.loadSidebarMedia(false);
});
} }
setTimeout(() => { setTimeout(() => {

4
src/scss/partials/_rightSidebar.scss

@ -116,6 +116,10 @@
min-height: calc((var(--vh, 1vh) * 100) - 100% - 60px); min-height: calc((var(--vh, 1vh) * 100) - 100% - 60px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
&.sliding {
max-height: calc((var(--vh, 1vh) * 100) - 100% - 60px);
}
} }
} }

Loading…
Cancel
Save