From a5de80db6df241c8cbacfd4aaa3228f7469b45b9 Mon Sep 17 00:00:00 2001 From: 3846masa <3846masahiro+git@gmail.com> Date: Sun, 19 Jan 2020 19:27:58 +0900 Subject: [PATCH] Optimize to create album * Send one request when creating album method --- src/GPhotos.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/GPhotos.ts b/src/GPhotos.ts index eb3d638d..96b215f7 100644 --- a/src/GPhotos.ts +++ b/src/GPhotos.ts @@ -87,17 +87,13 @@ class GPhotos { } async createAlbum({ title }: { title: string }): Promise { - const { - results: [latestPhoto], - } = await this.fetchPhotoList({ cursor: null }); - const { OXvT9d: [[albumId]], } = await this.requestor.sendBatchExecute<{ OXvT9d: [[string]]; }>({ queries: { - OXvT9d: [title, null, 1, [[[latestPhoto.id]]]], + OXvT9d: [title, null, 2, []], }, }); @@ -106,18 +102,13 @@ class GPhotos { title, id: albumId, type: 'album', - period: { from: new Date(), to: new Date() }, + period: { from: new Date(0), to: new Date(0) }, itemsCount: 0, isShared: false, }, { requestor: this.requestor }, ); - const { - results: [insertedPhoto], - } = await album.fetchPhotoList({ cursor: null }); - await album.remove(insertedPhoto); - return album; }