diff --git a/src/GPhotos.ts b/src/GPhotos.ts index de90a436..eb3d638d 100644 --- a/src/GPhotos.ts +++ b/src/GPhotos.ts @@ -1,6 +1,7 @@ import util from 'util'; import { CookieJar } from 'tough-cookie'; import { Nullable, isNotNull, isNull } from 'option-t/cjs/Nullable'; +import { Maybe, isNullOrUndefined } from 'option-t/cjs/Maybe'; import { signinViaPuppeteer } from './signin_via_puppeteer'; import { Requestor } from './Requestor'; @@ -40,7 +41,7 @@ class GPhotos { const { Z5xsfc: [albumInfoList, nextCursor], } = await this.requestor.sendBatchExecute<{ - Z5xsfc: [Nullable, Nullable]; + Z5xsfc: [Nullable, Maybe]; }>({ queries: { Z5xsfc: [cursor, null, null, null, 1], @@ -60,6 +61,11 @@ class GPhotos { }); }); + // NOTE: Cursor maybe undefined or null or empty string. + if (isNullOrUndefined(nextCursor) || cursor === '') { + return { results: albumList, nextCursor: null }; + } + return { results: albumList, nextCursor }; } @@ -129,7 +135,7 @@ class GPhotos { const { lcxiM: [photoInfoList, nextCursor], } = await this.requestor.sendBatchExecute<{ - lcxiM: [any[], Nullable]; + lcxiM: [any[], Maybe]; }>({ queries: { lcxiM: [cursor, null, null, null, 1], @@ -140,6 +146,11 @@ class GPhotos { return new GPhotosPhoto(GPhotosPhoto.parseInfo(info), { requestor: this.requestor }); }); + // NOTE: Cursor maybe undefined or null or empty string. + if (isNullOrUndefined(nextCursor) || nextCursor === '') { + return { results: photoList, nextCursor: null }; + } + return { results: photoList, nextCursor }; } diff --git a/src/GPhotosAlbum.ts b/src/GPhotosAlbum.ts index 82c6dbac..ebb72ab3 100644 --- a/src/GPhotosAlbum.ts +++ b/src/GPhotosAlbum.ts @@ -1,5 +1,6 @@ import util from 'util'; import { Nullable } from 'option-t/cjs/Nullable'; +import { Maybe, isNullOrUndefined } from 'option-t/cjs/Maybe'; import { Requestor } from './Requestor'; import { GPhotosPhoto } from './GPhotosPhoto'; @@ -73,7 +74,7 @@ class GPhotosAlbum { const { snAcKc: [, photoInfoList, nextCursor], } = await this.requestor.sendBatchExecute<{ - snAcKc: [unknown, any[], Nullable]; + snAcKc: [unknown, any[], Maybe]; }>({ queries: { snAcKc: [this.id, cursor, null, null, 0], @@ -84,6 +85,11 @@ class GPhotosAlbum { return new GPhotosPhoto(GPhotosPhoto.parseInfo(info), { requestor: this.requestor }); }); + // NOTE: Cursor maybe undefined or null or empty string. + if (isNullOrUndefined(nextCursor) || nextCursor === '') { + return { results: photoList, nextCursor: null }; + } + return { results: photoList, nextCursor }; }