From 14da721a8cf5362d50e946a61617c25be2149828 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sun, 15 Sep 2019 13:56:56 -0400 Subject: drag drop of album --- .../apis/google_docs/GooglePhotosClientUtils.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/client/apis') diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts index f3f652ce1..dfc4a6ddf 100644 --- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts +++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts @@ -121,7 +121,7 @@ export namespace GooglePhotos { export type CollectionConstructor = (data: Array, options: DocumentOptions, ...args: any) => Doc; export const CollectionFromSearch = async (constructor: CollectionConstructor, requested: Opt>): Promise => { - let response = await Query.Search(requested); + let response = await Query.ContentSearch(requested); let uploads = await Transactions.WriteMediaItemsToServer(response); const children = uploads.map((upload: Transactions.UploadInformation) => { let document = Docs.Create.ImageDocument(Utils.fileUrl(upload.fileNames.clean)); @@ -149,7 +149,7 @@ export namespace GooglePhotos { const values = Object.values(ContentCategories); for (let value of values) { if (value !== ContentCategories.NONE) { - const results = await Search({ included: [value] }); + const results = await ContentSearch({ included: [value] }); if (results.mediaItems) { const ids = results.mediaItems.map(item => item.id); for (let id of ids) { @@ -208,7 +208,20 @@ export namespace GooglePhotos { nextPageToken: string; } - export const Search = async (requested: Opt>): Promise => { + export const AlbumSearch = async (albumId: string, pageSize = 100): Promise => { + const photos = await endpoint(); + let mediaItems: MediaItem[] = []; + let nextPageTokenStored: Opt = undefined; + let found = 0; + do { + const { mediaItems, nextPageToken } = (await photos.search(albumId, pageSize, nextPageTokenStored)) as any; + mediaItems.push(...mediaItems); + nextPageTokenStored = nextPageToken; + } while (found); + return mediaItems; + }; + + export const ContentSearch = async (requested: Opt>): Promise => { const options = requested || DefaultSearchOptions; const photos = await endpoint(); const filters = new photos.Filters(options.includeArchivedMedia === undefined ? true : options.includeArchivedMedia); -- cgit v1.2.3-70-g09d2