aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/google_docs/GooglePhotosClientUtils.ts
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2020-05-15 22:41:58 +0530
committerusodhi <61431818+usodhi@users.noreply.github.com>2020-05-15 22:41:58 +0530
commit0cc83ef72b6b1b254d97bf07a97dd1fe936aa25a (patch)
treebce434d8545a953fd943743f0714609f23529220 /src/client/apis/google_docs/GooglePhotosClientUtils.ts
parent9c0b8ab5820232292e02fbf453e50261137a533c (diff)
parent98c7540fff67c232c1b04f2130ee624f9a70afbd (diff)
resolved conflicts
Diffstat (limited to 'src/client/apis/google_docs/GooglePhotosClientUtils.ts')
-rw-r--r--src/client/apis/google_docs/GooglePhotosClientUtils.ts35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
index ff471853a..fef71ffeb 100644
--- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts
+++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
@@ -1,11 +1,11 @@
import { AssertionError } from "assert";
import { EditorState } from "prosemirror-state";
-import { Doc, DocListCastAsync, Opt } from "../../../new_fields/Doc";
-import { Id } from "../../../new_fields/FieldSymbols";
-import { RichTextField } from "../../../new_fields/RichTextField";
-import { RichTextUtils } from "../../../new_fields/RichTextUtils";
-import { Cast, StrCast } from "../../../new_fields/Types";
-import { ImageField } from "../../../new_fields/URLField";
+import { Doc, DocListCastAsync, Opt } from "../../../fields/Doc";
+import { Id } from "../../../fields/FieldSymbols";
+import { RichTextField } from "../../../fields/RichTextField";
+import { RichTextUtils } from "../../../fields/RichTextUtils";
+import { Cast, StrCast } from "../../../fields/Types";
+import { ImageField } from "../../../fields/URLField";
import { MediaItem, NewMediaItemResult } from "../../../server/apis/google/SharedTypes";
import { Utils } from "../../../Utils";
import { Docs, DocumentOptions } from "../../documents/Documents";
@@ -153,21 +153,20 @@ export namespace GooglePhotos {
}
const tagMapping = new Map<string, string>();
const images = (await DocListCastAsync(collection.data))!.map(Doc.GetProto);
- images && images.forEach(image => tagMapping.set(image[Id], ContentCategories.NONE));
- const values = Object.values(ContentCategories);
+ images?.forEach(image => tagMapping.set(image[Id], ContentCategories.NONE));
+ const values = Object.values(ContentCategories).filter(value => value !== ContentCategories.NONE);
for (const value of values) {
- if (value === ContentCategories.NONE) {
- continue;
- }
- for (const id of (await ContentSearch({ included: [value] }))?.mediaItems?.map(({ id }) => id)) {
+ const searched = (await ContentSearch({ included: [value] }))?.mediaItems?.map(({ id }) => id);
+ console.log("Searching " + value);
+ console.log(searched);
+ searched?.forEach(async id => {
const image = await Cast(idMapping[id], Doc);
- if (!image) {
- continue;
+ if (image) {
+ const key = image[Id];
+ const tags = tagMapping.get(key);
+ !tags?.includes(value) && tagMapping.set(key, tags + delimiter + value);
}
- const key = image[Id];
- const tags = tagMapping.get(key);
- !tags?.includes(value) && tagMapping.set(key, tags + delimiter + value);
- }
+ });
}
images?.forEach(image => {
const concatenated = tagMapping.get(image[Id])!;