Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Random Note Command #813

Merged
merged 2 commits into from Jun 11, 2021
Merged

feat:Random Note Command #813

merged 2 commits into from Jun 11, 2021

Conversation

jonathanyeung
Copy link
Contributor

Fixes #743

New Command to navigate to a random note.

@CLAassistant
Copy link

CLAassistant commented Jun 10, 2021

CLA assistant check
All committers have signed the CLA.

@@ -1,752 +1,757 @@
{
"name": "@dendronhq/plugin-core",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - did we do some 'prettier' or whitespace formatting changes recently to this file? The only material difference should be the addition of

            {
                "command": "dendron.randomNote",
                "title": "Dendron: Random Note",
                "desc": "Open a Random Note"
            },

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we did some formatting. no worries about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to merge as is? or would you prefer me to re-align to the whitespace changes currently in master?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the package generation code? specifically this should be changed to 2 spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -1,752 +1,757 @@
{
"name": "@dendronhq/plugin-core",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we did some formatting. no worries about this


type CommandInput = {};

type CommandOutput = void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a convention we've been following is to return the note as an output. makes it easy to test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, will adjust

}

let isMatch = false;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: prefer forEach syntax for conciseness. eg. includeSet.forEach( pattern => { ... } )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - doesn't seem like you can call break from within an interable.forEach() loop though: https://stackoverflow.com/questions/2641347/short-circuit-array-foreach-like-calling-break

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, good catch. in that case, feel free to use for or use _.some (we make liberal use of lodash as our utility library) https://lodash.com/docs/#some

} from "../testUtilsV3";

// common template function for RandomNoteCommand testing
function basicTest(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, new to Typescript - when I tried to switch to object notation, the parameters can no longer be referenced within runLegacyMultiWorkspaceTest(). Seems that the properties of opts aren't known in that context (Error is Object literal may only specify known properties, and 'opts' does not exist in type 'SetupCodeConfigurationV2...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... how did you do it? it should look like the following:

basicTest({ctx, preSetupHook, ...}: {
  ctx: ...
  preSetupHook: ...
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean now - adjusted

ctx,
preSetupHook: async ({ wsRoot, vaults }) => {
for (let name of noteNames) {
await CreateNoteFactory({ fname: name, body: "" }).create({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of exporting note factoring, you can use NoteTestUtilsV4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, will adjust and remove the export.

@kevinslin kevinslin merged commit 3c57c70 into master Jun 11, 2021
@kevinslin kevinslin deleted the feature-random-note branch June 11, 2021 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random note
3 participants