fix max reached condition

This commit is contained in:
Nicolas Constant 2020-06-24 20:25:37 -04:00
parent 08dd0025c9
commit e3a7239522
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
4 changed files with 23 additions and 13 deletions

View File

@ -15,12 +15,13 @@ import { BrowseBase } from './browse-base';
export abstract class TimelineBase extends BrowseBase {
isLoading = true;
protected maxReached = false;
protected lastCallReachedMax = false;
isThread = false;
displayError: string;
hasContentWarnings = false;
timelineLoadingMode: TimeLineModeEnum = TimeLineModeEnum.OnTop;
timelineLoadingMode: TimeLineModeEnum = TimeLineModeEnum.OnTop;
protected account: AccountInfo;
protected websocketStreaming: StreamingWrapper;
@ -44,8 +45,8 @@ export abstract class TimelineBase extends BrowseBase {
protected readonly toolsService: ToolsService,
protected readonly notificationService: NotificationService,
protected readonly mastodonService: MastodonWrapperService) {
super();
}
super();
}
abstract ngOnInit();
abstract ngOnDestroy();
@ -80,11 +81,17 @@ export abstract class TimelineBase extends BrowseBase {
return;
}
for (const s of status) {
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
if (status) {
for (const s of status) {
let cwPolicy = this.toolsService.checkContentWarning(s);
const wrapper = new StatusWrapper(cwPolicy.status, this.account, cwPolicy.applyCw, cwPolicy.hide);
this.statuses.push(wrapper);
}
}
if(this.lastCallReachedMax){
this.maxReached = true;
}
})
.catch((err: HttpErrorResponse) => {
this.scrolledErrorOccured = true;
@ -101,7 +108,7 @@ export abstract class TimelineBase extends BrowseBase {
}
applyGoToTop(): boolean {
this.statusProcessOnGoToTop();
this.statusProcessOnGoToTop();
const stream = this.statustream.nativeElement as HTMLElement;
setTimeout(() => {

View File

@ -47,7 +47,8 @@ export class BookmarksComponent extends TimelineBase {
private reset() {
this.isLoading = true;
this.statuses.length = 0;
this.maxReached = false;
this.maxReached = false;
this.lastCallReachedMax = false;
this.maxId = null;
}
@ -78,7 +79,7 @@ export class BookmarksComponent extends TimelineBase {
this.maxId = result.max_id;
if(!this.maxId){
this.maxReached = true;
this.lastCallReachedMax = true;
}
return statuses;

View File

@ -46,6 +46,7 @@ export class FavoritesComponent extends TimelineBase {
this.isLoading = true;
this.statuses.length = 0;
this.maxReached = false;
this.lastCallReachedMax = false;
this.maxId = null;
}
@ -77,7 +78,7 @@ export class FavoritesComponent extends TimelineBase {
this.maxId = result.max_id;
if(!this.maxId){
this.maxReached = true;
this.lastCallReachedMax = true;
}
return statuses;

View File

@ -267,6 +267,7 @@ export class StreamStatusesComponent extends TimelineBase {
if (this.streamPositionnedAtTop && this.statuses.length > 3 * this.streamingService.nbStatusPerIteration) {
this.statuses.length = 2 * this.streamingService.nbStatusPerIteration;
this.maxReached = false;
this.lastCallReachedMax = false;
}
if (this.bufferStream.length > 3 * this.streamingService.nbStatusPerIteration) {