@@ -56,6 +56,30 @@ export default class TimeTreePlugin extends Plugin {
56
56
} ,
57
57
} ) ;
58
58
59
+ this . addCommand ( {
60
+ id : "change-status-todo" ,
61
+ name : "Change status to todo" ,
62
+ callback : async ( ) => {
63
+ await this . changeStatus ( "todo" ) ;
64
+ } ,
65
+ } ) ;
66
+
67
+ this . addCommand ( {
68
+ id : "change-status-doing" ,
69
+ name : "Change status to doing" ,
70
+ callback : async ( ) => {
71
+ await this . changeStatus ( "doing" ) ;
72
+ } ,
73
+ } ) ;
74
+
75
+ this . addCommand ( {
76
+ id : "change-status-done" ,
77
+ name : "Change status to done" ,
78
+ callback : async ( ) => {
79
+ await this . changeStatus ( "done" ) ;
80
+ } ,
81
+ } ) ;
82
+
59
83
this . buttonObserver = new MutationObserver ( ( mutations ) => {
60
84
mutations . forEach ( ( mutation ) => {
61
85
mutation . addedNodes . forEach ( ( node ) => {
@@ -196,6 +220,22 @@ export default class TimeTreePlugin extends Plugin {
196
220
editor . setCursor ( { line : cursor . line , ch : cursor . ch + 4 } ) ;
197
221
}
198
222
223
+ async changeStatus ( status : string ) : Promise < void > {
224
+ const activeFile = this . app . workspace . getActiveFile ( ) ;
225
+ if ( ! activeFile ) {
226
+ new Notice ( "No active file found." ) ;
227
+ return ;
228
+ }
229
+ await this . frontMatterManager . updateProperty (
230
+ activeFile ,
231
+ ( frontmatter ) => {
232
+ frontmatter . status = status ;
233
+ return frontmatter ;
234
+ }
235
+ ) ;
236
+ new Notice ( `Updated status to ${ status } ` ) ;
237
+ }
238
+
199
239
scheduleComputeTimeTree ( ) : void {
200
240
// Clear any existing interval
201
241
if ( this . computeIntervalHandle ) {
0 commit comments