Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

feat: notes display criteria #232

Merged
merged 10 commits into from
Mar 4, 2021
Merged

feat: notes display criteria #232

merged 10 commits into from
Mar 4, 2021

Conversation

moughxyz
Copy link
Member

@moughxyz moughxyz commented Mar 4, 2021

No description provided.

@@ -65,6 +65,20 @@ describe('payload collections', () => {
expect(collection.conflictsOf(payload.uuid)).to.eql([manualResults]);
});

it.skip('setting same element twice should not yeild duplicates', async () => {
Copy link
Member Author

@moughxyz moughxyz Mar 4, 2021

Choose a reason for hiding this comment

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

This test doesn't pass, and is a new one created to catch a pre-existing issue. I didn't want to modify this behavior in this PR, so marked it as skip for now.

Copy link
Contributor

@arielsvg arielsvg left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@arielsvg arielsvg left a comment

Choose a reason for hiding this comment

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

Last thoughts are up for your consideration but my opinions are weakly-held there :) Don't forget to update package.json version before merging

public subFilter?: (element: any) => boolean;

static CreateCriteria(
initializer: (criteria: NotesDisplayCriteria) => void
Copy link
Contributor

Choose a reason for hiding this comment

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

With Partial<NotesDisplayCriteria> you can do this:

NotesDisplayCriteria.Create({
  includePinned: true
});

The object doesn't have to be an instance of NotesDisplayCriteria, it just has to respond identically to its property calls. See how only the last call in this example is invalid: https://www.typescriptlang.org/play?#code/MYGwhgzhAEAqAWBLAdgc2gbwFDWgBwFcAjERYaAMwHsroBeSsECAUwG4d9jTyiwAnetAAu-AuywBfLFgoFkwYYirIRYANYsICFKgAUwpGgBc0AAoClTADw60APgCUmTsBUQqIFgDoQVfYa63tRUjhzSWMIaWnb6GJJhkdHaRnGcIaai4lKJUZopunrYuHz8mWIsORx5MalFnKWmAEQA7ioA5MLQbgC2eIheTVVAA

In the end both approaches look kind of similar on the calling site and I don't hold a strong opinion either way, especially since this pattern also exists in other parts of the app. Just wanted to throw this at you in case you thought going the "pass an object" approach was impossible with TypeScript :)

sortBy?: CollectionSort,
direction?: SortDirection,
filter?: (element: SNNote) => boolean
public setNotesDisplayCriteria(
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that SNApplication.setDisplayOptions() (the more generic method that covers everything except for notes, a couple of lines above) should be renamed to SNApplication.setDisplayCriteria(), because while the method signature is different the intent is the same.

@moughxyz
Copy link
Member Author

moughxyz commented Mar 4, 2021

The object doesn't have to be an instance of NotesDisplayCriteria, it just has to respond identically to its property calls

Yeah you're right, this is a cleaner approach. Will update.

@moughxyz
Copy link
Member Author

moughxyz commented Mar 4, 2021

I meant that SNApplication.setDisplayOptions() should be renamed to SNApplication.setDisplayCriteria()

Oh, the only thing is that display criteria right now is just for notes. Only NotesDisplayCriteria exists.

@moughxyz moughxyz merged commit 51f3f07 into master Mar 4, 2021
@moughxyz moughxyz deleted the search-refactor branch March 4, 2021 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants