0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 11:22:40 +00:00

Get next page if end of files not reached

This commit is contained in:
Trevor Buckner
2023-05-09 10:44:18 -04:00
parent b2ebf724f5
commit 0e1b30eced

View File

@@ -99,8 +99,13 @@ const GoogleActions = {
listGoogleBrews : async (auth)=>{ listGoogleBrews : async (auth)=>{
const drive = googleDrive.drive({ version: 'v3', auth }); const drive = googleDrive.drive({ version: 'v3', auth });
const fileList = [];
let NextPageToken = "";
do {
const obj = await drive.files.list({ const obj = await drive.files.list({
pageSize : 1000, pageSize : 1000,
pageToken : NextPageToken || "",
fields : 'nextPageToken, files(id, name, description, createdTime, modifiedTime, properties)', fields : 'nextPageToken, files(id, name, description, createdTime, modifiedTime, properties)',
q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false' q : 'mimeType != \'application/vnd.google-apps.folder\' and trashed = false'
}) })
@@ -110,12 +115,15 @@ const GoogleActions = {
throw (err); throw (err);
//TODO: Should break out here, but continues on for some reason. //TODO: Should break out here, but continues on for some reason.
}); });
fileList.push(...obj.data.files);
NextPageToken = obj.data.nextPageToken;
} while (NextPageToken);
if(!obj.data.files.length) { if(!fileList.length) {
console.log('No files found.'); console.log('No files found.');
} }
const brews = obj.data.files.map((file)=>{ const brews = fileList.map((file)=>{
return { return {
text : '', text : '',
shareId : file.properties.shareId, shareId : file.properties.shareId,