aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/apis/google_docs/GooglePhotosClientUtils.ts14
-rw-r--r--src/client/views/MainView.tsx7
2 files changed, 11 insertions, 10 deletions
diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
index e8daf3dd4..bb5d23971 100644
--- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts
+++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
@@ -10,6 +10,7 @@ import { RichTextField } from "../../../new_fields/RichTextField";
import { RichTextUtils } from "../../../new_fields/RichTextUtils";
import { EditorState } from "prosemirror-state";
import { FormattedTextBox } from "../../views/nodes/FormattedTextBox";
+import { Docs } from "../../documents/Documents";
export namespace GooglePhotosClientUtils {
@@ -130,14 +131,13 @@ export namespace GooglePhotosClientUtils {
filters.setMediaTypeFilter(new photos.MediaTypeFilter(options.type || MediaType.ALL_MEDIA));
- return new Promise<any>((resolve, reject) => {
+ return new Promise<Doc>(resolve => {
photos.mediaItems.search(filters, options.pageSize || 20).then(async (response: SearchResponse) => {
- if (!response) {
- return reject();
- }
- let filenames = await PostToServer(RouteStore.googlePhotosMediaDownload, response);
- console.log(filenames);
- resolve(filenames);
+ response && resolve(Docs.Create.StackingDocument((await PostToServer(RouteStore.googlePhotosMediaDownload, response)).map((download: any) => {
+ let document = Docs.Create.ImageDocument(Utils.prepend(`/files/${download.fileName}`));
+ document.contentSize = download.contentSize;
+ return document;
+ }), { width: 500, height: 500 }));
});
});
};
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index ee58c684a..b72df3715 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -131,8 +131,6 @@ export class MainView extends React.Component {
window.addEventListener("keydown", KeyManager.Instance.handle);
// this.executeGooglePhotosRoutine();
- const imageTag = GooglePhotosClientUtils.ContentCategories;
- GooglePhotosClientUtils.Search({ included: [imageTag.ANIMALS] });
reaction(() => {
let workspaces = CurrentUserUtils.UserDocument.workspaces;
@@ -472,12 +470,15 @@ export class MainView extends React.Component {
// let youtubeurl = "https://www.youtube.com/embed/TqcApsGRzWw";
// let addYoutubeSearcher = action(() => Docs.Create.YoutubeDocument(youtubeurl, { width: 600, height: 600, title: "youtube search" }));
- let btns: [React.RefObject<HTMLDivElement>, IconName, string, () => Doc][] = [
+ let googlePhotosSearch = () => GooglePhotosClientUtils.Search({ included: [GooglePhotosClientUtils.ContentCategories.ANIMALS] });
+
+ let btns: [React.RefObject<HTMLDivElement>, IconName, string, () => Doc | Promise<Doc>][] = [
[React.createRef<HTMLDivElement>(), "object-group", "Add Collection", addColNode],
[React.createRef<HTMLDivElement>(), "tv", "Add Presentation Trail", addPresNode],
[React.createRef<HTMLDivElement>(), "globe-asia", "Add Website", addWebNode],
[React.createRef<HTMLDivElement>(), "bolt", "Add Button", addButtonDocument],
[React.createRef<HTMLDivElement>(), "file", "Add Document Dragger", addDragboxNode],
+ [React.createRef<HTMLDivElement>(), "object-group", "Test Google Photos Search", googlePhotosSearch],
[React.createRef<HTMLDivElement>(), "cloud-upload-alt", "Import Directory", addImportCollectionNode], //remove at some point in favor of addImportCollectionNode
//[React.createRef<HTMLDivElement>(), "play", "Add Youtube Searcher", addYoutubeSearcher],
];