Skip to content

Commit

Permalink
refactor of gdrive file syncing and permissions. now load only on-dem…
Browse files Browse the repository at this point in the history
…and. hadn't been fully working since api migration to gISS
  • Loading branch information
tconfrey committed Mar 7, 2024
1 parent 371e21a commit 3631134
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 452 deletions.
20 changes: 16 additions & 4 deletions app/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ async function handleStartupFileConnection() {
let launchType = 'UnsyncedLaunch';

// Handle GDrive connection
if (configManager.getProp('BTGDriveConnected') == 'true') {
if (configManager.getProp('BTGDriveConnected')) {
GDriveConnected = true;
gDriveFileManager.authorizeGapi();
authorizeGAPI(false);
launchType = 'GDriveLaunch';
}

Expand Down Expand Up @@ -73,15 +73,27 @@ async function authorizeLocalFile() {
const success = await localFileManager.authorizeLocalFile();
if (!success) return false;

configManager.setProp('BTGDriveConnected', 'false');
configManager.setProp('BTGDriveConnected', false);
configManager.setProp('BTTimestamp', await localFileManager.getFileLastModifiedTime());
updateSyncSettings(true);
alert('Local file sync established. See Actions to disable.');
return true;
}

function authorizeGAPI(userInitiated) {
// just pass thru
// load apis and pass thru to gdrive file manager
if (!window.gapi) {
let gapiscript = document.createElement('script');
gapiscript.src = 'https://apis.google.com/js/api.js'; // URL of the Google API script
gapiscript.onload = gapiLoadOkay;
gapiscript.onerror = gapiLoadFail;
let gisscript = document.createElement('script');
gisscript.src = 'https://accounts.google.com/gsi/client'; // URL of the Google GIS script
gisscript.onload = gisLoadOkay;
gisscript.onerror = gisLoadFail;
document.head.appendChild(gapiscript);
document.head.appendChild(gisscript);
}
gDriveFileManager.authorizeGapi(userInitiated);
}

Expand Down
Loading

0 comments on commit 3631134

Please sign in to comment.