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

Show more than first line in note list preview #1647

Merged
merged 4 commits into from
Oct 31, 2019

Conversation

belcherj
Copy link
Contributor

@belcherj belcherj commented Oct 16, 2019

Fix

fixes: #235

The regex that captures the note list preview was only selecting the first line. This selects the remainder of the note. That string then gets sliced down to the previewCharacterLimit.

This PR also decreases the performance cost of creating the title and preview from 1ms to 0.2ms.

Test

  1. Load production
  2. Have note that has a few characters per line for a couple of lines
  3. Have Settings -> Display -> Note Display set to Expanded
  4. Observe only the first line of text is shown
  5. Do the same on the this branch
  6. Observe that multiple lines are shown up to 300 characters
  7. This is the same as the Android app

Before:
Screen Shot 2019-10-18 at 10 53 21 AM
After:
Screen Shot 2019-10-18 at 10 53 29 AM

Review

Only one developer ais required to review these changes, but anyone can perform the review.

Release

RELEASE-NOTES.txt was updated with:

  • Fixed bug that only shows the first line of text in note list preview

@belcherj belcherj added this to the 1.10 milestone Oct 16, 2019
@belcherj belcherj requested a review from a team October 16, 2019 19:16
@belcherj belcherj self-assigned this Oct 16, 2019
lib/utils/note-utils.js Outdated Show resolved Hide resolved
@belcherj
Copy link
Contributor Author

Used the Dennis solution.

@belcherj belcherj requested a review from a team October 18, 2019 14:52
@belcherj
Copy link
Contributor Author

Hold off on reviews. I need to fix the remove markdown functionality.

@belcherj
Copy link
Contributor Author

I looked at how many times this actually gets called. It only gets called a dozen or so times for the items in the list that are visible. Let's get this fixed in.

lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
@dmsnell dmsnell force-pushed the fix/include-multiple-lines-in-excerpt branch from 4b84e2f to 89c68f8 Compare October 21, 2019 21:11
dmsnell added a commit that referenced this pull request Oct 22, 2019
Replaces #1647

fixes: #235

The regex that captures the note list preview was only selecting the first line. This selects the remainder of the note.  That string then gets sliced down to the `previewCharacterLimit`.

This PR also decreases the performance cost of creating the title and preview from 1ms to 0.2ms.

1. Load production
2. Have note that has a few characters per line for a couple of lines
3. Have Settings -> Display -> Note Display set to Expanded
4. Observe only the first line of text is shown
5. Do the same on the this branch
6. Observe that multiple lines are shown up to 300 characters
7. This is the same as the Android app

**Before:**
<img width="331" alt="Screen Shot 2019-10-18 at 10 53 21 AM" src="https://user-images.githubusercontent.com/6817400/67104796-9690bd80-f195-11e9-959a-1edc18f58030.png">
**After:**
<img width="329" alt="Screen Shot 2019-10-18 at 10 53 29 AM" src="https://user-images.githubusercontent.com/6817400/67104797-9690bd80-f195-11e9-9c17-282747d9a7da.png">

Only one developer ais required to review these changes, but anyone can perform the review.

`RELEASE-NOTES.txt` was updated with:

- Fixed bug that only shows the first line of text in note list preview
@dmsnell dmsnell force-pushed the fix/include-multiple-lines-in-excerpt branch from 89c68f8 to b3deb68 Compare October 22, 2019 18:37
dmsnell added a commit that referenced this pull request Oct 27, 2019
Replaces #1647

fixes: #235

The regex that captures the note list preview was only selecting the first line. This selects the remainder of the note.  That string then gets sliced down to the `previewCharacterLimit`.

This PR also decreases the performance cost of creating the title and preview from 1ms to 0.2ms.

1. Load production
2. Have note that has a few characters per line for a couple of lines
3. Have Settings -> Display -> Note Display set to Expanded
4. Observe only the first line of text is shown
5. Do the same on the this branch
6. Observe that multiple lines are shown up to 300 characters
7. This is the same as the Android app

**Before:**
<img width="331" alt="Screen Shot 2019-10-18 at 10 53 21 AM" src="https://user-images.githubusercontent.com/6817400/67104796-9690bd80-f195-11e9-959a-1edc18f58030.png">
**After:**
<img width="329" alt="Screen Shot 2019-10-18 at 10 53 29 AM" src="https://user-images.githubusercontent.com/6817400/67104797-9690bd80-f195-11e9-9c17-282747d9a7da.png">

Only one developer ais required to review these changes, but anyone can perform the review.

`RELEASE-NOTES.txt` was updated with:

- Fixed bug that only shows the first line of text in note list preview
@dmsnell dmsnell force-pushed the fix/include-multiple-lines-in-excerpt branch from b3deb68 to f419154 Compare October 27, 2019 01:15
Replaces #1647

fixes: #235

The regex that captures the note list preview was only selecting the first line. This selects the remainder of the note.  That string then gets sliced down to the `previewCharacterLimit`.

This PR also decreases the performance cost of creating the title and preview from 1ms to 0.2ms.

1. Load production
2. Have note that has a few characters per line for a couple of lines
3. Have Settings -> Display -> Note Display set to Expanded
4. Observe only the first line of text is shown
5. Do the same on the this branch
6. Observe that multiple lines are shown up to 300 characters
7. This is the same as the Android app

