refactor: better format

This commit is contained in:
Antonella Sgarlatta
2021-05-05 11:31:04 -03:00
parent bffe63cc3c
commit e5750e88c6
3 changed files with 41 additions and 29 deletions

View File

@@ -1,13 +1,5 @@
import {
ContentType,
SNSmartTag,
SNTag,
} from '@standardnotes/snjs';
import {
action,
makeObservable,
observable,
} from 'mobx';
import { ContentType, SNSmartTag, SNTag } from '@standardnotes/snjs';
import { action, makeObservable, observable } from 'mobx';
import { WebApplication } from '../application';
export class TagsState {
@@ -28,20 +20,25 @@ export class TagsState {
this.application.streamItems(
[ContentType.Tag, ContentType.SmartTag],
async () => {
this.tags = this.application.getDisplayableItems(ContentType.Tag) as SNTag[];
this.tags = this.application.getDisplayableItems(
ContentType.Tag
) as SNTag[];
this.smartTags = this.application.getSmartTags();
}
),
)
);
}
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
const selectedNotes = Object.values(this.application.getAppState().notes.selectedNotes);
const selectedNotes = Object.values(
this.application.getAppState().notes.selectedNotes
);
await Promise.all(
selectedNotes.map(async note =>
await this.application.changeItem(tag.uuid, (mutator) => {
mutator.addItemAsRelationship(note);
})
selectedNotes.map(
async (note) =>
await this.application.changeItem(tag.uuid, (mutator) => {
mutator.addItemAsRelationship(note);
})
)
);
this.application.sync();