@@ -9,6 +9,7 @@ enum PluginState {
9
9
add ,
10
10
commit ,
11
11
push ,
12
+ conflicted ,
12
13
}
13
14
interface ObsidianGitSettings {
14
15
commitMessage : string ;
@@ -35,7 +36,7 @@ export default class ObsidianGit extends Plugin {
35
36
git : SimpleGit ;
36
37
settings : ObsidianGitSettings ;
37
38
statusBar : StatusBar ;
38
- state : PluginState = PluginState . idle ;
39
+ state : PluginState ;
39
40
intervalID : number ;
40
41
lastUpdate : number ;
41
42
gitReady = false ;
@@ -78,17 +79,16 @@ export default class ObsidianGit extends Plugin {
78
79
new ChangedFilesModal ( this , status . files ) . open ( ) ;
79
80
}
80
81
} ) ;
81
-
82
- this . init ( ) ;
83
-
84
82
// init statusBar
85
83
let statusBarEl = this . addStatusBarItem ( ) ;
86
84
this . statusBar = new StatusBar ( statusBarEl , this ) ;
87
- this . setState ( PluginState . idle ) ;
88
85
this . registerInterval (
89
86
window . setInterval ( ( ) => this . statusBar . display ( ) , 1000 )
90
87
) ;
91
88
89
+ this . init ( ) ;
90
+
91
+
92
92
}
93
93
async onunload ( ) {
94
94
console . log ( 'unloading ' + this . manifest . name + " plugin" ) ;
@@ -117,6 +117,7 @@ export default class ObsidianGit extends Plugin {
117
117
this . displayError ( "Valid git repository not found." ) ;
118
118
} else {
119
119
this . gitReady = true ;
120
+ this . setState ( PluginState . idle ) ;
120
121
121
122
if ( this . settings . autoPullOnBoot ) {
122
123
this . pullChangesFromRemote ( ) ;
@@ -329,6 +330,7 @@ export default class ObsidianGit extends Plugin {
329
330
} )
330
331
] ;
331
332
this . writeAndOpenFile ( lines . join ( "\n" ) ) ;
333
+ this . setState ( PluginState . conflicted ) ;
332
334
}
333
335
334
336
async writeAndOpenFile ( text : string ) {
@@ -634,6 +636,12 @@ class StatusBar {
634
636
case PluginState . pull :
635
637
this . statusBarEl . setText ( "git: pulling changes.." ) ;
636
638
break ;
639
+ case PluginState . conflicted :
640
+ this . statusBarEl . setText ( "git: you have conflict files.." ) ;
641
+ break ;
642
+ default :
643
+ this . statusBarEl . setText ( "git: not ready!" ) ;
644
+ break ;
637
645
}
638
646
}
639
647
0 commit comments