fix follower pagination
This commit is contained in:
parent
34dcc3050a
commit
9a8f24462c
@ -18,7 +18,7 @@ export class UserFollowsComponent implements OnInit, OnDestroy {
|
||||
private _type: 'follows' | 'followers';
|
||||
private _currentAccount: string;
|
||||
|
||||
private sinceId: string;
|
||||
private maxId: string;
|
||||
isLoading: boolean = true;
|
||||
accounts: Account[] = [];
|
||||
|
||||
@ -97,7 +97,7 @@ export class UserFollowsComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
.then((result: FollowingResult) => {
|
||||
console.warn(result);
|
||||
this.sinceId = result.sinceId;
|
||||
this.maxId = result.maxId;
|
||||
this.accounts = result.follows;
|
||||
})
|
||||
.catch(err => {
|
||||
@ -119,9 +119,9 @@ export class UserFollowsComponent implements OnInit, OnDestroy {
|
||||
this.toolsService.findAccount(currentAccount, this._currentAccount)
|
||||
.then((acc: Account) => {
|
||||
if (this._type === 'followers') {
|
||||
return this.mastodonService.getFollowers(currentAccount, acc.id, this.sinceId, null);
|
||||
return this.mastodonService.getFollowers(currentAccount, acc.id, this.maxId, null);
|
||||
} else if (this._type === 'follows') {
|
||||
return this.mastodonService.getFollowing(currentAccount, acc.id, this.sinceId, null);
|
||||
return this.mastodonService.getFollowing(currentAccount, acc.id, this.maxId, null);
|
||||
} else {
|
||||
throw Error('not implemented');
|
||||
}
|
||||
@ -135,11 +135,15 @@ export class UserFollowsComponent implements OnInit, OnDestroy {
|
||||
this.maxReached = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.sinceId = result.sinceId;
|
||||
|
||||
for (let a of accounts) {
|
||||
this.accounts.push(a);
|
||||
}
|
||||
|
||||
this.maxId = result.maxId;
|
||||
if(!this.maxId) {
|
||||
this.maxReached = true;
|
||||
}
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.scrolledErrorOccured = true;
|
||||
|
@ -482,9 +482,9 @@ export class MastodonService {
|
||||
const link = res.headers.get('Link');
|
||||
let lastId = null;
|
||||
if (link) {
|
||||
const sinceId = link.split('since_id=')[1];
|
||||
const maxId = link.split('max_id=')[1];
|
||||
if (maxId) {
|
||||
lastId = sinceId.split('>;')[0];
|
||||
lastId = maxId.split('>;')[0];
|
||||
}
|
||||
}
|
||||
return new FollowingResult(lastId, res.body)
|
||||
@ -503,9 +503,9 @@ export class MastodonService {
|
||||
const link = res.headers.get('Link');
|
||||
let lastId = null;
|
||||
if (link) {
|
||||
const sinceId = link.split('since_id=')[1];
|
||||
if (sinceId) {
|
||||
lastId = sinceId.split('>;')[0];
|
||||
const maxId = link.split('max_id=')[1];
|
||||
if (maxId) {
|
||||
lastId = maxId.split('>;')[0];
|
||||
}
|
||||
}
|
||||
return new FollowingResult(lastId, res.body)
|
||||
@ -553,6 +553,6 @@ export class BookmarkResult {
|
||||
|
||||
export class FollowingResult {
|
||||
constructor(
|
||||
public sinceId: string,
|
||||
public maxId: string,
|
||||
public follows: Account[]) { }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user