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

Desktop: Fixes #4411: Count tags based on showCompletedTodos setting #4957

Merged
merged 12 commits into from
May 27, 2021

Conversation

JackGruber
Copy link
Contributor

Count the completed todos at the tag sidebar based on the showCompletedTodos setting.

@JackGruber JackGruber changed the title Desktop: Fix #4411 Show tag cound based on showCompletedTodos setting Desktop: Fix #4411 Count tags based on showCompletedTodos setting May 13, 2021
@laurent22 laurent22 changed the title Desktop: Fix #4411 Count tags based on showCompletedTodos setting Desktop: Fixes #4411: Count tags based on showCompletedTodos setting May 13, 2021
@tessus tessus added the desktop All desktop platforms label May 14, 2021
@@ -448,7 +448,7 @@ class SidebarComponent extends React.Component<Props, State> {

renderTag(tag: any, selected: boolean) {
const anchorRef = this.anchorItemRef('tag', tag.id);
const noteCount = Setting.value('showNoteCounts') ? this.renderNoteCount(tag.note_count) : '';
const noteCount = Setting.value('showNoteCounts') ? Setting.value('showCompletedTodos') ? this.renderNoteCount(tag.note_count) : this.renderNoteCount(tag.note_count - tag.todo_completed_count) : '';
Copy link
Owner

Choose a reason for hiding this comment

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

Could you refactor this logic to avoid the nested ternary operators? This is to clarify a bit the logic.

packages/lib/JoplinDatabase.ts Show resolved Hide resolved
packages/app-cli/tests/models_Tag.ts Show resolved Hide resolved
@@ -123,21 +133,25 @@ describe('models_Tag', function() {
expect(commonTags.length).toBe(0);

commonTags = await Tag.commonTagsByNoteIds([note0.id, note1.id, note2.id, note3.id]);
// @ts-ignore
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need ts-ignore here?

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 can't figure out why I added the ts-ignore, I have removed them.

@JackGruber
Copy link
Contributor Author

Ok I have made the performance test on Android, with the following items count:

Note: 5345
Folder: 57
Resource: 8939
Tag: 1701
NoteTag: 18470
MasterKey: 0/0
Revision: 642/642
Total: 34512

No difference was noticeable on my Motorola X4, 5 second with screen with the DB version 37 and 5-6 seconds during the upgrade from 37 to 38.

Copy link
Owner

@laurent22 laurent22 left a comment

Choose a reason for hiding this comment

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

Brilliant, thanks for checking the performance on mobile! It seems it's when migrating the "notes" table that we can get this white screen on startup. Other than that, there's just a minor tweak to make and we can merge.

Comment on lines 135 to 155
commonTags = await Tag.commonTagsByNoteIds([note0.id, note1.id, note2.id, note3.id]);

let commonTagIds = commonTags.map(t => t.id);
expect(commonTagIds.length).toBe(0);

commonTags = await Tag.commonTagsByNoteIds([note1.id, note2.id, note3.id]);

commonTagIds = commonTags.map(t => t.id);
expect(commonTagIds.length).toBe(1);
expect(commonTagIds.includes(taga.id)).toBe(true);

commonTags = await Tag.commonTagsByNoteIds([note2.id, note3.id]);

commonTagIds = commonTags.map(t => t.id);
expect(commonTagIds.length).toBe(2);
expect(commonTagIds.includes(taga.id)).toBe(true);
expect(commonTagIds.includes(tagb.id)).toBe(true);

commonTags = await Tag.commonTagsByNoteIds([note3.id]);

commonTagIds = commonTags.map(t => t.id);
Copy link
Owner

Choose a reason for hiding this comment

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

It's a small thing, but you could you remove the white space changes please? Just to keep the diff and blame history simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done

@laurent22
Copy link
Owner

Looks good now, thanks @JackGruber!

@laurent22 laurent22 merged commit 2b28641 into laurent22:dev May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants