Skip to content

Commit efe840d

Browse files
fixed single file opening, added loading toasters, made instantaneous syncing work when either gdrive or github is syncing
1 parent 8ba080c commit efe840d

File tree

6 files changed

+655
-505
lines changed

6 files changed

+655
-505
lines changed

src/commons/fileSystem/FileSystemUtils.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,31 @@ export const getPersistenceFile = (filePath: string) => {
297297

298298
return persistenceFile;
299299
};
300+
301+
export const isGDriveSyncing = () => {
302+
const persistenceFileArray = store.getState().fileSystem.persistenceFileArray;
303+
304+
if (persistenceFileArray.length === 0) {
305+
return false;
306+
}
307+
308+
if (!persistenceFileArray[0].id) {
309+
return false;
310+
}
311+
312+
return true;
313+
}
314+
315+
export const isGithubSyncing = () => {
316+
const persistenceFileArray = store.getState().fileSystem.persistenceFileArray;
317+
318+
if (persistenceFileArray.length === 0) {
319+
return false;
320+
}
321+
322+
if (!persistenceFileArray[0].repoName) {
323+
return false;
324+
}
325+
326+
return true;
327+
}

src/commons/fileSystemView/FileSystemViewDirectoryNode.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { PersistenceFile } from 'src/features/persistence/PersistenceTypes';
1414
import classes from 'src/styles/FileSystemView.module.scss';
1515

16-
import { rmdirRecursively } from '../fileSystem/FileSystemUtils';
16+
import { isGDriveSyncing, isGithubSyncing, rmdirRecursively } from '../fileSystem/FileSystemUtils';
1717
import { showSimpleConfirmDialog, showSimpleErrorDialog } from '../utils/DialogHelper';
1818
import { removeEditorTabsForDirectory } from '../workspace/WorkspaceActions';
1919
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
@@ -90,8 +90,12 @@ const FileSystemViewDirectoryNode: React.FC<Props> = ({
9090
if (!shouldProceed) {
9191
return;
9292
}
93-
dispatch(persistenceDeleteFolder(fullPath));
94-
dispatch(githubDeleteFolder(fullPath));
93+
if (isGDriveSyncing()) {
94+
dispatch(persistenceDeleteFolder(fullPath));
95+
}
96+
if (isGithubSyncing()) {
97+
dispatch(githubDeleteFolder(fullPath));
98+
}
9599
dispatch(removeEditorTabsForDirectory(workspaceLocation, fullPath));
96100
rmdirRecursively(fileSystem, fullPath).then(refreshParentDirectory);
97101
});
@@ -124,8 +128,12 @@ const FileSystemViewDirectoryNode: React.FC<Props> = ({
124128
if (err) {
125129
console.error(err);
126130
}
127-
dispatch(persistenceCreateFile(newFilePath));
128-
dispatch(githubCreateFile(newFilePath));
131+
if (isGDriveSyncing()) {
132+
dispatch(persistenceCreateFile(newFilePath));
133+
}
134+
if (isGithubSyncing()) {
135+
dispatch(githubCreateFile(newFilePath));
136+
}
129137
forceRefreshFileSystemViewList();
130138
});
131139
});

src/commons/fileSystemView/FileSystemViewFileName.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
renameEditorTabsForDirectory
1616
} from '../workspace/WorkspaceActions';
1717
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
18+
import { isGDriveSyncing, isGithubSyncing } from '../fileSystem/FileSystemUtils';
1819

1920
type Props = {
2021
workspaceLocation: WorkspaceLocation;
@@ -74,12 +75,20 @@ const FileSystemViewFileName: React.FC<Props> = ({
7475
}
7576

7677
if (isDirectory) {
77-
dispatch(persistenceRenameFolder({ oldFolderPath: oldPath, newFolderPath: newPath }));
78-
dispatch(githubRenameFolder(oldPath, newPath));
78+
if (isGDriveSyncing()) {
79+
dispatch(persistenceRenameFolder({ oldFolderPath: oldPath, newFolderPath: newPath }));
80+
}
81+
if (isGithubSyncing()) {
82+
dispatch(githubRenameFolder(oldPath, newPath));
83+
}
7984
dispatch(renameEditorTabsForDirectory(workspaceLocation, oldPath, newPath));
8085
} else {
81-
dispatch(persistenceRenameFile({ oldFilePath: oldPath, newFilePath: newPath }));
82-
dispatch(githubRenameFile(oldPath, newPath));
86+
if (isGDriveSyncing()) {
87+
dispatch(persistenceRenameFile({ oldFilePath: oldPath, newFilePath: newPath }));
88+
}
89+
if (isGithubSyncing()) {
90+
dispatch(githubRenameFile(oldPath, newPath));
91+
}
8392
dispatch(renameEditorTabForFile(workspaceLocation, oldPath, newPath));
8493
}
8594
refreshDirectory();

src/commons/fileSystemView/FileSystemViewFileNode.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { WorkspaceLocation } from '../workspace/WorkspaceTypes';
1515
import FileSystemViewContextMenu from './FileSystemViewContextMenu';
1616
import FileSystemViewFileName from './FileSystemViewFileName';
1717
import FileSystemViewIndentationPadding from './FileSystemViewIndentationPadding';
18+
import { isGDriveSyncing, isGithubSyncing } from '../fileSystem/FileSystemUtils';
1819

1920
type Props = {
2021
workspaceLocation: WorkspaceLocation;
@@ -107,8 +108,12 @@ const FileSystemViewFileNode: React.FC<Props> = ({
107108
if (err) {
108109
console.error(err);
109110
}
110-
dispatch(persistenceDeleteFile(fullPath));
111-
dispatch(githubDeleteFile(fullPath));
111+
if (isGDriveSyncing()) {
112+
dispatch(persistenceDeleteFile(fullPath));
113+
}
114+
if (isGithubSyncing()) {
115+
dispatch(githubDeleteFile(fullPath));
116+
}
112117
dispatch(removeEditorTabForFile(workspaceLocation, fullPath));
113118
refreshDirectory();
114119
});

0 commit comments

Comments
 (0)