Skip to content

Commit

Permalink
Keep hidden files from displaying in autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacwhite committed Oct 10, 2019
1 parent f9ecfac commit 58cbf7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions server/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ async function fetchAllFiles({nextPageToken: pageToken, listSoFar = [], parentId
}

function produceTree(files, firstParent) {
// maybe group into folders first?
// then build out tree, by traversing top down
// keep in mind that files can have multiple parents
// NB: technically files can have multiple parents
// may be worth filtering here based on metadata info.
const [byParent, byId, tagIds, fileNames] = files.reduce(([byParent, byId, tagIds, fileNames], resource) => {
const {parents, id, name, mimeType} = resource

Expand All @@ -169,7 +168,7 @@ function produceTree(files, firstParent) {
.map((t) => t.trim().toLowerCase())
.filter((t) => t.length > 0)

if (!mimeType.includes('folder')) fileNames.push(prettyName)
if (!mimeType.includes('folder') && !tags.includes('hidden')) fileNames.push(prettyName)

byId[id] = Object.assign({}, resource, {
prettyName,
Expand Down Expand Up @@ -218,7 +217,6 @@ function produceTree(files, firstParent) {
return {tree: tree, filenames: fileNames}
}

// do we care about parent ids? maybe not?
function buildTreeFromData(rootParent, previousData, breadcrumb) {
const {children, home, homePrettyName} = driveBranches[rootParent] || {}
const parentInfo = docsInfo[rootParent] || {}
Expand Down Expand Up @@ -351,7 +349,6 @@ function handleUpdates(id, {info: lastInfo, tree: lastTree}) {
if (oldItem && newItem.path !== oldItem.path) {
cache.redirect(oldItem.path, newItem.path, newItem.modifiedTime)
} else {
// should we be calling purge every time?
// basically we are just calling purge because we don't know the last modified
cache.purge({url: newItem.path, modified: newItem.modifiedTime}).catch((err) => {
if (!err) return
Expand Down
2 changes: 1 addition & 1 deletion test/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.inspectHttp = () => {
exports.allFilenames = [].concat(...Object.keys(listing).map((pageName, i) => {
// map each mock page listing to an array of non-folder file names, strip tags
return listing[pageName].data.files.reduce((acc, {mimeType, name}) => {
if (!mimeType.includes('folder')) acc.push(name.split(' | ')[0])
if (!mimeType.includes('folder') && !name.includes('| hidden')) acc.push(name.split(' | ')[0])
return acc
}, [])
}))
Expand Down

0 comments on commit 58cbf7b

Please sign in to comment.