@@ -466,6 +466,11 @@ export default class ObsidianGit extends Plugin {
466
466
return Platform . isDesktopApp ;
467
467
}
468
468
469
+ hasConnectivity ( ) {
470
+ if ( navigator . onLine ) return true ;
471
+ return ( new Notice ( 'No Connectivity' ) , false )
472
+ }
473
+
469
474
async init ( { fromReload = false } ) : Promise < void > {
470
475
if ( this . settings . showStatusBar ) {
471
476
const statusBarEl = this . addStatusBarItem ( ) ;
@@ -663,6 +668,7 @@ export default class ObsidianGit extends Plugin {
663
668
///Used for command
664
669
async pullChangesFromRemote ( ) : Promise < void > {
665
670
if ( ! ( await this . isAllInitialized ( ) ) ) return ;
671
+ if ( ! ( this . hasConnectivity ( ) ) ) return ;
666
672
667
673
const filesUpdated = await this . pull ( ) ;
668
674
await this . automaticsManager . setUpAutoCommitAndSync ( ) ;
@@ -695,11 +701,13 @@ export default class ObsidianGit extends Plugin {
695
701
commitMessage ?: string
696
702
) : Promise < void > {
697
703
if ( ! ( await this . isAllInitialized ( ) ) ) return ;
704
+ const isConnected = this . hasConnectivity ( ) ;
698
705
699
706
if (
700
707
this . settings . syncMethod == "reset" &&
701
708
this . settings . pullBeforePush
702
709
) {
710
+ if ( ! isConnected ) return ;
703
711
await this . pull ( ) ;
704
712
}
705
713
@@ -716,11 +724,13 @@ export default class ObsidianGit extends Plugin {
716
724
this . settings . syncMethod != "reset" &&
717
725
this . settings . pullBeforePush
718
726
) {
727
+ if ( ! isConnected ) return ;
719
728
await this . pull ( ) ;
720
729
}
721
730
722
731
if ( ! this . settings . disablePush ) {
723
732
// Prevent trying to push every time. Only if unpushed commits are present
733
+ if ( ! isConnected ) return ;
724
734
if (
725
735
( await this . remotesAreSet ( ) ) &&
726
736
( await this . gitManager . canPush ( ) )
@@ -891,9 +901,9 @@ export default class ObsidianGit extends Plugin {
891
901
*/
892
902
async push ( ) : Promise < boolean > {
893
903
if ( ! ( await this . isAllInitialized ( ) ) ) return false ;
894
- if ( ! ( await this . remotesAreSet ( ) ) ) {
895
- return false ;
896
- }
904
+ if ( ! ( await this . remotesAreSet ( ) ) ) return false ;
905
+ if ( ! ( this . hasConnectivity ( ) ) ) return false ;
906
+
897
907
const hadConflict = this . localStorage . getConflict ( ) ;
898
908
try {
899
909
if ( this . gitManager instanceof SimpleGit )
0 commit comments