Skip to content

Commit

Permalink
check for newer synced file before saving
Browse files Browse the repository at this point in the history
  • Loading branch information
tconfrey committed Feb 20, 2025
1 parent 9f19960 commit c7ada6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/bt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ function tabPositioned(data, highlight = false) {
const windowId = data.windowId;
const parentId = AllNodes[nodeId]?.parentId || nodeId;

if (!node) return;
node.tabId = tabId;
node.windowId = windowId;
node.tabIndex = tabIndex;
Expand Down
16 changes: 11 additions & 5 deletions app/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,24 @@ async function saveBT(localOnly = false, newContent = true) {
InitialInstall = false;
}

// also save to GDrive or local file if connected and drop an event
let event = "local_storage_save";
// also check before saving, save to GDrive or local file if connected and drop an event
let eventType = "local_storage_save";
const warnNewer = await checkBTFileVersion();
if ((warnNewer) &&
(confirm("The synced version of your BrainTool file has newer data. \n\nClick OK the refresh from it, or Cancel to overwrite with this change."))) {
refreshTable(true);
return;
}
if (GDriveConnected) {
await gDriveFileManager.saveBT(BTFileText, newContent); // if !newContent, don't force re-auth
event = "gdrive_save";
eventType = "gdrive_save";
} else if (LocalFileConnected) {
await localFileManager.saveBT(BTFileText);
event = "local_file_save";
eventType = "local_file_save";
}
updateStatsRow(); // update num cards etc
messageManager.removeWarning(); // remove stale warning if any
gtag('event', event, {'event_category': 'Save', 'event_label': 'NumNodes', 'value': AllNodes.length});
gtag('event', eventType, {'event_category': 'Save', 'event_label': 'NumNodes', 'value': AllNodes.length});
configManager.incrementStat('BTNumSaves');
}

Expand Down

0 comments on commit c7ada6a

Please sign in to comment.