chore: upgrade deps

This commit is contained in:
Mo
2022-03-21 14:31:42 -05:00
parent ea0ca7dc18
commit 9f032f13c2
27 changed files with 143 additions and 183 deletions

View File

@@ -89,7 +89,7 @@ export class AccountMenuState {
this.appEventListeners.push(
this.application.streamItems([ContentType.Note, ContentType.Tag], () => {
runInAction(() => {
this.notesAndTags = this.application.getItems([
this.notesAndTags = this.application.items.getItems([
ContentType.Note,
ContentType.Tag,
]);

View File

@@ -307,7 +307,7 @@ export class AppState {
return;
}
if (this.application.isTemplateItem(tag)) {
if (this.application.items.isTemplateItem(tag)) {
return;
}
@@ -436,9 +436,11 @@ export class AppState {
/** Returns the tags that are referncing this note */
public getNoteTags(note: SNNote) {
return this.application.referencingForItem(note).filter((ref) => {
return ref.content_type === ContentType.Tag;
}) as SNTag[];
return this.application.items
.itemsReferencingItem(note.uuid)
.filter((ref) => {
return ref.content_type === ContentType.Tag;
}) as SNTag[];
}
panelDidResize(name: string, collapsed: boolean) {

View File

@@ -1,6 +1,6 @@
import { storage, StorageKey } from "@/services/localStorage";
import { SNApplication, ApplicationEvent } from "@standardnotes/snjs";
import { runInAction, makeObservable, observable, action } from "mobx";
import { storage, StorageKey } from '@/services/localStorage';
import { SNApplication, ApplicationEvent } from '@standardnotes/snjs';
import { runInAction, makeObservable, observable, action } from 'mobx';
export class NoAccountWarningState {
show: boolean;
@@ -33,9 +33,9 @@ export class NoAccountWarningState {
hide = (): void => {
this.show = false;
storage.set(StorageKey.ShowNoAccountWarning, false);
}
};
reset = (): void => {
storage.remove(StorageKey.ShowNoAccountWarning);
}
};
}

View File

@@ -170,7 +170,7 @@ export class NoteTagsState {
}
searchActiveNoteAutocompleteTags(): void {
const newResults = this.application.searchTags(
const newResults = this.application.items.searchTags(
this.autocompleteSearchQuery,
this.activeNote
);
@@ -184,7 +184,7 @@ export class NoteTagsState {
reloadTags(): void {
const { activeNote } = this;
if (activeNote) {
const tags = this.application.getSortedTagsForNote(activeNote);
const tags = this.application.items.getSortedTagsForNote(activeNote);
this.setTags(tags);
}
}
@@ -224,7 +224,7 @@ export class NoteTagsState {
}
getSortedTagsForNote(note: SNNote): SNTag[] {
const tags = this.application.getSortedTagsForNote(note);
const tags = this.application.items.getSortedTagsForNote(note);
const sortFunction = (tagA: SNTag, tagB: SNTag): number => {
const a = this.getLongTitle(tagA);
@@ -243,10 +243,10 @@ export class NoteTagsState {
}
getPrefixTitle(tag: SNTag): string | undefined {
return this.application.getTagPrefixTitle(tag);
return this.application.items.getTagPrefixTitle(tag);
}
getLongTitle(tag: SNTag): string {
return this.application.getTagLongTitle(tag);
return this.application.items.getTagLongTitle(tag);
}
}

View File

@@ -81,11 +81,11 @@ export class NotesState {
}
get trashedNotesCount(): number {
return this.application.getTrashedItems().length;
return this.application.items.trashedItems.length;
}
private async selectNotesRange(selectedNote: SNNote): Promise<void> {
const notes = this.application.getDisplayableItems(
const notes = this.application.items.getDisplayableItems(
ContentType.Note
) as SNNote[];
const lastSelectedNoteIndex = notes.findIndex(
@@ -117,7 +117,7 @@ export class NotesState {
}
async selectNote(uuid: UuidString, userTriggered?: boolean): Promise<void> {
const note = this.application.findItem(uuid) as SNNote;
const note = this.application.items.findItem(uuid) as SNNote;
if (!note) {
return;
}
@@ -163,7 +163,9 @@ export class NotesState {
return;
}
const note = this.application.findItem(noteUuid) as SNNote | undefined;
const note = this.application.items.findItem(noteUuid) as
| SNNote
| undefined;
if (!note) {
console.warn('Tried accessing a non-existant note of UUID ' + noteUuid);
return;
@@ -408,7 +410,7 @@ export class NotesState {
async addTagToSelectedNotes(tag: SNTag): Promise<void> {
const selectedNotes = Object.values(this.selectedNotes);
const parentChainTags = this.application.getTagParentChain(tag);
const parentChainTags = this.application.items.getTagParentChain(tag.uuid);
const tagsToAdd = [...parentChainTags, tag];
await Promise.all(
tagsToAdd.map(async (tag) => {

View File

@@ -223,7 +223,7 @@ export class NotesViewState {
if (!tag) {
return;
}
const notes = this.application.getDisplayableItems(
const notes = this.application.items.getDisplayableItems(
ContentType.Note
) as SNNote[];
const renderedNotes = notes.slice(0, this.notesToDisplay);
@@ -264,7 +264,7 @@ export class NotesViewState {
this.appState.searchOptions.includeProtectedContents,
},
});
this.application.setNotesDisplayCriteria(criteria);
this.application.items.setNotesDisplayCriteria(criteria);
};
reloadPreferences = () => {

View File

@@ -1,5 +1,5 @@
import { SyncOpStatus } from "@standardnotes/snjs";
import { action, makeObservable, observable } from "mobx";
import { SyncOpStatus } from '@standardnotes/snjs';
import { action, makeObservable, observable } from 'mobx';
export class SyncState {
inProgress = false;
@@ -32,5 +32,5 @@ export class SyncState {
{ style: 'percent' }
);
}
}
};
}

View File

@@ -29,9 +29,11 @@ import { FeaturesState, SMART_TAGS_FEATURE_NAME } from './features_state';
type AnyTag = SNTag | SmartView;
const rootTags = (application: SNApplication): SNTag[] => {
const hasNoParent = (tag: SNTag) => !application.getTagParent(tag);
const hasNoParent = (tag: SNTag) => !application.items.getTagParent(tag.uuid);
const allTags = application.getDisplayableItems(ContentType.Tag) as SNTag[];
const allTags = application.items.getDisplayableItems(
ContentType.Tag
) as SNTag[];
const rootTags = allTags.filter(hasNoParent);
return rootTags;
@@ -41,11 +43,11 @@ const tagSiblings = (application: SNApplication, tag: SNTag): SNTag[] => {
const withoutCurrentTag = (tags: SNTag[]) =>
tags.filter((other) => other.uuid !== tag.uuid);
const isTemplateTag = application.isTemplateItem(tag);
const parentTag = !isTemplateTag && application.getTagParent(tag);
const isTemplateTag = application.items.isTemplateItem(tag);
const parentTag = !isTemplateTag && application.items.getTagParent(tag.uuid);
if (parentTag) {
const siblingsAndTag = application.getTagChildren(parentTag);
const siblingsAndTag = application.items.getTagChildren(parentTag.uuid);
return withoutCurrentTag(siblingsAndTag);
}
@@ -101,7 +103,7 @@ export class TagsState {
this.editing_ = undefined;
this.addingSubtagTo = undefined;
this.smartViews = this.application.getSmartViews();
this.smartViews = this.application.items.getSmartViews();
this.selected_ = this.smartViews[0];
makeObservable(this, {
@@ -148,10 +150,10 @@ export class TagsState {
[ContentType.Tag, ContentType.SmartView],
(items) => {
runInAction(() => {
this.tags = this.application.getDisplayableItems<SNTag>(
this.tags = this.application.items.getDisplayableItems<SNTag>(
ContentType.Tag
);
this.smartViews = this.application.getSmartViews();
this.smartViews = this.application.items.getSmartViews();
const selectedTag = this.selected_;
if (selectedTag && !isSystemView(selectedTag as SmartView)) {
@@ -174,12 +176,14 @@ export class TagsState {
);
appEventListeners.push(
this.application.addNoteCountChangeObserver((tagUuid) => {
this.application.items.addNoteCountChangeObserver((tagUuid) => {
if (!tagUuid) {
this.setAllNotesCount(this.application.allCountableNotesCount());
this.setAllNotesCount(
this.application.items.allCountableNotesCount()
);
} else {
this.tagsCountsState.update([
this.application.findItem(tagUuid) as SNTag,
this.application.items.findItem(tagUuid) as SNTag,
]);
}
})
@@ -198,7 +202,7 @@ export class TagsState {
title
)) as SNTag;
const futureSiblings = this.application.getTagChildren(parent);
const futureSiblings = this.application.items.getTagChildren(parent.uuid);
if (!isValidFutureSiblings(this.application, futureSiblings, createdTag)) {
this.setAddingSubtagTo(undefined);
@@ -299,7 +303,7 @@ export class TagsState {
public get allLocalRootTags(): SNTag[] {
if (
this.editing_ instanceof SNTag &&
this.application.isTemplateItem(this.editing_)
this.application.items.isTemplateItem(this.editing_)
) {
return [this.editing_, ...this.rootTags];
}
@@ -311,11 +315,11 @@ export class TagsState {
}
getChildren(tag: SNTag): SNTag[] {
if (this.application.isTemplateItem(tag)) {
if (this.application.items.isTemplateItem(tag)) {
return [];
}
const children = this.application.getTagChildren(tag);
const children = this.application.items.getTagChildren(tag.uuid);
const childrenUuids = children.map((childTag) => childTag.uuid);
const childrenTags = this.tags.filter((tag) =>
@@ -325,11 +329,11 @@ export class TagsState {
}
isValidTagParent(parentUuid: UuidString, tagUuid: UuidString): boolean {
return this.application.isValidTagParent(parentUuid, tagUuid);
return this.application.items.isValidTagParent(parentUuid, tagUuid);
}
public hasParent(tagUuid: UuidString): boolean {
const item = this.application.findItem(tagUuid);
const item = this.application.items.findItem(tagUuid);
return !!item && !!(item as SNTag).parentId;
}
@@ -337,9 +341,9 @@ export class TagsState {
tagUuid: string,
futureParentUuid: string | undefined
): Promise<void> {
const tag = this.application.findItem(tagUuid) as SNTag;
const tag = this.application.items.findItem(tagUuid) as SNTag;
const currentParent = this.application.getTagParent(tag);
const currentParent = this.application.items.getTagParent(tag.uuid);
const currentParentUuid = currentParent?.uuid;
if (currentParentUuid === futureParentUuid) {
@@ -348,7 +352,7 @@ export class TagsState {
const futureParent =
futureParentUuid &&
(this.application.findItem(futureParentUuid) as SNTag);
(this.application.items.findItem(futureParentUuid) as SNTag);
if (!futureParent) {
const futureSiblings = rootTags(this.application);
@@ -357,7 +361,9 @@ export class TagsState {
}
await this.application.mutator.unsetTagParent(tag);
} else {
const futureSiblings = this.application.getTagChildren(futureParent);
const futureSiblings = this.application.items.getTagChildren(
futureParent.uuid
);
if (!isValidFutureSiblings(this.application, futureSiblings, tag)) {
return;
}
@@ -368,7 +374,9 @@ export class TagsState {
}
get rootTags(): SNTag[] {
return this.tags.filter((tag) => !this.application.getTagParent(tag));
return this.tags.filter(
(tag) => !this.application.items.getTagParent(tag.uuid)
);
}
get tagsCount(): number {
@@ -432,7 +440,7 @@ export class TagsState {
public async createNewTemplate() {
const isAlreadyEditingATemplate =
this.editing_ && this.application.isTemplateItem(this.editing_);
this.editing_ && this.application.items.isTemplateItem(this.editing_);
if (isAlreadyEditingATemplate) {
return;
@@ -470,7 +478,7 @@ export class TagsState {
public async save(tag: SNTag | SmartView, newTitle: string) {
const hasEmptyTitle = newTitle.length === 0;
const hasNotChangedTitle = newTitle === tag.title;
const isTemplateChange = this.application.isTemplateItem(tag);
const isTemplateChange = this.application.items.isTemplateItem(tag);
const siblings =
tag instanceof SNTag ? tagSiblings(this.application, tag) : [];
@@ -500,7 +508,8 @@ export class TagsState {
}
if (isTemplateChange) {
const isSmartViewTitle = this.application.isSmartViewTitle(newTitle);
const isSmartViewTitle =
this.application.items.isSmartViewTitle(newTitle);
if (isSmartViewTitle) {
if (!this.features.hasSmartViews) {
@@ -541,7 +550,7 @@ export class TagsState {
item.content_type === ContentType.Tag ||
item.content_type === ContentType.SmartView
) {
const matchingTag = this.application.findItem(item.uuid);
const matchingTag = this.application.items.findItem(item.uuid);
if (matchingTag) {
this.selected = matchingTag as AnyTag;
@@ -554,7 +563,9 @@ export class TagsState {
}
public get hasAtLeastOneFolder(): boolean {
return this.tags.some((tag) => !!this.application.getTagParent(tag));
return this.tags.some(
(tag) => !!this.application.items.getTagParent(tag.uuid)
);
}
}
@@ -575,7 +586,7 @@ class TagsCountsState {
);
tags.forEach((tag) => {
newCounts[tag.uuid] = this.application.countableNotesForTag(tag);
newCounts[tag.uuid] = this.application.items.countableNotesForTag(tag);
});
this.counts = newCounts;