-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Google Docs Usability Audit / Improvements #13960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
b634854
6cbe684
7a320a6
63ebd5f
6433f0b
a2708f8
0a8c90a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import newFilesInstant from "../../../google_drive/sources/new-files-instant/new-files-instant.mjs"; | ||
| import googleDrive from "../../google_docs.app.mjs"; | ||
| import { MY_DRIVE_VALUE } from "../../../google_drive/common/constants.mjs"; | ||
|
|
||
| export default { | ||
| ...newFilesInstant, | ||
| props: { | ||
| googleDrive, | ||
| db: "$.service.db", | ||
| http: "$.interface.http", | ||
| timer: newFilesInstant.props.timer, | ||
| folders: { | ||
| propDefinition: [ | ||
| googleDrive, | ||
| "folderId", | ||
| ], | ||
| type: "string[]", | ||
| description: "(Optional) The folders you want to watch. Leave blank to watch for any new document.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| hooks: { | ||
| ...newFilesInstant.hooks, | ||
| async deploy() { | ||
| // Emit sample records on the first run | ||
| const docs = await this.getDocuments(5); | ||
| await this.emitFiles(docs); | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...newFilesInstant.methods, | ||
| getDriveId() { | ||
| return googleDrive.methods.getDriveId(MY_DRIVE_VALUE); | ||
| }, | ||
| shouldProcess(file) { | ||
| return ( | ||
| file.mimeType.includes("document") && | ||
| newFilesInstant.methods.shouldProcess.bind(this)(file) | ||
| ); | ||
| }, | ||
| getDocumentsFromFolderOpts(folderId) { | ||
| const mimeQuery = "mimeType = 'application/vnd.google-apps.document'"; | ||
| let opts = { | ||
| q: `${mimeQuery} and parents in '${folderId}' and trashed = false`, | ||
| }; | ||
| return opts; | ||
| }, | ||
| async getDocumentsFromFiles(files, limit) { | ||
| return files.reduce(async (acc, file) => { | ||
| const docs = await acc; | ||
| const fileInfo = await this.googleDrive.getFile(file.id); | ||
| return docs.length >= limit | ||
| ? docs | ||
| : docs.concat(fileInfo); | ||
| }, []); | ||
| }, | ||
| async getDocuments(limit) { | ||
| const foldersIds = this.folders; | ||
|
|
||
| if (!foldersIds.length) { | ||
| const opts = this.getDocumentsFromFolderOpts("root"); | ||
| const { files } = await this.googleDrive.listFilesInPage(null, opts); | ||
| return this.getDocumentsFromFiles(files, limit); | ||
| } | ||
|
|
||
| return foldersIds.reduce(async (docs, folderId) => { | ||
| const opts = this.getDocumentsFromFolderOpts(folderId); | ||
| const { files } = await this.googleDrive.listFilesInPage(null, opts); | ||
| const nextDocuments = await this.getDocumentsFromFiles(files, limit); | ||
| return (await docs).concat(nextDocuments); | ||
| }, []); | ||
| }, | ||
| async emitFiles(files) { | ||
| for (const file of files) { | ||
| if (!this.shouldProcess(file)) { | ||
| continue; | ||
| } | ||
| const doc = await this.googleDrive.getDocument(file.id); | ||
| this.$emit(doc, this.generateMeta(doc)); | ||
| } | ||
| }, | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "google_docs-new-document-created", | ||
| name: "New Document Created (Instant)", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these sources be labeled as instant? Aren't they timer-based? Also, can we include docs links in the descriptions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| description: "Emit new event when a new document is created in Google Docs", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| generateMeta(doc) { | ||
| return { | ||
| id: doc.documentId, | ||
| summary: `New Document: ${doc.documentId}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, | ||
| async processChanges() { | ||
| const lastFileCreatedTime = this._getLastFileCreatedTime(); | ||
| const timeString = new Date(lastFileCreatedTime).toISOString(); | ||
|
|
||
| const args = this.getListFilesOpts({ | ||
| q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`, | ||
| orderBy: "createdTime desc", | ||
| fields: "*", | ||
| }); | ||
|
|
||
| const { files } = await this.googleDrive.listFilesInPage(null, args); | ||
| if (!files?.length) { | ||
| return; | ||
| } | ||
| await this.emitFiles(files); | ||
| this._setLastFileCreatedTime(Date.parse(files[0].createdTime)); | ||
| }, | ||
| }, | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.