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

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

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

4
src/lib/appManagers/appImManager.ts

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

4
src/scss/partials/_rightSidebar.scss

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

Loading…
Cancel
Save