aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/google_docs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/apis/google_docs')
-rw-r--r--src/client/apis/google_docs/GoogleApiClientUtils.ts20
-rw-r--r--src/client/apis/google_docs/GooglePhotosClientUtils.ts16
2 files changed, 18 insertions, 18 deletions
diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts
index 26c7f8d2e..d2a79f189 100644
--- a/src/client/apis/google_docs/GoogleApiClientUtils.ts
+++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts
@@ -1,4 +1,4 @@
-import { docs_v1, slides_v1 } from "googleapis";
+import { docs_v1 } from "googleapis";
import { Opt } from "../../../new_fields/Doc";
import { isArray } from "util";
import { EditorState } from "prosemirror-state";
@@ -94,7 +94,7 @@ export namespace GoogleApiClientUtils {
export type ExtractResult = { text: string, paragraphs: DeconstructedParagraph[] };
export const extractText = (document: docs_v1.Schema$Document, removeNewlines = false): ExtractResult => {
- let paragraphs = extractParagraphs(document);
+ const paragraphs = extractParagraphs(document);
let text = paragraphs.map(paragraph => paragraph.contents.filter(content => !("inlineObjectId" in content)).map(run => run as docs_v1.Schema$TextRun).join("")).join("");
text = text.substring(0, text.length - 1);
removeNewlines && text.ReplaceAll("\n", "");
@@ -107,14 +107,14 @@ export namespace GoogleApiClientUtils {
const fragments: DeconstructedParagraph[] = [];
if (document.body && document.body.content) {
for (const element of document.body.content) {
- let runs: ContentArray = [];
+ const runs: ContentArray = [];
let bullet: Opt<number>;
if (element.paragraph) {
if (element.paragraph.elements) {
for (const inner of element.paragraph.elements) {
if (inner) {
if (inner.textRun) {
- let run = inner.textRun;
+ const run = inner.textRun;
(run.content || !filterEmpty) && runs.push(inner.textRun);
} else if (inner.inlineObjectElement) {
runs.push(inner.inlineObjectElement);
@@ -182,8 +182,8 @@ export namespace GoogleApiClientUtils {
export const read = async (options: ReadOptions): Promise<Opt<ReadResult>> => {
return retrieve({ documentId: options.documentId }).then(document => {
if (document) {
- let title = document.title!;
- let body = Utils.extractText(document, options.removeNewlines).text;
+ const title = document.title!;
+ const body = Utils.extractText(document, options.removeNewlines).text;
return { title, body };
}
});
@@ -192,7 +192,7 @@ export namespace GoogleApiClientUtils {
export const readLines = async (options: ReadOptions): Promise<Opt<ReadLinesResult>> => {
return retrieve({ documentId: options.documentId }).then(document => {
if (document) {
- let title = document.title;
+ const title = document.title;
let bodyLines = Utils.extractText(document).text.split("\n");
options.removeNewlines && (bodyLines = bodyLines.filter(line => line.length));
return { title, bodyLines };
@@ -201,7 +201,7 @@ export namespace GoogleApiClientUtils {
};
export const setStyle = async (options: UpdateOptions) => {
- let replies: any = await update({
+ const replies: any = await update({
documentId: options.documentId,
requests: options.requests
});
@@ -221,7 +221,7 @@ export namespace GoogleApiClientUtils {
let index = options.index;
const mode = options.mode;
if (!(index && mode === WriteMode.Insert)) {
- let schema = await retrieve({ documentId });
+ const schema = await retrieve({ documentId });
if (!schema || !(index = Utils.endOf(schema))) {
return undefined;
}
@@ -248,7 +248,7 @@ export namespace GoogleApiClientUtils {
return undefined;
}
requests.push(...options.content.requests);
- let replies: any = await update({ documentId: documentId, requests });
+ const replies: any = await update({ documentId: documentId, requests });
if ("errors" in replies) {
console.log("Write operation failed:");
console.log(replies.errors.map((error: any) => error.message));
diff --git a/src/client/apis/google_docs/GooglePhotosClientUtils.ts b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
index bf8897061..966d8053a 100644
--- a/src/client/apis/google_docs/GooglePhotosClientUtils.ts
+++ b/src/client/apis/google_docs/GooglePhotosClientUtils.ts
@@ -128,10 +128,10 @@ export namespace GooglePhotos {
export const CollectionFromSearch = async (constructor: CollectionConstructor, requested: Opt<Partial<Query.SearchOptions>>): Promise<Doc> => {
await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
- let response = await Query.ContentSearch(requested);
- let uploads = await Transactions.WriteMediaItemsToServer(response);
+ const response = await Query.ContentSearch(requested);
+ const uploads = await Transactions.WriteMediaItemsToServer(response);
const children = uploads.map((upload: Transactions.UploadInformation) => {
- let document = Docs.Create.ImageDocument(Utils.fileUrl(upload.fileNames.clean));
+ const document = Docs.Create.ImageDocument(Utils.fileUrl(upload.fileNames.clean));
document.fillColumn = true;
document.contentSize = upload.contentSize;
return document;
@@ -157,12 +157,12 @@ export namespace GooglePhotos {
const images = (await DocListCastAsync(collection.data))!.map(Doc.GetProto);
images && images.forEach(image => tagMapping.set(image[Id], ContentCategories.NONE));
const values = Object.values(ContentCategories);
- for (let value of values) {
+ for (const value of values) {
if (value !== ContentCategories.NONE) {
const results = await ContentSearch({ included: [value] });
if (results.mediaItems) {
const ids = results.mediaItems.map(item => item.id);
- for (let id of ids) {
+ for (const id of ids) {
const image = await Cast(idMapping[id], Doc);
if (image) {
const key = image[Id];
@@ -220,9 +220,9 @@ export namespace GooglePhotos {
export const AlbumSearch = async (albumId: string, pageSize = 100): Promise<MediaItem[]> => {
const photos = await endpoint();
- let mediaItems: MediaItem[] = [];
+ const mediaItems: MediaItem[] = [];
let nextPageTokenStored: Opt<string> = undefined;
- let found = 0;
+ const found = 0;
do {
const response: any = await photos.mediaItems.search(albumId, pageSize, nextPageTokenStored);
mediaItems.push(...response.mediaItems);
@@ -332,7 +332,7 @@ export namespace GooglePhotos {
album = await Create.Album(album.title);
}
const media: MediaInput[] = [];
- for (let source of sources) {
+ for (const source of sources) {
const data = Cast(Doc.GetProto(source).data, ImageField);
if (!data) {
return;