@@ -740,6 +740,11 @@ export default class ObsidianGit extends Plugin {
740
740
return Platform . isDesktopApp ;
741
741
}
742
742
743
+ hasConnectivity ( ) {
744
+ if ( navigator . onLine ) return true ;
745
+ return ( new Notice ( 'No Connectivity' ) , false )
746
+ }
747
+
743
748
async init ( ) : Promise < void > {
744
749
this . showNotices ( ) ;
745
750
@@ -926,6 +931,7 @@ export default class ObsidianGit extends Plugin {
926
931
///Used for command
927
932
async pullChangesFromRemote ( ) : Promise < void > {
928
933
if ( ! ( await this . isAllInitialized ( ) ) ) return ;
934
+ if ( ! ( this . hasConnectivity ( ) ) ) return ;
929
935
930
936
const filesUpdated = await this . pull ( ) ;
931
937
this . setUpAutoBackup ( ) ;
@@ -956,10 +962,13 @@ export default class ObsidianGit extends Plugin {
956
962
) : Promise < void > {
957
963
if ( ! ( await this . isAllInitialized ( ) ) ) return ;
958
964
965
+ const isConnected = this . hasConnectivity ( ) ;
966
+
959
967
if (
960
968
this . settings . syncMethod == "reset" &&
961
969
this . settings . pullBeforePush
962
970
) {
971
+ if ( ! isConnected ) return ;
963
972
await this . pull ( ) ;
964
973
}
965
974
@@ -975,6 +984,7 @@ export default class ObsidianGit extends Plugin {
975
984
if ( ! this . settings . disablePush ) {
976
985
// Prevent plugin to pull/push at every call of createBackup. Only if unpushed commits are present
977
986
if ( await this . gitManager . canPush ( ) ) {
987
+ if ( ! isConnected ) return ;
978
988
if (
979
989
this . settings . syncMethod != "reset" &&
980
990
this . settings . pullBeforePush
@@ -1166,9 +1176,9 @@ export default class ObsidianGit extends Plugin {
1166
1176
1167
1177
async push ( ) : Promise < boolean > {
1168
1178
if ( ! ( await this . isAllInitialized ( ) ) ) return false ;
1169
- if ( ! ( await this . remotesAreSet ( ) ) ) {
1170
- return false ;
1171
- }
1179
+ if ( ! ( await this . remotesAreSet ( ) ) ) return false ;
1180
+ if ( ! ( this . hasConnectivity ( ) ) ) return false ;
1181
+
1172
1182
const hadConflict = this . localStorage . getConflict ( ) ;
1173
1183
if ( this . gitManager instanceof SimpleGit )
1174
1184
await this . mayDeleteConflictFile ( ) ;
0 commit comments