Action

clean done items in list

Posted by FlohGro, Last update almost 3 years ago

UPDATES

almost 3 years ago

description update

created by @FlohGro / more on my Blog

clean done items in list

This action removes all done items from a list

[Configuration]

no configuration needed

[Usage]

When you run this action all done items in a list will be removed. The lines

This action works best when you use it together with the Show List action. Then you can quickly open a list, check of items already done and then run this action to clean everything up.


If you find this useful and want to support me you can

Buy Me A Coffee

Steps

  • script

    // clean done items in simple list
    // break draft into lines
    
    var lines = draft.content.split("\n");
    var begin = '';
    var end = '';
    var c = "- [x]";
    
    // sort lines based on their leading characters
    
    for(var line of lines){
    	var check = line.includes(c);
    	// if line contains c:
    	if (check) {
    		//ignore line
    //		end += line + "\n";
    	} else if ( line.includes("## done")){
    		//ignore line!
    	} 
    	else{
    		begin += line + "\n";
    	}
    }
    
    // recompile / reorder draft
    begin = begin.slice(0,-1);
    end = end.slice(0,-1);
    editor.setText(begin + "\n");
    draft.update();
    editor.focus(draft); 

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.