aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/google_docs/GoogleApiClientUtils.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-08-14 16:15:56 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-08-14 16:15:56 -0400
commit4f338a06345c6a002c9bebc9ad0c9c1fe910eebd (patch)
tree44482ea8f1adb700becae880f84e3d77ac729a4c /src/client/apis/google_docs/GoogleApiClientUtils.ts
parent13d2be7f66c01ee9f09cb65f567eb3da760df670 (diff)
clean up and edge cases
Diffstat (limited to 'src/client/apis/google_docs/GoogleApiClientUtils.ts')
-rw-r--r--src/client/apis/google_docs/GoogleApiClientUtils.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts
index c1cbba31f..9d78b632d 100644
--- a/src/client/apis/google_docs/GoogleApiClientUtils.ts
+++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts
@@ -178,7 +178,7 @@ export namespace GoogleApiClientUtils {
}
}
if (mode === WriteMode.Replace) {
- requests.push({
+ index > 1 && requests.push({
deleteContentRange: {
range: {
startIndex: 1,
@@ -189,14 +189,21 @@ export namespace GoogleApiClientUtils {
index = 1;
}
const text = options.content;
- requests.push({
+ text.length && requests.push({
insertText: {
text: isArray(text) ? text.join("\n") : text,
location: { index }
}
});
- let replies = await update({ documentId, requests });
- console.log(replies);
+ if (!requests.length) {
+ return undefined;
+ }
+ let replies: any = await update({ documentId, requests });
+ let errors = "errors";
+ if (errors in replies) {
+ console.log("Write operation failed:");
+ console.log(replies[errors].map((error: any) => error.message));
+ }
return replies;
};