Action

open flagged draft

Posted by FlohGro, Last update about 1 month ago

created by @FlohGro / more on my Blog

Quickly open a flagged draft. Displays a prompt to select the draft if more than one is flagged. If only one draft is flagged, it will be opened directly. If no draft is flagged, only an info message is displayed


If you find this useful and want to support me you can donate or buy me a coffee

Buy Me A Coffee

Steps

  • script

    // open flagged draft 1.0
    // created by @FlohGro@social.lol
    
    let flaggedDrafts = Draft.query("", "flagged", [], [], "accessed", true, false);
    
    let draftToOpen = undefined;
    
    switch (flaggedDrafts.length) {
        case 0: app.displayInfoMessage("no flagged drafts found"); break;
        case 1: draftToOpen = flaggedDrafts[0]; break;
        default: draftToOpen = selectDraftToOpen(flaggedDrafts)
    }
    
    if (draftToOpen != undefined) {
        editor.load(draftToOpen)
    }
    
    function selectDraftToOpen(drafts) {
        let p = new Prompt()
        p.title = "select draft"
        for (let d of drafts) {
            p.addButton(d.displayTitle, d)
        }
        if (p.show()) {
            return p.buttonPressed
        } else {
            return undefined
        }
    }

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.