Skip to content

Commit a6f46c3

Browse files
prevented both google drive and github from syncing at the same time
1 parent 4eea489 commit a6f46c3

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/commons/controlBar/ControlBarGoogleDriveButtons.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Props = {
2020
accessToken?: string;
2121
currPersistenceFile?: PersistenceFile;
2222
isDirty?: boolean;
23+
isGithubSynced?: boolean;
2324
onClickOpen?: () => any;
2425
onClickSave?: () => any;
2526
onClickSaveAll?: () => any;
@@ -36,13 +37,14 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
3637
? 'DIRTY'
3738
: 'SAVED'
3839
: 'INACTIVE';
39-
const isNotPlayground = props.workspaceLocation !== "playground";
40+
const isNotPlayground = props.workspaceLocation !== "playground" ;
41+
const GithubSynced = props.isGithubSynced;
4042
const mainButton = (
4143
<ControlButton
4244
label={(props.currPersistenceFile && props.currPersistenceFile.name) || 'Google Drive'}
4345
icon={IconNames.CLOUD}
4446
options={{ intent: stateToIntent[state] }}
45-
isDisabled={isNotPlayground}
47+
isDisabled={isNotPlayground || GithubSynced}
4648
/>
4749
);
4850
const openButton = (
@@ -109,7 +111,7 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
109111
}
110112
onOpening={props.onPopoverOpening}
111113
popoverClassName={Classes.POPOVER_DISMISS}
112-
disabled={isNotPlayground}
114+
disabled={isNotPlayground || GithubSynced}
113115
>
114116
{mainButton}
115117
</Popover2>

src/commons/controlBar/github/ControlBarGitHubButtons.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Props = {
1616
loggedInAs?: Octokit;
1717
githubSaveInfo: GitHubSaveInfo;
1818
isDirty: boolean;
19+
isGDriveSynced: boolean;
1920
onClickOpen?: () => void;
2021
onClickSave?: () => void;
2122
onClickSaveAs?: () => void;
@@ -41,6 +42,7 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
4142
const shouldDisableButtons = !isLoggedIn;
4243
const hasFilePath = filePath !== '';
4344
const hasOpenFile = isLoggedIn && hasFilePath;
45+
const GDriveSynced = props.isGDriveSynced;
4446

4547
const mainButtonDisplayText =
4648
(props.currPersistenceFile && hasOpenFile && props.currPersistenceFile.name) || 'GitHub';
@@ -54,7 +56,7 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
5456
label={mainButtonDisplayText}
5557
icon={IconNames.GIT_BRANCH}
5658
options={{ intent: mainButtonIntent }}
57-
isDisabled={isNotPlayground}
59+
isDisabled={isNotPlayground || GDriveSynced}
5860
/>
5961
);
6062

@@ -120,7 +122,7 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
120122
</div>
121123
}
122124
popoverClassName={Classes.POPOVER_DISMISS}
123-
disabled={isNotPlayground}
125+
disabled={isNotPlayground || GDriveSynced}
124126
>
125127
{mainButton}
126128
</Popover2>

src/pages/playground/Playground.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ import {
118118
import { Position } from '../../commons/editor/EditorTypes';
119119
import {
120120
getGithubSaveInfo,
121+
isGDriveSyncing,
122+
isGithubSyncing,
121123
overwriteFilesInWorkspace
122124
} from '../../commons/fileSystem/FileSystemUtils';
123125
import FileSystemView from '../../commons/fileSystemView/FileSystemView';
@@ -603,6 +605,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
603605
// Compute this here to avoid re-rendering the button every keystroke
604606
const persistenceIsDirty =
605607
persistenceFile && (!persistenceFile.lastSaved || persistenceFile.lastSaved < lastEdit);
608+
const githubSynced = isGithubSyncing();
606609
const persistenceButtons = useMemo(() => {
607610
return (
608611
<ControlBarGoogleDriveButtons
@@ -612,6 +615,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
612615
loggedInAs={persistenceUser}
613616
isDirty={persistenceIsDirty}
614617
accessToken={googleAccessToken}
618+
isGithubSynced={githubSynced}
615619
key="googledrive"
616620
onClickSaveAs={() => dispatch(persistenceSaveFileAs())}
617621
onClickSaveAll={() => dispatch(persistenceSaveAll())}
@@ -631,13 +635,13 @@ const Playground: React.FC<PlaygroundProps> = props => {
631635
persistenceIsDirty,
632636
dispatch,
633637
googleAccessToken,
634-
workspaceLocation
638+
workspaceLocation,
639+
githubSynced
635640
]);
636641

637642
const githubPersistenceIsDirty =
638643
githubSaveInfo && (!githubSaveInfo.lastSaved || githubSaveInfo.lastSaved < lastEdit);
639-
console.log(githubSaveInfo.lastSaved);
640-
console.log(lastEdit);
644+
const gdriveSynced = isGDriveSyncing();
641645
const githubButtons = useMemo(() => {
642646
return (
643647
<ControlBarGitHubButtons
@@ -648,6 +652,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
648652
loggedInAs={githubOctokitObject.octokit}
649653
githubSaveInfo={githubSaveInfo}
650654
isDirty={githubPersistenceIsDirty}
655+
isGDriveSynced={gdriveSynced}
651656
onClickOpen={() => dispatch(githubOpenFile())}
652657
onClickSaveAs={() => dispatch(githubSaveFileAs())}
653658
onClickSave={() => dispatch(githubSaveFile())}
@@ -663,7 +668,8 @@ const Playground: React.FC<PlaygroundProps> = props => {
663668
githubSaveInfo,
664669
isFolderModeEnabled,
665670
persistenceFile,
666-
workspaceLocation
671+
workspaceLocation,
672+
gdriveSynced
667673
]);
668674

669675
const executionTime = useMemo(

0 commit comments

Comments
 (0)