Action

Cycle Workspace REV

Posted by @nahumck, Last update 20 days ago - Unlisted

Original idea from the Drafts Forum, but adding workspace.reverse() after the first line to reverse the workspace array to cycle the workspaces in reverse. Credit to @jsamlarose for creating the original base action!

Steps

  • script

    workspaces = Workspace.getAll();
    workspaces.reverse();
    
    // get index of object by property (https://stackoverflow.com/a/39529049)
    var index = workspaces.findIndex(item => item.name === app.currentWorkspace.name)
    
    if (index == -1 || index == workspaces.length-1){
    	var workspace = Workspace.find(workspaces[0].name)
    } else {
    	index++
    	var workspace = Workspace.find(workspaces[index].name)
    }
    
    app.applyWorkspace(workspace)
    app.showDraftList()
    // app.displayInfoMessage(workspace.name)
    // alert(workspace.name + "," + index)
    

Options

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