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

Commit

Permalink
refactor: allow countable over smarttags
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Jan 17, 2022
1 parent 7945488 commit 2fda84d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/snjs/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ export class SNApplication {
return this.itemManager.allCountableNotesCount();
}

public countableNotesForTag(tag: SNTag): number {
public countableNotesForTag(tag: SNTag | SNSmartTag): number {
return this.itemManager.countableNotesForTag(tag);
}

Expand Down
21 changes: 13 additions & 8 deletions packages/snjs/lib/services/item_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,35 @@ import { CreateMaxPayloadFromAnyObject } from '@Payloads/generator';
import {
CollectionSort,
ItemCollection,
SortDirection
SortDirection,
} from '@Protocol/collection/item_collection';
import { ContentType } from '@standardnotes/common'
import { ContentType } from '@standardnotes/common';
import { ComponentMutator } from './../models/app/component';
import {
ActionsExtensionMutator,
SNActionsExtension
SNActionsExtension,
} from './../models/app/extension';
import {
FeatureRepoMutator,
SNFeatureRepo
SNFeatureRepo,
} from './../models/app/feature_repo';
import { ItemsKeyMutator } from './../models/app/items_key';
import { NoteMutator, SNNote } from './../models/app/note';
import {
SmartTagPredicateContent,
SMART_TAG_DSL_PREFIX,
SNSmartTag
SNSmartTag,
} from './../models/app/smartTag';
import { TagMutator } from './../models/app/tag';
import { ItemMutator, MutationType, SNItem } from './../models/core/item';
import { SNPredicate } from './../models/core/predicate';
import {
TagNoteCountChangeObserver, TagNotesIndex
TagNoteCountChangeObserver,
TagNotesIndex,
} from './../protocol/collection/tag_notes_index';
import {
PayloadContent,
PayloadOverride
PayloadOverride,
} from './../protocol/payloads/generator';
import { PurePayload } from './../protocol/payloads/pure_payload';
import { PayloadSource } from './../protocol/payloads/sources';
Expand Down Expand Up @@ -272,8 +273,12 @@ export class ItemManager extends PureService {
return this.tagNotesIndex.allCountableNotesCount();
}

public countableNotesForTag(tag: SNTag): number {
public countableNotesForTag(tag: SNTag | SNSmartTag): number {
if (tag.isSmartTag) {
if (tag.isAllTag) {
return this.tagNotesIndex.allCountableNotesCount();
}

throw Error(
'countableNotesForTag is not meant to be used for smart tags.'
);
Expand Down

0 comments on commit 2fda84d

Please sign in to comment.