**Before:**
<img width="331" alt="Screen Shot 2019-10-18 at 10 53 21 AM" src="https://user-images.githubusercontent.com/6817400/67104796-9690bd80-f195-11e9-959a-1edc18f58030.png">
**After:**
<img width="329" alt="Screen Shot 2019-10-18 at 10 53 29 AM" src="https://user-images.githubusercontent.com/6817400/67104797-9690bd80-f195-11e9-9c17-282747d9a7da.png">

Only one developer ais required to review these changes, but anyone can perform the review.

`RELEASE-NOTES.txt` was updated with:

- Fixed bug that only shows the first line of text in note list preview
@dmsnell dmsnell force-pushed the fix/include-multiple-lines-in-excerpt branch from f419154 to 192e3bf Compare October 28, 2019 15:05
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
lib/utils/note-utils.js Outdated Show resolved Hide resolved
@belcherj belcherj merged commit f6ac7ed into develop Oct 31, 2019
@belcherj belcherj deleted the fix/include-multiple-lines-in-excerpt branch October 31, 2019 14:39
dmsnell added a commit that referenced this pull request Jan 16, 2020
Tests have been failing because `noteTitleAndPreview` is reported to be taking
longer than 1ms to run. In fact, `Date.now()`, which we were using to validate
this, includes reduced time precision for protection against timing attacks. In
this patch I've done two things to address the failing tests:
 - Replace `Date.now()` with `process.hrtime()` which gives us nanosecond
   precision
 - Run the function-under-test 100 times in order to eliminate variance in the
   measurement

While fixing this test I noted a flaw in `noteTitleAndPreview` that we missed
in #1647. We created the helper function `removeMarkdownFromOutput` which
transforms a string based on whether or not markdown is enabled for the note.
Unfortunately for us we were setting a module-global function based on the
module-init-time value `isMarkdown`, which as a function is always truthy,
meaning that it would return a function that alwasy removed markdown regardless
of the note.

In this patch I've addressed this by passing `stripMarkdown` into that
function. In the PR for #1647 we discussed this parameter and removed it but we
kept `removeMarkdownFromOutput` outside the scope of `noteTitleAndPreview`. We
could leave out the parameter and move the function into `noteTitleAndPreview`
or we could add the parameter back.

For the purpose of only creating that function once I have added the parameter
back in. `noteTitleAndPreview` gets called in some inner loops and I preferred
to avoid recreating the filtering function on every call, or at least until the
JIT figured it out; I'm sure that the performance impact is insignificant but I
don't see any benefit to one way over the other and I'd rather do less work as
the default.
dmsnell added a commit that referenced this pull request Jan 16, 2020
Tests have been failing because `noteTitleAndPreview` is reported to be taking
longer than 1ms to run. In fact, `Date.now()`, which we were using to validate
this, includes reduced time precision for protection against timing attacks. In
this patch I've done two things to address the failing tests:
 - Replace `Date.now()` with `process.hrtime()` which gives us nanosecond
   precision
 - Run the function-under-test 100 times in order to eliminate variance in the
   measurement

While fixing this test I noted a flaw in `noteTitleAndPreview` that we missed
in #1647. We created the helper function `removeMarkdownFromOutput` which
transforms a string based on whether or not markdown is enabled for the note.
Unfortunately for us we were setting a module-global function based on the
module-init-time value `isMarkdown`, which as a function is always truthy,
meaning that it would return a function that alwasy removed markdown regardless
of the note.

In this patch I've addressed this by passing `stripMarkdown` into that
function. In the PR for #1647 we discussed this parameter and removed it but we
kept `removeMarkdownFromOutput` outside the scope of `noteTitleAndPreview`. We
could leave out the parameter and move the function into `noteTitleAndPreview`
or we could add the parameter back.

For the purpose of only creating that function once I have added the parameter
back in. `noteTitleAndPreview` gets called in some inner loops and I preferred
to avoid recreating the filtering function on every call, or at least until the
JIT figured it out; I'm sure that the performance impact is insignificant but I
don't see any benefit to one way over the other and I'd rather do less work as
the default.
dmsnell added a commit that referenced this pull request Jan 17, 2020
Tests have been failing because `noteTitleAndPreview` is reported to be taking
longer than 1ms to run. In fact, `Date.now()`, which we were using to validate
this, includes reduced time precision for protection against timing attacks. In
this patch I've done two things to address the failing tests:
 - Replace `Date.now()` with `process.hrtime()` which gives us nanosecond
   precision
 - Run the function-under-test 100 times in order to eliminate variance in the
   measurement

While fixing this test I noted a flaw in `noteTitleAndPreview` that we missed
in #1647. We created the helper function `removeMarkdownFromOutput` which
transforms a string based on whether or not markdown is enabled for the note.
Unfortunately for us we were setting a module-global function based on the
module-init-time value `isMarkdown`, which as a function is always truthy,
meaning that it would return a function that alwasy removed markdown regardless
of the note.

In this patch I've addressed this by passing `stripMarkdown` into that
function. In the PR for #1647 we discussed this parameter and removed it but we
kept `removeMarkdownFromOutput` outside the scope of `noteTitleAndPreview`. We
could leave out the parameter and move the function into `noteTitleAndPreview`
or we could add the parameter back.

For the purpose of only creating that function once I have added the parameter
back in. `noteTitleAndPreview` gets called in some inner loops and I preferred
to avoid recreating the filtering function on every call, or at least until the
JIT figured it out; I'm sure that the performance impact is insignificant but I
don't see any benefit to one way over the other and I'd rather do less work as
the default.
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.

Note display: number of lines vary for Expanded display
2 participants