Order Google Drive results by folder to show all folders first (#3546)

This commit is contained in:
Robert DiMartino 2022-03-11 00:00:22 -05:00 committed by GitHub
parent ae1c512b32
commit 7da07c29fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,10 +17,6 @@ const SHARED_DRIVE_FIELDS = '*'
// Hopefully this name will not be used by Google
const VIRTUAL_SHARED_DIR = 'shared-with-me'
function sortByName (first, second) {
return first.name.localeCompare(second.name)
}
async function waitForFailedResponse (resp) {
const buf = await new Promise((resolve) => {
let data = ''
@ -71,7 +67,7 @@ function adaptData (listFilesResp, sharedDrivesResp, directory, query, showShare
const adaptedItems = [
...(virtualItem ? [virtualItem] : []), // shared folder first
...([...sharedDrives, ...items].map(adaptItem).sort(sortByName)),
...([...sharedDrives, ...items].map(adaptItem)),
]
return {
@ -143,6 +139,7 @@ class Drive extends Provider {
pageToken: query.cursor,
q,
// pageSize: 10, // can be used for testing pagination if you don't have many files
orderBy: 'folder,name',
includeItemsFromAllDrives: true,
supportsAllDrives: true,
}