Fix gifs search repeat
This commit is contained in:
parent
f0cdecc5b8
commit
88862f22df
@ -23,6 +23,7 @@ export default class AppGifsTab implements SliderTab {
|
|||||||
private lazyLoadQueue: LazyLoadQueue;
|
private lazyLoadQueue: LazyLoadQueue;
|
||||||
|
|
||||||
private nextOffset = '';
|
private nextOffset = '';
|
||||||
|
private loadedAll = false;
|
||||||
|
|
||||||
private gifBotPeerID: number;
|
private gifBotPeerID: number;
|
||||||
private masonry: GifsMasonry;
|
private masonry: GifsMasonry;
|
||||||
@ -73,6 +74,7 @@ export default class AppGifsTab implements SliderTab {
|
|||||||
private reset() {
|
private reset() {
|
||||||
this.searchPromise = null;
|
this.searchPromise = null;
|
||||||
this.nextOffset = '';
|
this.nextOffset = '';
|
||||||
|
this.loadedAll = false;
|
||||||
this.lazyLoadQueue.clear();
|
this.lazyLoadQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +93,7 @@ export default class AppGifsTab implements SliderTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async search(query: string, newSearch = true) {
|
public async search(query: string, newSearch = true) {
|
||||||
if(this.searchPromise) return;
|
if(this.searchPromise || this.loadedAll) return;
|
||||||
|
|
||||||
if(!this.gifBotPeerID) {
|
if(!this.gifBotPeerID) {
|
||||||
this.gifBotPeerID = (await appUsersManager.resolveUsername('gif')).id;
|
this.gifBotPeerID = (await appUsersManager.resolveUsername('gif')).id;
|
||||||
@ -111,11 +113,15 @@ export default class AppGifsTab implements SliderTab {
|
|||||||
this.gifsDiv.innerHTML = '';
|
this.gifsDiv.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
results.forEach((result) => {
|
if(results.length) {
|
||||||
if(result._ === 'botInlineMediaResult' && result.document) {
|
results.forEach((result) => {
|
||||||
this.masonry.add(result.document, ANIMATIONGROUP, this.lazyLoadQueue);
|
if(result._ === 'botInlineMediaResult' && result.document) {
|
||||||
}
|
this.masonry.add(result.document, ANIMATIONGROUP, this.lazyLoadQueue);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.loadedAll = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.scrollable.onScroll();
|
this.scrollable.onScroll();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user