diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 22:17:15 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-09-26 22:17:15 -0400 |
commit | 20540a35be82c34cc3962de4f957d1aa43f8a2b0 (patch) | |
tree | a4d67686a1d323bab947fcf3a6d6c2575b576c3e /src/client/apis/google_docs/GooglePhotosClientUtils.ts | |
parent | e95387732e1fbff49ec035c3bec4b03324d814c8 (diff) |
finally transferred google credential management to database
Diffstat (limited to 'src/client/apis/google_docs/GooglePhotosClientUtils.ts')
-rw-r--r-- | src/client/apis/google_docs/GooglePhotosClientUtils.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts index b1b29210a..29cc042b6 100644 --- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts +++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts @@ -14,11 +14,14 @@ import { NewMediaItemResult, MediaItem } from "../../../server/apis/google/Share import { AssertionError } from "assert"; import { DocumentView } from "../../views/nodes/DocumentView"; import { DocumentManager } from "../../util/DocumentManager"; -import { PostToServer } from "../../Network"; +import { Identified } from "../../Network"; export namespace GooglePhotos { - const endpoint = async () => new Photos(await PostToServer(RouteStore.googlePhotosAccessToken)); + const endpoint = async () => { + const accessToken = await Identified.FetchFromServer(RouteStore.googlePhotosAccessToken); + return new Photos(accessToken); + }; export enum MediaType { ALL_MEDIA = 'ALL_MEDIA', @@ -296,7 +299,7 @@ export namespace GooglePhotos { }; export const WriteMediaItemsToServer = async (body: { mediaItems: any[] }): Promise<UploadInformation[]> => { - const uploads = await PostToServer(RouteStore.googlePhotosMediaDownload, body); + const uploads = await Identified.PostToServer(RouteStore.googlePhotosMediaDownload, body); return uploads; }; @@ -316,7 +319,7 @@ export namespace GooglePhotos { album = await Create.Album(album.title); } const media: MediaInput[] = []; - sources.forEach(source => { + for (let source of sources) { const data = Cast(Doc.GetProto(source).data, ImageField); if (!data) { return; @@ -324,11 +327,11 @@ export namespace GooglePhotos { const url = data.url.href; const target = Doc.MakeAlias(source); const description = parseDescription(target, descriptionKey); - DocumentView.makeCustomViewClicked(target, undefined); + await DocumentView.makeCustomViewClicked(target, undefined); media.push({ url, description }); - }); + } if (media.length) { - const uploads: NewMediaItemResult[] = await PostToServer(RouteStore.googlePhotosMediaUpload, { media, album }); + const uploads: NewMediaItemResult[] = await Identified.PostToServer(RouteStore.googlePhotosMediaUpload, { media, album }); return uploads; } }; |